i am new to php .i am trying to develop a application with html and php. i passed variable from form to url.all code given below
<FORM METHOD="get" ACTION="action1.php">
Type your first name: <INPUT TYPE="text" NAME="FirstName"> <br/>
Type your last name: <INPUT TYPE="text" NAME="LastName"> <br/>
Type your email:<INPUT TYPE="email" NAME="email">
<INPUT TYPE="submit" VALUE="Click and See">
</FORM>
the output url is http://example.com/action1.php?FirstName=jon&LastName=Kuri&email=xyz%40abc.com
but i want it to be http://example.com/action1.php?FirstName=jon&LastName=Kuri&email=xyz@abc.com
How to do it.
Thanks in advance for any suggestion.
update:
<?php
$email="xyz@gmail.com";
$decode=urldecode($email);
?>
<FORM METHOD="get" ACTION="action1.php">
Type your first name: <INPUT TYPE="text" NAME="FirstName"> <br/>
Type your last name: <INPUT TYPE="text" NAME="LastName"> <br/>
Type your email:<INPUT type="hidden" NAME="email" value="<?php $decode; ?>">
<INPUT TYPE="submit" VALUE="Click and See">
</FORM>
This also does not give me the required result.here i am pre defining email value.
You are simply seeing certain characters encoded to be URL safe (like
@
).When you examine the data server-side it will look like the original data on the form. You don't have to decode anything, PHP does it for you automatically.
From the docs:
Try to
echo $_GET['email']
in PHP and you'll seexyz@abc.com
again.Urls are encoded, that's why
@
becomes%40
, it comes from the way data is sent from the form/ If you useget method
, this is how it will be formated in the url. But don't worry, what you get in php is correct and decoded.