0
<?php
$con = mysql_connect("localhost","root","12345");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  echo "connection made";
    if(isset($_POST['nw_update'])){
        echo("You clicked nw_update!");
    }
    else {
    echo" dhur";
    }
?>

 <html>
 <body>
    <form action="<?php echo $_SERVER(PHP_SELF); ?>" method="POST"    >
        <input type="button" id="nw_update" value="NW_Update"/>
    </form>
</body>
</html>

In the above code when the button is clicked i want the echo("You clicked nw_update!"); to be executed. PLease could you help out.

Edited by debal: modify

5
Contributors
5
Replies
12
Views
5 Years
Discussion Span
Last Post by simplypixie
0

the else part is automatically printed the connection part is ok.. i have already tested that

0

Why not execute SQL on $_POST instead?

if ($_POST)
{
    //Connection to DB
    //Execute Query
}
0

@Javvy good idea! Or you could have an hidden attribute inside your form:

<input type="hidden" name="submitted" value="TRUE">

Making sure it's after your submit button and then inside PHP:

<?php
  if(isset($_POST['submitted']))
  {
      // SQL
      // SQL
  }
0

Your button should be a submit instead as what you have won't submit your form or post your data.
<input type="submit" id="nw_update" value="NW_Update"/>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.