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

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -