I have written a simple php coding for getting the name , phone number and insert the values into data base. My problem is that when ever I just click the refresh button in the browser window, it will automatically previous inserted values are once again inserted into databse as a new entry.
Please anybody give the perfect coding which will avoid automatic insertion of previous values into database.....
I attched my coding below........
Expand|Select|Wrap|Line Numbers
- <form id="form1" name="form1" method="post" action="index.php">
- Name:<input name="name" type="text" /><br />
- Phone Number:<input name="pnumber" type="text" /><br />
- <input type="submit" name="submit" value="submit" />
- </form>
- <?
- $submit=addslashes($_POST['submit']);
- if(isset($submit))
- {
- $name=addslashes($_POST['name']);
- $pnumber=addslashes($_POST['pnumber']);
- $sql="insert into details(phone,name) values ('$pnumber','$name')";
- mysql_query($sql) or die('Could not Connect the database'.mysql_error());
- echo"<script language=javascript>alert('Your details are stored successfully');</script>";
- }
- ?>
thanks....