I have a database called message, with a table called user in it. The table, 'user' has five columns, user_id which is the primary key and auto increments. Then is the first name last name username and password. But when i press the submit button, it shows me error connecting. Cannot find the error!
What could it be?
<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<title> Create Account
</title>
</head>
<body>
<?php
$dbc=mysqli_connect('localhost', 'root', '', 'message') or die("Error");
if(isset($_POST['submit']))
{
if($_POST['password']==$_POST['repassword'])
{
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$username=$_POST['username'];
$password=$_POST['password'];
$password_hash=sha1($password);
$query="INSERT INTO user (fname, lname, username, password)"."VALUES('$fname', '$lname', '$username', '$password_hash')";
$result=mysqli_query($dbc, $query) or die("Error Connecting");
echo "Account Created!";
mysqli_close($dbc);
}
else
{
echo "Passwords do not match";
}
}
?>
userviamysqli_select_db? I couldn't see it ya!mysqli_query()fails you should report it as "Query failed" or "Couldn't create account". It should never state "Error Connecting", because at that point in time you're either connected already or it failed above ("Errror").