|
#1
| |||
| |||
| Hello,everybody! I installed MAMP om my Mac ( running MACOSX 10.3.9),it works ok,but php 5.0 would not pass values. In case of values to go from a form to php page for processing I am totally lost.IT IS a deadlock. Values entered do not stay. Page 1. <html> <head> <title>hello</title> </head> <body> <center> <form method = "post" action = "process.php"> <h1> please enter your name:</h1> <input type = "text" name = "userName" value = ""> <br> <input type = "submit"> </center> </body> </html> So here I input something and go to Page2 (process.php) <html> <head> <title>hello</title> </head> <body> <center> <h1>Greeting</h1> <? print "<h2>Hello,$userName!</h2>"; ?> </center> </body> </html> The result is "Hello,!" - and no nothing, the name entered in page 1 in gets kicked. Maybe someone knows what is wrong. Thanks. Valery. Last edited by Valery1; December 16th, 2005 at 01:00 AM. |
|
#2
| |||
| |||
| your page doesn't know where to get $username from. use something like $userName = $_POST['userName']; |
|
#3
| |||
| |||
| FYI... the code above needs to be on the recieving page and declared before your print statement |
|
#4
| |||
| |||
| Cmcdonal1, HURRAH. You are helpful. Because your tip helped. Now the pages happily communicate. You know what? For me this is half of the puzzle. The school book I have says as HTML page with a form in it goes to PHP page for processing , PHP automatically turns all elements of the form into variables.So in our case userName is turned into $userName. And the value entered in userName is supposed to stay in $userName. AND IT DOES.If we test the above pages on PC. Everything works fine on my PC with W2K on it. Whereas on Mac variable userName needs to be specified twice:PHP does it by default, then you enhance with $userName = $_POST['userName']; And if you don't,it does not work. |
|
#5
| ||||
| ||||
| The newer versions of PHP disabled the direct $varname access to POST variables for security reasons.
__________________ MacBook Pro 2.16GHz Core2Duo 3GB RAM, G4 1.4GHz OSX Tiger 1.25GB RAM, Dual 2GHz G5 OSX Tiger 2GB RAM (freakin shweet) Athlon 64 Windoze XP for school work (programming) 1GB RAM dferns@macosx.com |