|
| Author |
Message |
M4RTIN Member

Joined: 31 Dec 2004 Posts: 134
  
|
Posted: Sun Apr 03, 2005 11:36 am Post subject: |
|
|
Guy's, Need help.
My little tiny n00b code isnt working ;|
| Code: | | <br /><br /><FORM ACTION="rainbow.php?text=<? echo $txt; ?>" METHOD=post><br /> <input type="text' size="20" name="txt"><br /> <input type="submit" value="Submit"><br /></form><br /><br /> |
It submit's, but it doesnt submit what the user imputted into the textbox, Can anyone help? |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Sun Apr 03, 2005 1:00 pm Post subject: |
|
|
Forms by default will take every variable within your form, and send it to its destination. You don't need to define what's sent within the action:
| Code: | | <form action="rainbow.php" method="post"><br /><input type="text" name="txt" size="20"><br /><input type="submit" value="Submit"><br /></form> |
That will send "txt=(whatever they typed)" to rainbow.php _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
draget Not Yet a God

Joined: 29 Dec 2004 Posts: 367 Location: Australia
   
|
Posted: Sun Apr 03, 2005 1:31 pm Post subject: |
|
|
Beside the point, but you know, CGI.pm makes this quite easy in perl!
Also i would suggest you start coding in XHTML.
ie.
| Code: | | <form action="rainbow.php" method="post"><br /><input type="text" id="txt" size="20" /><br /><input type="submit" value="Submit" /><br /></form> |
closed input tags, and all lower case, id's instead of names. |
|
| Back to top |
|
 |
Siebe God Like

Joined: 06 Jan 2004 Posts: 562 Location: Netherlands
    
|
Posted: Sun Apr 03, 2005 4:45 pm Post subject: |
|
|
Not to mention,
|
|
| Back to top |
|
 |
zander God Like

Joined: 14 Jan 2004 Posts: 540 Location: england
 
|
Posted: Wed Apr 06, 2005 1:35 pm Post subject: |
|
|
it might submit to the other page but who is to say the code on the rainbow page is coded correct to accept it?
ok i use forms on the welcome page of my website and this is what i use for users to input there name, email and age
| Code: | | <form action="construction.php" method="post"><br /><div>Enter your Name: <br /><input type="text" value="" name="name"> <br /><br><br /><br>Enter your Email: <br /><input type="text" value="" name="email"> <br /><br><br /><br>Enter Your Age <br /><input type="text" value="" name="age"> <br /><input type="submit" value="Submit Query"> </div> |
that is to submit the information which has been typed into the boxes
now on my recieving page i show it as info so i put this
| Code: | | Your Name = <?php $name = $_POST["name"]; echo $name; ?>.<br /> <br />Your Email = <?php $email = $_POST["email"]; echo $email; ?><br><br />Your Age = <?php $age = $_POST["age"]; echo $age; ?> |
now many of you out there may say that the coding can be shortened down but i dont care because it works fine as it is... if you want a tester go to www.crim.atomicoxide.co.uk as see mine
hope this helped |
|
| Back to top |
|
 |
M4RTIN Member

Joined: 31 Dec 2004 Posts: 134
  
|
Posted: Wed Apr 06, 2005 2:29 pm Post subject: |
|
|
I know how to do all of that, I was just wondering why this doesnt work:
| Code: | | <br /><FORM ACTION="rainbow.php?text=<? echo $txt; ?>" METHOD=post><br /><input type="text" size="20" name="txt"><br /><input type="submit" value="Submit"><br /></form><br /> |
|
|
| Back to top |
|
 |
zander God Like

Joined: 14 Jan 2004 Posts: 540 Location: england
 
|
Posted: Wed Apr 06, 2005 2:42 pm Post subject: |
|
|
well you dont need this bit
| Code: | | <br />text=<? echo $txt; ?>" | in the top line
all you need is
| Code: | | <br /><FORM ACTION="rainbow.php" METHOD=post> |
now with this
| Code: | | <br /><input type="text" size="20" name="txt"> |
instead of having "txt" it should be text, i dont realy know what you want ' size="20" ' to do
other than that it should work |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Wed Apr 06, 2005 8:36 pm Post subject: |
|
|
For a basic overview of how forms work:
| Code: | | <form action="recipient.php" method="get"><br />Name: <input type="text" name="name"><br><br />Age: <input type="text" name="age"><br><br />Fav. Color: <input type="text" name="color"><br><br />E-Mail: <input type="text" name="email"><br><br /><input type="submit"><br /></form> |
Notice in the form action, it JUST goes to a php file, it doesn't do anything with the query strings. The form's submit button does all that work for you.
So hitting "Submit" would be the exact same as going to recipient.php?name=Billy+Bob&age=25&color=light+blue&email=name@domain.com
And it would follow that pattern no matter how many fields are in your form and no matter what you decide to name your fields.
Also, the difference between the "get" and "post" method is that GET will show all the form's data in the query string, POST will just show "recipient.php" and hide all the other data. But the data is still received the same in the script. _________________ Current Site (2008) http://www.cuvou.com/ |
|
| Back to top |
|
 |
M4RTIN Member

Joined: 31 Dec 2004 Posts: 134
  
|
Posted: Fri Apr 08, 2005 5:07 am Post subject: |
|
|
| Ok, Thank's for helping. |
|
| Back to top |
|
 |
|