[英]Submit button with php variable
<form method="post">
<input type="submit" name="'.$pTest.'" value="submit" id="submit"/>
</form>
<?php
if(isset($_POST[''.$pTest.'']))
{echo 'something'
;}
?>
This doesn't work if I use variable as the name of the submit button.如果我使用变量作为提交按钮的名称,这将不起作用。 Please some help!
请一些帮助!
像这样尝试
<input type="submit" name="<?php echo $pTest; ?>" value="submit" id="submit"/>
Your variable is doing nothing.你的变量什么都不做。 Just
echo
your <input>
name and catch it whith php:只需
echo
您的<input>
名称并用 php 捕获它:
<form method="post">
<input type="submit" name="<?php echo $pTest ?>" value="submit" id="submit"/>
</form>
<?php
if (isset($_POST[$pTest])) {
echo 'something'
}
?>
Add value to the variable first..首先将值添加到变量..
<?php $pTest = 'sks'; ?>
<form method="post">
<input type="submit" method="post" name="<?php echo $pTest; ?>" value="submit" id="submit"/>
</form>
<?php
if(isset($_POST[$pTest]))
{
echo '<script>alert("something");</script>';
}
?>
Just replace your quotes with double quotes :只需用双引号替换您的引号:
if(isset($_POST["'.$pTest.'"]))
{
echo 'something'
;}
Or name your input with a PHP variable :或者使用 PHP 变量命名您的输入:
<input type="submit" name="<?php echo $pTest; ?>" value="submit" id="submit"/>
anybody who solve this question?有人解决这个问题吗? please I need help!
请我需要帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.