Wednesday, 18 September 2013

PHP Insert Into not Working?

PHP Insert Into not Working?

For some reason the php insert into is not working for me and just goes to
the die.
<form action="user_create.php" method="post">
Forename: <input type="text" name="forename"><br>
Surname: <input type="text" name="surname"><br>
Username: <input type="text" name="username"><br>
Password: <input type="text" name="password"><br>
Email: <input type="text" name="email"><br>
<input type="submit" value="Create User"><br>
</form>
And here is my php code:
$forename = $_POST['forename'];
$surname = $_POST['surname'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$insert = "INSERT INTO users (id, forename, surname, username, password,
email)
VALUES(
''
,$forename
,$surname
,$username
,$password
,$email)";
echo("$forename");
echo("$surname");
echo("$username");
echo("$password");
echo("$email");
mysqli_query($con, $insert) or die ('Error');
mysqli_close($con);
?>
For some reason the code does not complete the mysqli_query, it runs the
die code.

No comments:

Post a Comment