Hello guys,
its been some time now i have been strugling with this error,
evertime i submit my form it give me this error "Column count doesn't match value count at row 1
" and i cant find a way around this. Any help would be very appreciated!!!
<?php
if($_POST['phpfunction'] == 'createUser') {
createUser();
}
if($_GET['phpfunction'] == 'verifyUser') {
verifyUser();
}
function createUser() {
$FirstName = $_POST['firstName'];
$LastName = $_POST['lastName'];
$AddressLine1 = $_POST['addressLine1'];
$AddressLine2 = $_POST['addressLine2'];
$PostCode = $_POST['postCode'];
$City = $_POST['city'];
$Email = $_POST['email'];
$Password = $_POST['passWord'];
$verificationCode = substr(md5(uniqid(rand(),true)), 16,16);
include "../include/config.php";
$sql = "SELECT * FROM `User` WHERE Email='$Email'";
$query = mysqli_query($connection, $sql);
if (mysqli_num_rows($query) >0){
echo "This email.is already registered.";
return;
}
$sql = "INSERT INTO `User`".
" values ".
"('$FirstName', '$LastName', '$AddressLine1', '$AddressLine2', '$PostCode', '$City', '$Email', '$Password', NOW(), '$verificationCode', '0' )";
if(mysqli_query($connection, $sql)) {
echo "True";
} else {
echo mysqli_error($connection);
}
sendEmail($Email, $verificationCode);
mysqli_close($connection);
}
function verifyUser() {
$Email = $_GET['$email'];
$verificationcode = $_GET['$VerificationCode'];
include "../include/config.php";
$sql = "UPDATE `User` ".
"SET IsVerified='1'".
" WHERE email = '$Email' AND verificationcode='$verificationcode'";
if(mysqli_query($connection, $sql)){
echo "Your account has been successfully verified.";
}else{
echo mysqli_error($connection);
}
}
function sendEmail($emailTo, $verificationcode) {
$from="username@glos.ac.uk";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//Create email headers
$headers .= 'From: '.$from. "\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
// Compose the message of the email
$body = 'Thank you for registering with Flogger. <br>';
$body = $body.'Please click the link below to activate your account. <br>';
$link = 'http://aalam.studentsites.glos.ac.uk/CT4009Sem2Week4/RegistrationPage/RegistrationDAO.php?'.
'phpfunction=verifyUser&email='.$emailTo.
'&VerificationCode='.$verificationcode;
$link = '<a href="'.$link.'">Click here</a>';
$body = $body.$link;
$message = '<html><body>';
$message .= $body;
$message .= '</body></html>';
if (mail($emailTo, $subject, $message, $headers)){
//Do Something
} else {
//Do Something
}
}
?>
Anthony_22 0 Newbie Poster
urtrivedi 276 Nearly a Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.