触发在PHP中动态创建的提交按钮

时间:2012-10-02 10:13:35

标签: php

嗨,有人可以指出我的方法出错了。在我的代码中,我动态地获得一个名为'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!';
}}
?>

1 个答案:

答案 0 :(得分:1)

您不创建表单。将<form action="nameofyourphpscript" method="POST">置于<input>之上,</form>置于其下方。