我认为这篇文章可能对其他人来说似乎是一个“离题”的话题。但是,如果您能帮我解决这个问题,将非常感谢。
我在网上找到了一些电子邮件验证码。不知何故,一开始我觉得它很混乱,但是当我开始理解它并将它放在我的代码中时。有一个错误,我不知道如何。
问题:
- 电子邮件验证码。
- 代码的正确语法/使用。
代码:
<?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>";
}
}
}
?>
如果有人帮助我,那就太好了