I have this script below that allows me to ad data to a database via a HTML form It works fine (you can use it if you want) But when it works the page just loads as white I need it to either load to a thankyou style html webpage or send out an echo statement confirming it has worked Thanks The script is <?php define ('DB_NAME' , 'demo'); define ('DB_USER' , 'root'); define ('DB_PASSWORD' , ''); define ('DB_HOST' , 'localhost'); $link = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('could not connect: ' . mysql_error ()); } $db_selected =mysql_select_db (DB_NAME, $link); if (!$db_selected) { die('can\'t use ' . DB_NAME . ':' . mysql_error ()); } $value = $_POST['input1']; $value2 = $_POST['input2']; $sql = "INSERT INTO demo1 (input1, input2) VALUES ('$value','$value2')"; if (!mysql_query($sql)) { die('ERROR: ' . mysql_error()); } ?> PHP: anyone know the code and where to put it
Just write it below <?php define ('DB_NAME' , 'demo'); define ('DB_USER' , 'root'); define ('DB_PASSWORD' , ''); define ('DB_HOST' , 'localhost'); $link = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('could not connect: ' . mysql_error ()); } $db_selected =mysql_select_db (DB_NAME, $link); if (!$db_selected) { die('can\'t use ' . DB_NAME . ':' . mysql_error ()); } $value = $_POST['input1']; $value2 = $_POST['input2']; $sql = "INSERT INTO demo1 (input1, input2) VALUES ('$value','$value2')"; if (!mysql_query($sql)) { die('ERROR: ' . mysql_error()); } ?> <p>This is my page in html</p> <p>Thank you for using my form, it has been submitted</p> PHP:
if (!mysql_query($sql)) { die('ERROR: ' . mysql_error()); } else { header("Location: thanks.php"); } ?>