我试图从表单中的 value="" 获取文本到 php 变量 $_POST['twitter'] 但我一直得到一个空白,如果我删除 isset,我会收到一个未定义的错误。
<?php
//$twitter=(isset($_POST['twitter']));
var_dump($_POST);
?>
<form method="post" action="">
<input type="checkbox" name="twitter" value="My Posting Text">Would you like to send to Twitter?<br>
</form>
<div id="custom-tweet-button">
<a href="https://twitter.com/share?" id="my_twitter_id" data-show-screen-name="false" data-url="https://nyctelecomm.com" data-text="<?php echo $_POST['twitter']; ?>" data-counturl="null" class="twitter-share-button" target="_blank" data-count="horizontal" data-lang="en" data-via="NYCTelecomm.com">Tweet</a>
</div>
<script language="javascript" type='text/javascript'>
!function (d, s, id)
{
var js, fjs = d.getElementsByTagName(s)[0];
if (!d.getElementById(id))
{
js = d.createElement(s);
js.id = id;
js.src = "//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
}
}
(document, "script", "twitter-wjs");
</script>