arcanepsyche Posted December 23, 2008 Report Share Posted December 23, 2008 Hello, I am very new to PHP and have been watching Stefan's videos in an attempt to learn. I'm doing well, except that I'm stuck on getting collecting information to display on the .php page that is processing the form results. When I submit the form, everything loads fine in terms of text and html code, but the variables I have set up using the $_post information are just being skipped. I'm certain the php is collecting the form info because I used $_get and the information showed up in the URL bar, it just didn't display on the page. Here is the code: (changed back to $_post) <?php $_post['name_first']; $_post['name_last']; $_post['email_address']; $_post['comment']; $name_first=$_post['name_first']; $name_last=$_post['name_last']; $email=$_post['email_address']; $comments=$_post['comment']; print "The first name is: {$name_first} "; print "The last name is: {$name_last} "; print "The email address is: {$email} "; print "And the comments are: {$comments} "; ?> Any help for a beginner is appreciated! Quote Link to comment Share on other sites More sharing options...
monkeysaurus Posted December 23, 2008 Report Share Posted December 23, 2008 Hi, there's no need for you to have the following lines of code: $_post['name_first']; $_post['name_last']; $_post['email_address']; $_post['comment']; You can safely delete those. Provided your form fields have the names 'name_first', 'name_last', 'email_address', and 'comment', your form should now work as expected. Quote Link to comment Share on other sites More sharing options...
arcanepsyche Posted December 23, 2008 Author Report Share Posted December 23, 2008 (edited) Thanks for the help, it's good to know I don't need that code. However, I'm still getting the same result. Here is the code after deleting the portion you told me to: <?php $name_first=$_post['name_first']; $name_last=$_post['name_last']; $email=$_post['email_address']; $comments=$_post['comment']; print "The first name is: {$name_first} "; print "The last name is: {$name_last} "; print "The email address is: {$email} "; print "And the comments are: {$comments} "; ?> I'm still not getting any of the form information to display. I'm not sure if this matters, but I've created my form in Serif's Webplus10 and then set the form element names in that program. Then, I set it to use a remote scripts from my hard drive and it uploads both the page and my scripts to my existing hosting account. Would Webplus somehow be the problem? Here is a link to a page I just created with a test form set to submit to my .php page. Not sure if that's helpful either though: www.cornerstonewebsolutions.com/page10.html I've checked the names of the form elements over and over to make sure they match, so I know it doesn't have to do with that. Thanks again, Zac Edited December 23, 2008 by arcanepsyche Quote Link to comment Share on other sites More sharing options...
jbwebdesign Posted December 23, 2008 Report Share Posted December 23, 2008 copy an paste the whole code from your form as well and then I can help you out Quote Link to comment Share on other sites More sharing options...
arcanepsyche Posted December 23, 2008 Author Report Share Posted December 23, 2008 Test Form Quote Link to comment Share on other sites More sharing options...
monkeysaurus Posted December 23, 2008 Report Share Posted December 23, 2008 jbwebdesign, you can see the form code on the link that was posted. That's really strange, everything looks correct. And when I use Tamper Data to view the request being sent, the variables are being POSTed properly - so it must be a problem on the receiving page. Two things I can suggest though it shouldn't make any difference: Try changing '$_post' to '$_POST'. Try concatenation instead of using the variables directly - like this: print 'The first name is:'. $name_first .' '; And let us know what happens. Quote Link to comment Share on other sites More sharing options...
monkeysaurus Posted December 23, 2008 Report Share Posted December 23, 2008 One more thing - try putting this at the top of testlandpage.php, before anything else, and let us know what is printed: <?php print_r($_POST);?> Quote Link to comment Share on other sites More sharing options...
arcanepsyche Posted December 23, 2008 Author Report Share Posted December 23, 2008 Alright, problem solved! It was the $_post vs $_POST. I tried your array before changing anything and the array caught the information but the $print function didn't. And then I changed the code to $_POST and everything displayed correctly. I heard that the capitalization doesn't matter, is that maybe not true? Thanks Monkeysaurus for your help! Zac Quote Link to comment Share on other sites More sharing options...
monkeysaurus Posted December 23, 2008 Report Share Posted December 23, 2008 (edited) That's good to hear. Variable names can be upper or lower case, although you should be consistent. I would suggest looking into camel case. Variable names are case sensitive, so $variable isn't the same as $VARIABLE or $Variable. Pick a convention and stick to it. For the superglobals ($_GET, $_POST, $_COOKIE, $_REQUEST, $_FILES etc) you should be using caps, or it won't work (as we found out ). The superglobal arrays are variables like any other, and so are case sensitive. I should have clocked that earlier, but it's almost midnight here. (That's my excuse and I'm sticking to it!) All the best! John Edited December 23, 2008 by monkeysaurus Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.