How Can We Give 2 Variables In Form ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

How Can We Give 2 Variables In Form ?

Post by saqib389 »

i just want to get the values from login.php
how can i get more than 1 variables here ?

Code: Select all

<form action = request.php?username=<?= $_REQUEST['username'];?> email=<?= $_POST['email']?>   method="post" >

this code giving me error... plz help me out
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

you forgot the ampersand (&).

Code: Select all

<form action=request.php?username=<?= $_REQUEST['username'];?>&email=<?= $_POST['email']?>  method="post" >
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

Why are you sending the data as a query string if the form method is post? Is this intentional?
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Skittlewidth wrote:Why are you sending the data as a query string if the form method is post? Is this intentional?
It's not a good idea to do that anyway. Some browsers will drop the query string when trying to send data via GET and POST simultaneously. Search the forums, you should find a thread about it somewhere.

Also, saqib389, it's difficult to provide any help without any code to work with. Please post what your login.php file looks like.

In addition to what mickd said about the ampersand, the action="" parameter requires quotes. Although some browsers will work anyhow if you forget them, but if you happen to have non url-encoded characters in it (which you should have escaped anyway), then your page may not work properly on some browsers.

Here's a better example of what your form should look like:
<form action="request.php?username=<?= urlencode($_REQUEST['username']) ?>&email=<?= urlencode($_POST['email']) ?>" method="post" >

<!-- Some form stuff in here... -->

</form>
What I also noticed in your code was <?= "bla"; ?> using the semicolon. That'll give you a parsing error, since in <?=?> tags this gets dropped.

Another thing: Try to avoid $_REQUEST. It's an open invitation to crackers and script kiddies. It's a security vulnerability, because it includes all request objects; ie: GET, POST, and COOKIE.
saqib389
Forum Commoner
Posts: 44
Joined: Wed Nov 30, 2005 2:13 am

Post by saqib389 »

THNX gUYzzz
i got my answer

hats of for you guyzzz

i will ask you more question i hope u ppl will help me more....
thnx again
SaQib
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

Whoa there! As far as I know, "guys" is spelled with an "s", and only one as well, mind you. :lol:
Post Reply