Jump to content


Photo

Submit Data (uber n00b)


  • Please log in to reply
4 replies to this topic

#1 joeldalmas

joeldalmas
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 March 2006 - 03:32 PM


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 got this code from a tutorial i read on php.net

basically 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...
<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>


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?
<?php

echo $_POST['username'];
echo $_REQUEST['username'];

import_request_variables('p', 'p_');
echo $p_username;

echo $HTTP_POST_VARS['username'];

echo $username;
?>

.............

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.... i'm not even sure if this is what i want to use for what i am trying to acomplish..

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 02 March 2006 - 03:45 PM

If this is your form...
<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>
Then foo.php should look like...
<?php

  if (isset($_POST['username']) && isset($_POST['email'])) {
    echo $_POST['username']." ".$_POST['email'];
  }

?>
To simply display the posted values.

#3 joeldalmas

joeldalmas
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 March 2006 - 03:53 PM

thank you!!,
so what do i do with...
<?php

echo $_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... :-X

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 :-X

jd

#4 fusionpixel

fusionpixel
  • Members
  • PipPipPip
  • Advanced Member
  • 64 posts

Posted 02 March 2006 - 04:10 PM

[!--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) View Post[/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 :-X

jd
[/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.
Did you know there is a manual for PHP? [a href="http://" target="_blank"]http://www.php.net[/a]
Did you know there is a manual for mySQL? [a href="http://" target="_blank"]http://www.mysql.org[/a]

#5 joeldalmas

joeldalmas
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 March 2006 - 05:29 PM

[!--quoteo(post=350998:date=Mar 2 2006, 11:10 AM:name=fusionpixel)--][div class=\'quotetop\']QUOTE(fusionpixel @ Mar 2 2006, 11:10 AM) View Post[/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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users