User Control Panel
Advertisements

HELP US, HELP YOU!

PHP || Grr..

 
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions
View unanswered posts
Author Message
M4RTIN
Member
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Sun Apr 03, 2005 11:36 am    Post subject: Reply with quote

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
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Sun Apr 03, 2005 1:00 pm    Post subject: Reply with quote

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
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Apr 03, 2005 1:31 pm    Post subject: Reply with quote

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
God Like


Joined: 06 Jan 2004
Posts: 562
Location: Netherlands
Reputation: 39.8Reputation: 39.8Reputation: 39.8Reputation: 39.8

PostPosted: Sun Apr 03, 2005 4:45 pm    Post subject: Reply with quote

Not to mention,

Quote:
"text' size="20" name="txt">
Back to top
zander
God Like
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Wed Apr 06, 2005 1:35 pm    Post subject: Reply with quote

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
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Wed Apr 06, 2005 2:29 pm    Post subject: Reply with quote

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
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Wed Apr 06, 2005 2:42 pm    Post subject: Reply with quote

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
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Wed Apr 06, 2005 8:36 pm    Post subject: Reply with quote

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
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Fri Apr 08, 2005 5:07 am    Post subject: Reply with quote

Ok, Thank's for helping.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> General Programming Questions All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group