PHP Form gives success message but nothing in db -


this question has answer here:

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

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -