mysql - PHP adding only a new record to a SQL database -


i need new data database table. trying query database , add new data. lost in sql , php.

i have got code entering database on refresh enter same data again , want allow new data:

<?php  // data base connection   define ('db_users', 'root'); define ('db_pass', 'root'); define ('db_host', 'localhost'); define ('db_name', 'sam_api');  $dbc = @mysqli_connect (db_host, db_users, db_pass, db_name) or die ('could not connect' . mysqli_connect_error());   $user_update = $items['id'];    // check if file exists   $query = mysqli_query($con, "select * updates $user_update ='".$items['id']."'");  if(mysqli_num_rows($query) > 0){      echo "email exists"; }else{     //     if (!mysqli_query($con,$query))     {         die('error: ' . mysqli_error($con));     } }   // inserting data form previous page in database  $q = "insert updates (user_update) values ('$user_update')"; $r = @mysqli_query ($dbc,$q);    // telling if has been uploaded or not  if($r){     echo "you have inserted"; } else{     echo "this did not work"; }   ?> 

remove $ user_update, because want compare field's value, not value itself.

 $query = mysqli_query($con, "select * updates user_update ='".$items['id']."'"); 

Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -