I've created a html form
<form action="http://localhost/php/insert.php" method="post">
Barcode: <input type="text" name="barcode" /><br><br>
Serial: <input type="text" name="serial" /><br><br>
<input type="submit" />
</form>
which saves into my database using this php:
<?php
$con = mysql_connect("example","example","");
if ( ! $con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
$sql = "INSERT INTO asset (barcode, serial)
VALUES ('$_POST[barcode]','$_POST[serial]')";
if ( ! mysql_query($sql, $con)) {
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
the form saves to the DB but the page just goes to http://localhost/php/insert.php
when you press submit, which is a blank page. how can I make it stay on the same page and just show a message or something?