【问题标题】:firing a submit button which is dynamically created in PHP触发在 PHP 中动态创建的提交按钮
【发布时间】:2012-10-02 10:13:34
【问题描述】:

您好,有人可以指出我的方法哪里出错了。在我的代码中,我得到一个名为“sendme”的动态提交按钮,一旦出现,我想在“sendme”被触发后回显一条消息。为此,我包括 if(isset($_POST['sendme'])){...... 代码,但它似乎不是有效的代码。请指出我的理性在这种情况下应该如何改变。感谢您的关注!

    <?php 
if(isset($_POST['sendone'])){

$Q = $_POST['txt5'];
$con=mysql_connect('localhost','root') or die ("Server connection failure!");
$db=mysql_select_db('db_customer',$con) or die ("Couldn't connect the database");
$SQL="SELECT * FROM tbl_customer WHERE name='$Q'";
$run=mysql_query($SQL,$con) or die ("SQL Error");
$row=mysql_fetch_array($run);

if($row=="")
{
echo "No records found";
}
else
{
echo "<table border='1'>";
echo "<tr><td>"."Name :"."</td>";
echo "<td><input type='text' value=".$row['name'].">"."</td>";
echo "<td><input type='submit' id='sendme' name='sendme'></td>";
echo "</tr>";
echo "</table>";
}
}
else {
    // here I'm trying to fire the populated submit button and echo cheers!
if(isset($_POST['sendme'])){
echo 'Cheers!';
}}
?>

【问题讨论】:

    标签: php


    【解决方案1】:

    您不创建表单。在您的&lt;input&gt;s 上方放置&lt;form action="nameofyourphpscript" method="POST"&gt;,在它们下方放置&lt;/form&gt;

    【讨论】:

      猜你喜欢
      • 2021-08-27
      • 1970-01-01
      • 1970-01-01
      • 2015-12-05
      • 2012-04-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多