通过url超链接从php表单传递变量

时间:2015-02-12 18:15:32

标签: forms variables url hyperlink

我正在尝试将变量从php表单传递到单独的页面,请注意我没有单独页面的权限。换句话说,表单是一个注册表单,它将包含我们想要传递到另一个单独页面以完成注册过程的信息。这就是我所拥有的:

<form id="contact-us" method="get" action="php/signup.php">
<div class="col-xs-12 animated" data-animation="fadeIn" data-animation-delay="300">
<input type="text" name="id" id="id" required="required" class="form light" placeholder="Sponsor's ID#    (leave it blank if you do not have one)" />
<input type="text" name="name" id="firstname" required="required" class="form light" placeholder="First Name" />
<input type="text" name="name" id="lastname" required="required" class="form light" placeholder="Last Name" />
<input type="text" name="mail" id="mail" required="required" class="form light" placeholder="Email (optional)" />
<input type="text" name="zipcode" id="zipcode" required="required" class="form light" placeholder="Zipcode" />
</div>
<div class="relative fullwidth col-xs-12">
<a href="http://example.com/sample.asp?name=<?php echo $id?>&name=<?php echo $firstname?>&name=<?php echo $lastname?>&name=<?php echo $mail?>&name=<?php echo $zipcode?>"><button type="submit" id="submit" name="submit" class="form-btn light">Join the Evolution</button></a>
</div>
<div class="clear"></div>
</form>

这是php代码:

$id = $_GET['id'];
$firstname = $_GET['firstname'];    
$lastname = $_GET['lastname'];
$email = $_GET['mail'];
$zipcode = $_GET['zipcode'];

echo $id;
echo $firstname;
echo $lastname;
echo $email;
echo $zipcode;

这是我得到的输出:

http://example.com/sample.asp?name=%3C?php%20echo%20$id?%3E&name=%3C?php%20echo%20$firstname?%3E&name=%3C?php%20echo%20$lastname?%3E&name=%20%3C?php%20echo%20$mail?%3E&name=%20%3C?php%20echo%20$zipcode?%3E

我还在学习,非常感谢任何帮助。提前谢谢!

0 个答案:

没有答案