开发者

Input value based on query string

How could I pass a query string value such as domain.com/register?invite=MR5OMxTyjYmTjcwNTyQjTZMyY5YY into a input box on a page?

For example say I had this: <input type="text" name="invite" value="" />

I'm using PHP

To c开发者_开发技巧larify what I mean, if a person loaded that URL, then the value would be automatically filled in with the query string of invite.


Simple:

<?php $invite = (array_key_exists('invite', $_GET)) ? htmlspecialchars($_GET['invite']) : ''; ?>
<input type="text" name="invite" value="<?php echo $invite; ?>" />


Try this:

<input type="text" name="invite" value='<?php echo $_GET["invite"]; ?>'  />


<input type="text" name="invite" value="<?php if(isset($_GET['register'])) echo $_GET['register']; ?>" />

This isn't secure at all, but it gives you a start.


Try fetching the invite key with $_GET['invite'] from the address bar (validate it first of course to prevent XSS attacks ;) ) and then place it in your input field within that value part as $invite for example so you end up with value="$invite"

Hope that helps!


<input type="text" name="invite" value="<?php echo $_REQUEST['invite']; ?>" />

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜