I think this post may appear to be as an "off" topic to others. But it'll be a great thank if you help me out with this.
I found some email verification code on the web. Somehow, I find it confusing at first but when I began to understand it and put it on my code. There's a error and I don't know how.
Problems:
- The email verification code.
- Proper syntax/use of the code.
Code:
<?php
if(isset($_POST['submit']))
{
$a = $_POST['username'];
$b = $_POST['password'];
$c = $_POST['firstname'];
$d = $_POST['lastname'];
$e = $_POST['month'];
$f = $_POST['day'];
$g = $_POST['year'];
$h = $_POST['contact'];
$i = $_POST['email'];
$j = $_POST['confirm'];
$code = md5(uniqid(rand()));
include("dbconnect.php");
$query = "SELECT * FROM `users`.`info` WHERE `username`='".$a."' AND `email_address`='".$i."'";
$queryQuery=$con->query($query);
$checker = mysqli_num_rows($queryQuery);
if (($a && $b && $c && $d && $h && $i && $j) == "")
{
print "<script type=text/javascript>
alert('All fields are required');
</script>";
}
else
{
if ($checker == 0 && $b != $j)
{
print "<script type=text/javascript>
alert('Password Mismatch');
</script>";
}
else if($checker == 0)
{
//print $a,$b,$c,$d,$e,$f,$g,$h,$i;
$insertQuery="INSERT INTO `users`.`info` (`username`,`password`,`firstname`,`lastname`,`month`,`day`,`year`,`contact_number`,`email_address`,`confirm_code`) VALUES ('$a','$b','$c','$d','$e','$f','$g','$h','$i','$code')";
$insertQueryResult=$con->query($insertQuery);
if ($insertQueryResult)
{
// send e-mail to ...
$to=$i;
// Your subject
$subject="Your confirmation link here";
// From
$header="From Admins of Publisita.com";
// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.gmail.com/confirmation.php?passkey=$code";
// send email
$sentmail = mail($to,$subject,$message,$header);
}
// if not found
else
{
print "<script type=text/javascript>
alert('Not found your email in our database')
</script>";
}
// if your email succesfully sent
if($sentmail)
{
print "<scrpit type=text/javascript>
alert('Your Confirmation link Has Been Sent To Your Email Address')
</script>";
}
else
{
print "<script type=text/javascript>
alert('Cannot send Confirmation link to your e-mail address')
</script>";
}
}
print "<script type=text/javascript>
alert('Successfully Registered');
</script>";
}
else
{
print "<script type=text/javascript>
alert('Information are already been used');
</script>";
}
}
}
?>
It'll be a great thing if someone helped me out