joeldalmas Posted March 2, 2006 Share Posted March 2, 2006 [i]What i really just want to be able to do is have a text form and a button, when the user types something into the text form and presses the button, it saves that information to a php file and then i want to be able to bring that information up on the page somewhere.. if this is the code i use for submitting the information to the .php file, i'm not sure exactly what code to put inside the php file itself so that it is able to organize the information and then redisplay it where i want on the page...? all of the tutorials i have found dont have any source code, which i work really well with... :([/i]I got this code from a tutorial i read on php.netbasically what i 'think it does' is submits a users name and email address to a file called "foo.php"... and then it displays it....here's the submit code...[b]<form action="foo.php" method="post"> Name: <input type="text" name="username" /><br /> Email: <input type="text" name="email" /><br /> <input type="submit" name="submit" value="Submit me!" /></form>[/b]now ( I THINK) this is the code that displays the information the user submitted, or do i put this inside the php file? im not sure?[b]<?php echo $_POST['username']; echo $_REQUEST['username']; import_request_variables('p', 'p_'); echo $p_username; echo $HTTP_POST_VARS['username']; echo $username;?>[/b]............. Now, my problem is that i created a file called foo.php - and im not sure if this code up top is suppose to input the users name and email address into the file or what, but instead of it showing their name and email it just tries to open a blank php file called foo.php.... [b]i'm not even sure if this is what i want to use for what i am trying to acomplish..[/b] Quote Link to comment https://forums.phpfreaks.com/topic/3915-submit-data-uber-n00b/ Share on other sites More sharing options...
trq Posted March 2, 2006 Share Posted March 2, 2006 If this is your form...[code]<form action="foo.php" method="post">Name: <input type="text" name="username" /><br />Email: <input type="text" name="email" /><br /><input type="submit" name="submit" value="Submit me!" /></form>[/code]Then foo.php should look like...[code]<?php if (isset($_POST['username']) && isset($_POST['email'])) { echo $_POST['username']." ".$_POST['email']; }?>[/code]To simply display the posted values. Quote Link to comment https://forums.phpfreaks.com/topic/3915-submit-data-uber-n00b/#findComment-13572 Share on other sites More sharing options...
joeldalmas Posted March 2, 2006 Author Share Posted March 2, 2006 thank you!!,so what do i do with...<?phpecho $_POST['username'];echo $_REQUEST['username'];import_request_variables('p', 'p_');echo $p_username;echo $HTTP_POST_VARS['username'];echo $username;?> does this post it on the page?I'm sorry im such a noob, I'm mostly a designer but i do know some (flash)actionscripting and alot of html.... this is literally my first "2 hours" trying to learn php... :-Xwhen i clicked submit me, even with the code you gave me, it is still trying to just open the .php file, instead of actually saving the data into that file and then displaying it... any idea what im doing wrong?again, im sorry for the frustration :-Xjd Quote Link to comment https://forums.phpfreaks.com/topic/3915-submit-data-uber-n00b/#findComment-13575 Share on other sites More sharing options...
fusionpixel Posted March 2, 2006 Share Posted March 2, 2006 [!--quoteo(post=350992:date=Mar 2 2006, 09:53 AM:name=joel dalmas)--][div class=\'quotetop\']QUOTE(joel dalmas @ Mar 2 2006, 09:53 AM) [snapback]350992[/snapback][/div][div class=\'quotemain\'][!--quotec--]when i clicked submit me, even with the code you gave me, it is still trying to just open the .php file, instead of actually saving the data into that file and then displaying it... any idea what im doing wrong?again, im sorry for the frustration :-Xjd[/quote]When your browser is trying to open the php file instead of running it, it means that your server doesn't support (compile) PHP files. If you are testing on your own computer you have to install apache and php to be able to run php files. Since you are just starting to work with PHP i would recommend an installation Kit if you are on a PC, that will enable you to run your scripts on your machine, but if you are testing online ask your server administrator if you can run PHP scripts on your remote site. Quote Link to comment https://forums.phpfreaks.com/topic/3915-submit-data-uber-n00b/#findComment-13580 Share on other sites More sharing options...
joeldalmas Posted March 2, 2006 Author Share Posted March 2, 2006 [!--quoteo(post=350998:date=Mar 2 2006, 11:10 AM:name=fusionpixel)--][div class=\'quotetop\']QUOTE(fusionpixel @ Mar 2 2006, 11:10 AM) [snapback]350998[/snapback][/div][div class=\'quotemain\'][!--quotec--]When your browser is trying to open the php file instead of running it, it means that your server doesn't support (compile) PHP files. If you are testing on your own computer you have to install apache and php to be able to run php files. Since you are just starting to work with PHP i would recommend an installation Kit if you are on a PC, that will enable you to run your scripts on your machine, but if you are testing online ask your server administrator if you can run PHP scripts on your remote site.[/quote]I donwloaded the software "wamp5" and executed it... When i click teh submit button its still trying to externally open the php file.... something must be wrong in the code no?appreichate it,joel Quote Link to comment https://forums.phpfreaks.com/topic/3915-submit-data-uber-n00b/#findComment-13609 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.