full email id passing in url

2020-04-02 06:49发布

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.

标签: php forms email
2条回答
虎瘦雄心在
2楼-- · 2020-04-02 07:01

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:

The superglobals $_GET and $_REQUEST are already decoded.

Try to echo $_GET['email'] in PHP and you'll see xyz@abc.com again.

查看更多
姐就是有狂的资本
3楼-- · 2020-04-02 07:16

Urls are encoded, that's why @ becomes %40, it comes from the way data is sent from the form/ If you use get method, this is how it will be formated in the url. But don't worry, what you get in php is correct and decoded.

查看更多
登录 后发表回答