|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
PHP script is not reading HTML form
i cant seem to get the PHP script to read the data ffrom the html form. the text before the answer in the sript is getting printed but the content from the form is beinf ignored .I am trying to do and example in abook and it does not work. please take a look and see if you see something wrong.
---Form2.html--- <HTML> <HEAD> <TITLE>HTML Form</TITLE> </HEAD> <BODY> <FORM ACTION="HandleForm.php" METHOD=POST> First Name <INPUT TYPE=TEXT NAME="First" SIZE=20> <BR> Last Name <INPUT TYPE=TEXT NAME="LastName" SIZE=40><BR> E-mail Address <INPUT TYPE=TEXT NAME="Email" SIZE=60><BR> Comments <TEXTAREA NAME="Comments" ROWS=5 COLS=40></TEXTAREA><BR> <INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!"> </FORM> </BODY> </HTML> HandleForm.php <html> <head></head> <body> <?php /* This page receives and handles the data generated by "form.html". */ print ("Your first name is $first<BR>\n"); print ("Your last name is $LastName<BR>\n"); print ("Your E-mail address is $Email<BR>\n"); print ("This is what you had to say:<BR>\n $Comments<BR>\n"); ?> </body> </html> Thanks dave |
|
#2
|
|||
|
|||
|
Hey Dave,
I cant see anything that's wrong here, but try this for size: PHP Code:
Notice I just replace your variables with the $_POST command. I am not sure if this will make a difference, but it's worth a try!! you can also use: PHP Code:
in the HandleForm.php page.... that will print out all the variables sent to the page. Hope this helps some! |
|
#3
|
|||
|
|||
|
you can also use print_r($_REQUEST);
|
|
#4
|
|||
|
|||
|
still not working?
thanks for the information.
you can see the page @ http://www.fs3d.com/form2.html and see that the part that is supposed to be filled in is blank. i get the HTML tag because it printing the text and <BR>, just no form results. could this be a setting on the server? Thanks again, Dave |
|
#5
|
|||
|
|||
|
did u try what we suggested? what is the output if you try using the print_r($_REQUEST); command?
|
|
#6
|
|||
|
|||
|
sorry!!
can you please show me an example of how to impliment that command. ive tried it a few ways and i think im typing it wrong.
sorry for the ignorance, Dave P.S. i am very new at programing. i only have a mild grasp of action scripting, and HTML, i dont really consider those true programing. I am more a graphics person but im trying to learn to do both so i can produce a better product in the end. and programing is cooler. do you think PHP is a good place to start for web interactivity or should i try Perl or JSP? Last edited by dfano : April 16th, 2003 at 09:47 AM. |
|
#7
|
|||
|
|||
|
hey, no worries... everyone has to start somewhere!!
as for the command, simply cut and paste this line and place it inside the HandleForm.php page PHP Code:
that should produce a string something like: Array ( [First] => matt [LastName] => facer => [email]m@m.com [Comments] => hope this works! [SUBMIT] => Submit! ) If you dont see anything in that, then there is a problem with the PHP code.... I suggested using $_POST['variablename'] ... give that a try as well.... I started out with HTML, then ASP, then found that PHP was easier and supported more widely on the net.... not sure about JSP.. never done it myself... but I think it's quite popular! Employers sure want it! |
|
#8
|
|||
|
|||
|
still trying
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /home/httpd/html/HandleForm.php on line 9
is the error i get when using $_POST['variablename']. as for the the other option "print_r($_POST);" on the local server that i set up ussing apache (did it my self so im not sure if it works good, also its 2.0 so it might be different) i get an array much like the one you typed for me. On the remote server that i use for hosting i get "array()" and thats it. Thanks Dave |
|
#9
|
|||
|
|||
|
Hey, Im not Totally stupid.
i just got a response from the web host saying that the server that was hosting my site does not handle POSTs very well. so they are going to move me to a new server. thanks for the help ill keep you "POSTed" (sorry i had to do it)
thanks Dave |
|
#10
|
|||
|
|||
|
hehe!! I see what you did there!! lol!!
ok, let us know when you make the move!! |
|
#11
|
|||
|
|||
|
THANKS FOR ALL THE HELP. they moved me over to a new server that handles POST better.
so how do i go about joining FAWB!! sound like a good foundation. i dont know if i can promote a company on this forum but anybody needs a good hosting company e-mail me beacause this companies service is great.. Thanks again Dave |
|
#12
|
|||
|
|||
|
hey,
glad you got it all sorted! Sounds like a very reasonable host! Not sure about advertising it, but you can always give it a mention! (so long as it's not over kill!) the FAWB is a result of the "400 posts" thread in the "Lizard Lounge" forum on this website... (http://www.devarticles.com/forum/sh...30&pagenumber=7) -- it's a lot of fun!! lol ![]() |
|
#13
|
|||
|
|||
|
okay, this does not work:
----------------------------------------------- <?php /* This page receives and handles the data generated by "form.html". */ print ("Your first name is $_POST['First']<BR>\n"); print ("Your last name is $_POST['LastName']<BR>\n"); print ("Your E-mail address is $_POST['Email']<BR>\n"); print ("This is what you had to say:<BR>\n $_POST['Comments']<BR>\n"); ?> --------------------------------------------------- but this does: --------------------------------------------------- print ("Your first name is $_POST[FirstName]<BR>\n"); print ("Your last name is $_POST[LastName]<BR>\n"); print ("Your E-mail address is $_POST[Email]<BR>\n"); print ("This is what you had to say:<BR>\n $_POST[Comments]<BR>\n"); ?> ------------------------------------------------------------ Why does that make a difference? The first way is exacylt how it's writtem in the book. (maybe it's not such a good book?) Thanks Dave |
|
#14
|
||||
|
||||
|
The reason why it's not working is because it's quotes within quotes.. if you escape the 's <ie \' > then that will work, but from everything I've ever done, if you have $_POST[] variables within an echo or print statement then you need to just take out the single quotes and it will work fine.. I'm sure that either fakker or Ben have a more technical explination on why it does that
![]() I ran across something about it in one of my books but I can't seem to find it now that I need to explain it.. <murphy's law, aparently..> But I think it's something along the same principal that the echo <or print> statements with single quotes instead of double, that it doesn't process any variable values.. IE: PHP Code:
![]() |
|
#15
|
|||
|
|||
|
I was to quick on the Cut & Paste
This did NOT work:
-------------------------- print ("Your first name is $FirstName.<BR>\n"); print ("Your last name is $LastName.<BR>\n"); print ("Your E-mail address is $Email<BR>\n"); print ("This is what you had to say:<BR>\n $Comments<BR>\n"); ?> (This is how it is in the book im reading) -------------------------- and this did: --------------------------- print ("Your first name is $_POST[FirstName]<BR>\n"); print ("Your last name is $_POST[LastName]<BR>\n"); print ("Your E-mail address is $_POST[Email]<BR>\n"); print ("This is what you had to say:<BR>\n $_POST[Comments]<BR>\n"); ?> --------------------------- Sorry for posting it wrong the last time, that one was kind of stupid, i should have noticed. Thanks Dave ?? when people fill out forms on line where to they usually go? to a data base, or e-mail? |
|
#16
|
||
|
|