javascript - MySQLi If condition alert msg not showing the output -


below given code working perfect. db table values inserted. echo message not showing in output

<?php  define('db_server', 'localhost'); define('db_username', 'root'); define('db_password', ''); define('db_database', 'admin'); $db = mysqli_connect(db_server,db_username,db_password,db_database); if(isset($_post["register"])) {     $id = $_post["id"];     $name = $_post["user_name"];     $password = $_post["password"];     $query = mysqli_query($db, "insert user (id, user_name, password)values ('$id', '$name', '$password')");     $result = mysqli_query($query);   if($result) {     echo "thank you! registered."; } } 

?>

you called mysqli_query 2 times , second time in wrong way, need call once instead

// change $query = mysqli_query($db, "insert user (id, user_name, password)values ('$id', '$name', '$password')"); $result = mysqli_query($query);  // $result = mysqli_query($db, "insert user (id, user_name, password) values ('$id', '$name', '$password')");  // , change condition  if( mysqli_affected_rows($db) ){  .. } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -