PHP Form gives success message but nothing in db -
this question has answer here:
- how mysqli error in different environments? 1 answer
- reference - error mean in php? 29 answers
i have following php v.5.6.29
<?php // connect database include_once("php_includes/db_connect.php"); error_reporting(e_all); ini_set("display_errors", 1); // gather posted data local variables $m = $_post['mrn']; $l = $_post['lastname']; $f = $_post['firstname']; $s = $_post['ssn']; // user ip address $ip = preg_replace('#[^0-9.]#', '', getenv('remote_addr')); // form data error handling if($m == "" || $l == "" || $f == "" || $s == ""){ echo "the form submission missing data."; } else { // end form data error handling $sql = "insert nys_demographics (mrn, pt_last_name, pt_first_name, pt_ssn, ip_address, record_insert_dtime) values('$m', '$l','$f','$s','$ip',now()"; mysqli_query($db_connect, $sql); echo "insert success"; } header("refresh:3; url=demographics.php"); ?> i success message there nothing in db table. not sure here.
first print success message if insert success boolean returned
if (mysqli_query($db_connect, $sql)) { echo "insert success"; } else { printf("error: %s\n", mysqli_error($db_connect)); }
Comments
Post a Comment