I simply start coding in PHP, i authored my first php + mysql program for placing data through web form. it really works fine, but whenever i refresh the page, it instantly saves null record to my database. i understand the answer insInternet is ispostback, although not in php? can somebody produce an idea in PHP.

Code is here now:

<form action="mySQLTest.php" method="post">
First Name :<input type="text" name ="txtFirstName"/> <br/>
Last Name: <input type="text" name ="txtLastName"/>   <br/>
Age : <input type="text" name= "txtAge" /> <br/>
<input type="submit"/>
   $con = mysql_connect("localhost","root","");
    die('Could not Connect:' .mysql_error());

   mysql_select_db("test", $con);


   $sql1 = "Insert into info(FirstName, LastName, Age) Values('$_POST[txtFirstName]','$_POST[txtLastName]','$_POST[txtAge]')";
   if(!mysql_query($sql1, $con))
    die('Error: '.mysql_error());
   echo "1 Record Added";


Perhaps you have attempted if ($_SERVER['REQUEST_METHOD']=='POST')

up-to-date answer:

header('Location: added_record.php');

If you use the Publish-method, it's better (imho) to make use of $_Publish instead of $_REQUEST. To check on whether you've data, you could utilize isset($_POST['txtFirstName']);. If you want all data, it is best to do that for those input fields, leading to

if(isset($_POST['txtFirstName']) && isset($_POST['txtLastName']) && isset($_POST['txtAge'])) {
    // do stuff

If you wish to determine if there is any area posted using publish, you could utilize if(!empty($_POST)) {.

On the side note: I understand you're just beginning PHP, it may be quite harmful to make use of user-produced code in queries. When you're building stuff online, for everybody to achieve, please read a little about SQL injection. This can also stop your code from breaking when someone makes its way into an apostrophe (').