[英]How can I populate a textarea from a URL?
I am trying to write a script in PHP that can send a message to some user on a forum. 我正在尝试用PHP编写一个脚本,可以在论坛上向某个用户发送消息。 So for example, the message form can be formatted like such:
例如,消息表单可以这样格式化:
<input>Username Goes Here</input
<textarea>Message Goes Here</textarea>
Luckily I am able to populate the input field from how the URL is formatted. 幸运的是,我能够根据URL的格式填充输入字段。 However, I am not so lucky with the textarea part.
但是,我对textarea部分不太满意。
How would I be able to populate the textarea field? 我怎样才能填充textarea字段?
The link is formatted as such: 链接格式如下:
https://live.xbox.com/en-US/Messages?gamertag=gamertag
Where "gamertag" is the recipient “gamertag”是收件人的地方
The textarea is formatted as: textarea格式为:
<textarea class="compose empty" empty="true">Say something here...</textarea>
Thanks for the help! 谢谢您的帮助!
Like this : 像这样 :
<textarea class="compose empty" empty="true"><?php echo htmlspecialchars($_REQUEST['gamertag']);?></textarea>
Considering the url is 考虑到网址是
https://live.xbox.com/en-US/Messages?gamertag=gamertag
You can get the value of gamertag like : 你可以获得gamertag的价值:
$gamertag = htmlspecialchars($_GET['gamertag']);
$gamertag = htmlspecialchars($_REQUEST['gamertag']);
To include static content : 要包含静态内容:
<textarea class="compose empty" empty="true">Your Verification Code is : <?php echo htmlspecialchars($_REQUEST['gamertag']);?></textarea>
Your website can't cause a user's browser to pre-populate arbitrary fields on a third party site. 您的网站无法使用户的浏览器预先填充第三方网站上的任意字段。
Presumably Microsoft provide a mechanism to pre-populate the username field for the purposes of "Contact me" links, but not the message since the positive use cases for that are far fewer and it encourages spammy messages. 据推测,微软提供了一种机制来预先填充用户名字段以用于“联系我”链接,但不是消息,因为正面的用例很少,它鼓励垃圾邮件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.