newuserphp Posted February 4, 2015 Share Posted February 4, 2015 Hello, I just started teaching myself PHP I've only been doing it for 3 days now Today, I hit a barrier : I am using an online tutorial, and I came across this example HTML code : <!DOCTYPE html> <html> <head> <title>My Form</title> </head> <body> <form action="TestFile.php" method=post> My name is: <br> <input type="text" name="YourName"> My favorite word is: <br /><input type="text" name="FavoriteWord"> <input type="submit" name="submit" value="Here we go !"> </form> </body> </html> Ok, that's the HTML form. And here is the PHP file "TestFile.php" <html> <head> <title>My Output!</title> </head> <?php // Capture the values posted to this php program from the text fields // which were named 'YourName' and 'FavoriteWord' respectively $YourName = $_REQUEST['YourName'] ; $FavoriteWord = $_REQUEST['FavoriteWord'] ; ?> <body bgcolor="#FFFFFF" text="#000000"> <p> Hi <?php print $YourName; ?> <p> You like the word <b> <?php print $FavoriteWord; ?>??</b> <p>That is a nice word. Well done! </body> </html> But, it's not working. The HTML form works fine, it inputs the info. But, when I click "Submit", the PHP file does not provide the output It shows the statements, ok. But, the "name" and "favorite word" fields are blank. It shows nothing. Everything is exactly as stated in the Online Tutorial. So, I know I did not miss anything. But, why is the output not being displayed? Thanks Link to comment https://forums.phpfreaks.com/topic/294377-what-am-i-missing/ Share on other sites More sharing options...
requinix Posted February 4, 2015 Share Posted February 4, 2015 One thread at a time, please. Are you sure you installed PHP properly? In the address bar of your browser, does the URL start with "http://" and not "file://"? Link to comment https://forums.phpfreaks.com/topic/294377-what-am-i-missing/#findComment-1504875 Share on other sites More sharing options...
Werezwolf Posted February 5, 2015 Share Posted February 5, 2015 $YourName = $_REQUEST['YourName'] ; $FavoriteWord = $_REQUEST['FavoriteWord'] ; I would try replacing $_REQUEST with $_POST. See http://php.net/manual/en/reserved.variables.request.php http://php.net/manual/en/reserved.variables.post.php Link to comment https://forums.phpfreaks.com/topic/294377-what-am-i-missing/#findComment-1504936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.