PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 15th, 2003, 06:53 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
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

Reply With Quote
  #2  
Old April 16th, 2003, 03:10 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via Yahoo to fakker
Hey Dave,

I cant see anything that's wrong here, but try this for size:

PHP Code:
<?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");
?>


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:
 print_r($_POST); 


in the HandleForm.php page.... that will print out all the variables sent to the page.

Hope this helps some!
__________________
Matt 'Fakker' Facer

mattfacer.com

Reply With Quote
  #3  
Old April 16th, 2003, 04:19 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
you can also use print_r($_REQUEST);

Reply With Quote
  #4  
Old April 16th, 2003, 09:14 AM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
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

Reply With Quote
  #5  
Old April 16th, 2003, 09:19 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via Yahoo to fakker
did u try what we suggested? what is the output if you try using the print_r($_REQUEST); command?

Reply With Quote
  #6  
Old April 16th, 2003, 09:36 AM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
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.

Reply With Quote
  #7  
Old April 16th, 2003, 10:05 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via Yahoo to fakker
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:
<?php

print_r
($_POST);
    
?>


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!

Reply With Quote
  #8  
Old April 16th, 2003, 01:28 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
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

Reply With Quote
  #9  
Old April 16th, 2003, 03:26 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
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

Reply With Quote
  #10  
Old April 16th, 2003, 05:33 PM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via Yahoo to fakker
hehe!! I see what you did there!! lol!!

ok, let us know when you make the move!!

Reply With Quote
  #11  
Old April 16th, 2003, 09:44 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
Talking IT WORKS!! IT WORKS!!!

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

Reply With Quote
  #12  
Old April 17th, 2003, 02:27 AM
fakker fakker is offline
The calm b4 the storm
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Manchester, UK
Posts: 404 fakker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via Yahoo to fakker
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

Reply With Quote
  #13  
Old April 17th, 2003, 09:01 AM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
Question ????

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

Reply With Quote
  #14  
Old April 18th, 2003, 02:11 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
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:
echo '$somevariable'//This will actually print $somevariable to the 
//screen.. instead of what is holding it where as:
echo "$somevariable"//will print the value of what is inside the variable 

Reply With Quote
  #15  
Old April 18th, 2003, 05:53 PM
dfano dfano is offline
Always Learning (I Think)
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: NYC Baby!!!!
Posts: 123 dfano User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via AIM to dfano Send a message via Yahoo to dfano
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?

Reply With Quote
  #16  
Old April 18th, 2003, 10:44 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 650 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
That really depends on what you want it to do.. if you expect that you're going to get quite a bit of replies to your feedback, you can pump it all into a database that you can sort the information by... or.. you could just have it email out.

Personally.. I store mine in a small database that i go through at the end of the week.. same thing with server error emails.. then just purge the information.. saves on having to put stress on the mail server

and no worries, i got what you were trying to say last time

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP script is not reading HTML form


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap