Reputation: 43
Hi can someone point out where my method has gone wrong. In my code I get a submit button dynamically with the name 'sendme' and once that appears I want to echo a message once the 'sendme' is fired. for that I include if(isset($_POST['sendme'])){...... code but as it seems its not valid code. Please point out how my rational should changed in this scenario. Thank you for looking!
<?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!';
}}
?>
Upvotes: 0
Views: 555
Reputation: 9642
You don't create a form. Put a <form action="nameofyourphpscript" method="POST">
above your <input>
s, and </form>
below them.
Upvotes: 1