php - How to prompt if the user is exist in database -


<?php      include('dbcon.php');     $code = $_post['code'];      $result=mysqli_query($dbcon,"insert attendance(firstname,lastname,type,year_level,date_added)select firstname,lastname,type,year_level,current_timestamp() member code='$code'") or die("error ".mysqli_error());     if(isset($_post['submit']))     {           if(!$result) {             echo "database not found.";         } else {             $result;             header('location:add_member_attendance.php');         }     } else {                }   ?> 

i want display prompt if entered data , if user not found in database don't know problem of code. helping me

you can try

<?php   include('dbcon.php');  $code = $_post['code'];       if(isset($_post['submit']))  {    $insert=mysqli_query($dbcon,"select firstname,lastname,type,year_level,current_timestamp() member code='$code'") or die("there error checking due to".mysql_error());    if(mysql_num_rows($insert)>0){  // means code exist;  $result="insert attendance(firstname,lastname,type,year_level,date_added)select firstname,lastname,type,year_level,current_timestamp() member code='$code'";    //check if query run  if(mysqli_query($dbcon,$result)){//or can mysql_query($result)  header('location:add_member_attendance.php');  //you can want here   }else{  echo "the insert query did not run due ".mysql_error();  }  }else{    echo "the code doesnt exist"  }  }  ?>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -