473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Method POST

I am working thru the book PHP, MySQL and Apache from the Sams teach yourself library. On page 202 the exercise it to create an HTML input screen and then pass the variables to php. When I try my it opens my PHP listing but does not display it as a website. Any help would be appreciated.
Jan 20 '12 #1
37 4156
Dormilich
8,658 Expert Mod 8TB
how do you open it?
Jan 20 '12 #2
Dormilich this is the line of code in the html form form action="send_simpleform.php" method="POST". What happens next then it that the .php file is opened for editing instead of being the web page parroting what was written the html form.

I went to the book CD to copy the code from there thinking maybe I had a typing error that I wasn't seeing. Those files work the same as mine.

Suggestions?!
Jan 21 '12 #3
Dormilich
8,658 Expert Mod 8TB
are you calling the file via http & localhost?
Jan 23 '12 #4
this is the line from the html page which "calls" the php code.

<form action="send_simpleform.php" method=post>

all pages are being displayed in the localhost server. I am using Apache for this.

If I change the entire process to be just one php text file with php code list on the top with the html code listed below with this command <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST"> in the html the process works.

So I am thinking it is something to do with the act of existing one file to go to another one. It is finding the called file just isn't running it. Any suggestions????

<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
Jan 23 '12 #5
Dormilich
8,658 Expert Mod 8TB
but in general, .php files are behaving as expected?
Jan 23 '12 #6
yes they are. My problem started when I tried to send variables from a Html page to a php page.

These are my first attempts at using this technology. I am just working through excerises in a book to learn. Everything has worked thus far with the exception of branching out from a html to php. My thoughts are at this time that being able to do this branching would prove very powerful and useful.

thanks in advance for your response and help.
Jan 23 '12 #7
Dormilich
8,658 Expert Mod 8TB
maybe it's time to look at your code. usually there is no problem in calling PHP scripts from HTML (and to be precise, every web page, be it created by PHP or any other server script, ends up as HTML).
Jan 23 '12 #8
here is the code (from the book examples....)

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>A simple HTML form</title>
  4. </head>
  5. <body>
  6. <form action="send_simpleform.php" method="POST">
  7. <p><strong>Name:</strong><br/>
  8. <input type="text" name="user"></p>
  9. <p><strong>Message:</strong><br/>
  10. <textarea name="message" rows="5" cols="40"/></textarea></p>
  11. <p><input type="submit" value="send"/></p>
  12. </form>
  13. </body>
  14. </html>
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo "<p>Welcome <b>".$_POST["user"]."</b>!</p>";
  3. echo "<p>Your message is:<br/><b>".$_POST["message"]."</b></p>";
  4. ?>
and again the html page does open the php file but it is not displaying as a page but opens it for editing the php file.

thanks!
Jan 23 '12 #9
Dormilich
8,658 Expert Mod 8TB
which browser do you use?
Jan 23 '12 #10
internet explorer - apache server set as localhost
Jan 23 '12 #11
Dormilich
8,658 Expert Mod 8TB
try Firefox or Chrome. I'm not trusting IE here.
Jan 23 '12 #12
I really need it to work in Internet Explorer. I don't have the other browsers.
Jan 23 '12 #13
Dormilich
8,658 Expert Mod 8TB
it would help to know whether the problem is server-side or IE.
Jan 24 '12 #14
Sadly, the exact same thing happens in Chrome....instead of running the PHP code it opens the code in a text editor (note pad).
Jan 24 '12 #15
Dormilich
8,658 Expert Mod 8TB
OK, this seems like a header problem.

try the following
- HTML code as is
- send_simpleform.php:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. header("Content-Type: text/plain");
  3. echo "done";
  4. ?>
if that behaves the same (quite probable) you need to check the Apache or IIS configuration (whichever server you have). it might be that PHP is not registered as handler.

and while in Chrome, you can check the file's headers in the developer tools.
Jan 24 '12 #16
thanks, but still reacting the same.
Jan 24 '12 #17
Dormilich
8,658 Expert Mod 8TB
what about the file headers in chrome? (Tools > Developer Tools > Network tab)
Jan 24 '12 #18
it might be that PHP is not registered as handler.

where would I find that out?

I did run it in chrome with the devoloper tools on but I'm not sure what I am looking for.
Jan 24 '12 #19
Dormilich
8,658 Expert Mod 8TB
it might be that PHP is not registered as handler.
where would I find that out?
in the server configuration file(s).


I did run it in chrome with the devoloper tools on but I'm not sure what I am looking for.
you're looking for the network tab (blue globe with LAN connector). next, click on the file name send_simpleform.php. now the panel changes from a table to some text. the first tab of the text (which should be open now) should read "Headers". look under "Response Headers" for "Content-Type". this should be text/html, were it working. other types may cause the browser to download the file (e.g. application/octet-stream)
Jan 24 '12 #20
Thanks for all this useful information - pretty slick and, being new to the scene, didn't even realize it existed! But on to the problem at hand.

when the html code is in the developer mode the method listed is GET even though the code inside says POST.

The PHP page lists the content type as text-plain.

The entire process though is no longer opening a separate window at least in the chrome.

Any other ideas???

Thanks!
Jan 24 '12 #21
Rabbit
12,516 Expert Mod 8TB
You've said other PHP pages have worked fine. Try those pages again and post the PHP for one of those files.
Jan 24 '12 #22
I've never had a POST PHP page work. As you can tell I'm just a beginner.

The examples where the PHP code is listed within a Html page work.

My setup will preform the statement below properly - just bring that up since it is getting the format to use from another php file.

$format = include("local_format.php")

Dormilich walked me thru using chrome to display the html code and I find the GET vs POST command a bit alarming - spoken with very limited knowledge - I would have expected that to be POST.

Thanks for your help.
Jan 24 '12 #23
Dormilich
8,658 Expert Mod 8TB
$format = include("local_format.php")
include() is not a function but a language construct. the correct syntax would be include "local_format.php";
if you want a file’s content in a string use file_get_contents().

Dormilich walked me thru using chrome to display the html code and I find the GET vs POST command a bit alarming - spoken with very limited knowledge - I would have expected that to be POST.
GET/POST command?
Jan 24 '12 #24
when the html code is in the developer mode the method listed is GET even though the code inside says POST.

this is what I am referring to.
Jan 24 '12 #25
Dormilich
8,658 Expert Mod 8TB
the HTML page itself must be GET because you call it via URL.
Jan 25 '12 #26
well I am still at a stand still - cannot get this basic command to function.

any other suggestions???

I do notice on the failures that I receive that the secondary PHP page type is coming in as plain/text - if I understand you correctly from prior post that should be html - how would I change that?

Thanks for all your help, I do appreciate but it's very hard not to be frustrated.
Jan 25 '12 #27
Dormilich
8,658 Expert Mod 8TB
I do notice on the failures that I receive that the secondary PHP page type is coming in as plain/text - if I understand you correctly from prior post that should be html - how would I change that?
if you used the code from post #16, that's correct. though normally a plain text file should be displayed in the browser (unless you told it to download the file).

otherwise could you write down all the headers you get?

regarding your server settings, which server do you use? (I only know Apache somewhat)
Jan 25 '12 #28
file:///C:/Program%20Files/Apache%20Software%20Foundation/Apache2.2/htdocs/simpleform.html

for the php form it is....
file:///C:/Program%20Files/Apache%20Software%20Foundation/Apache2.2/htdocs/send_simpleform.php

however, shouldn't the second one be localhost/send_simpleform.php?

because if I change the address to that then I get a webpage with done on it.
Jan 25 '12 #29
Dormilich
8,658 Expert Mod 8TB
if you want to use PHP, never use the file: protocol anywhere (not even in the calling HTML page)! if you do, .php is treated as text because the file system recognioses PHP files only as text.
Jan 25 '12 #30
I didn't change anything to read those URL in my samples - just something that I noticed.

Maybe I'm not understanding what you mean by headers. My code has changed since the beginning with the exception of the lines you wanted me to add to send_simpleform.php.

I am using an apache server.
Jan 25 '12 #31
Dormilich
8,658 Expert Mod 8TB
the URL of your HTML form should read:
http://localhost/simpleform.html

with headers I mean HTTP headers.
Jan 25 '12 #32
finally success! I've been opening the html pages from the actual folder they are in.

When I type the URL using the localhost then they run the php page. Boy my laziness sure created a huge problem for me.

Thanks for all your help and patience - I know you must be just rolling your eyes big time. If it makes you feel any better at least you taught me a bunch of stuff!

Thanks again!
Jan 25 '12 #33
Dormilich
8,658 Expert Mod 8TB
rest assured that you're not the first one with that problem, though I may point to posts #2 & #4 where I asked exactly for that.
Jan 25 '12 #34
yep, and now when I read those two post they make sooo much sense! You've taught me much in these past couple of days!

thanks again!
Jan 25 '12 #35
Dormilich
8,658 Expert Mod 8TB
and that's just scratching the surface ...
Jan 25 '12 #36
Make sure that you are using "localhost" to host your related php and html files. Do not open the html page direclty by double-clicking. Also make sure that your Appache server is running soundly.
Jan 25 '12 #37
Dormilich
8,658 Expert Mod 8TB
@Kadir Razu: you are aware that this problem is already solved?
Jan 25 '12 #38

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rob | last post by:
THis is my code. What im trying to accomplish is the user fills out the form then when they hit submit it displays what the entered on the samne page but i get this error message when I hit submit...
3
by: Armin Irger | last post by:
Hi, i'am running a debian sarge with the delivered apache2 mysql and php4. The file "mitarbeiter_eingabe.php" gets the data over a html <FORM> and send it to...
5
by: phil | last post by:
This is a quick plea on something that has me stumped. I have a python script importing "cgi" I developed my script on a local machine using method = get for uploading form data. My code...
2
by: Heinrich Klein | last post by:
Hello I have got an the Unload Handler is it possible when the Browser is closed to send a Method post to a CGI program? If yes how can i do this normally i need to push a Button. Thanks for...
4
by: Don | last post by:
How do I retrieve URL parameters via html, where they were provided from a <form method=post...>? Thanks in advance, Don -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----...
4
by: Paul J. Lay | last post by:
I am sending and receiving multipart messages using the WebClient UploadData method Method=Post. Everything seems to work well except when the URL contains parameters. For example:...
12
by: Britney | last post by:
Hi guys, in my default.aspx file, I have following code. when I go to browser, I enter values in both textboxs, then I hit submit Button, however, it didn't go to page2.aspx. instead, it was...
8
by: burut | last post by:
Hi, I have index.php page (attached). The flow is when I put username/password on the page, it will submit to be processed by connection.php where in connection.php, it require koneksi_db.php to...
11
by: =?Utf-8?B?QkxVRVNUQVI=?= | last post by:
Here is the link of the website http://www.smartcharlotte2050.com/YourThoughts.asp I have been told to change only the form action part of this site.which is to "response.asp" Here the method...
4
by: codyshea2000 | last post by:
this is my html /php form but every time i click submit it says the metod post is not alowed how can i fix this <!-- Form made by cody.m --> <center> <FORM METHOD="POST" ACTION="test.php"> ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.