Below is the section of my code which is causing me problems:
$usertype = $_POST['usertype'];
if ($usertype == "Administration") {
?>
<script type='text/javascript'>
window.onload = promptMessage;
function promptMessage() {
var x = 38773;
var code = prompt('Enter the administration code you have been given:', 'Enter code here');
if (code == x) {
alert("Administration code accepted");
} else {
var secondcode = prompt('The code you have entered is inccorect', 'Enter correct code here or change Usertype');
if (secondcode == x) {
alert("Administration code accepted");
} else {
location.href = 'AdminCodeFail.html';
}
}
}
</script>
<?php
$con = mysqli_connect("localhost:3306", "root", "***********", "systemone");
$sql = "INSERT INTO completeinfo (FirstName, Surname, UniID,
HouseNumber, AddressLineOne, AddressLineTwo, City,
PostCode, County, PhoneNumber, Email, Username,
Password, UserType)
VALUES
('$_POST[firstname]','$_POST[surname]','$_POST[uniid]',
'$_POST[housenumber]','$_POST[addresslineone]',
'$_POST[addresslinetwo]','$_POST[city]','$_POST[postcode]',
'$_POST[county]','$_POST[contactnumber]','$_POST[email]',
'$_POST[username]','$_POST[password]','$_POST[usertype]')";
if (!mysqli_query($con, $sql)) {
die('Error: ' . mysqli_error($con));
} else {
header("Location:SignUpComplete.html");
}
The problem I'm having is that the insert query is just not working. The query fails to insert any data into the database and I am at a loss as to why. The connection to the database is working fine and I'm receiving no errors when testing the query itself. So why isn't the query functioning?