我已经为登录和注册页面编写了此PHP代码,但是,我不知道它看起来不合逻辑,但是它不接受某些电子邮件,而接受其他电子邮件。我不知道这怎么可能。我不认为我使用的是apache服务器,因为它不会接受它接受的其他邮件,我也尝试过重新启动服务器,尝试使用其他浏览器,我尝试了所有尝试。请帮忙。
<?php
session_start();
require_once "connect.php"
$con=@new mysqli($hn,$un,$pw,$db);
if($con->connect_error) die("Failed to connect to the database");
if (isset($_POST['register']))
{
$nam=$_POST['name'];
$sur=$_POST['sur'];
$email=$_POST['email'];
$pass=$_POST['pass'];
$cpass=$_POST['cpass'];
if ($nam!="" && $sur!="" && $email!="" && $pass!="" && $cpass!="")
{
if ($pass==$cpass)
{
$userinfo=sanitise($nam,$sur,$email,$pass);
if (validate($userinfo[0],$userinfo[1],$userinfo[2],$userinfo[3]))
{
if(dataentry($userinfo[0],$userinfo[1],$userinfo[2],$userinfo[3]))
{
echo "Account Create Successfully";
}
else
{
echo "Failed to Create the account, Please try again After Some Time";
}
}
}
else
{
echo "The Entered Password do not Match";
}
}
else
{
echo "Please fill all the fields";
}
}
if (isset($_POST['login']))
{
$id=$_POST['email'];
$pin=$_POST['lpass'];
$id=ucfirst(strtolower(stripslashes(strip_tags(htmlentities($id)))));
$pin=stripcslashes(strip_tags(htmlentities($pin)));
$pin=hash('ripemd128', $pin);
if (isuser($id))
{
if (verify($id,$pin))
{
$_SESSION['email']=$id;
header("Location:homepage.php");
}
else
{
echo "The Password And Email Do not Match";
}
}
else
{
echo "The Email Id is Not Registered";
}
}
function verify($email,$pass)
{
global $con;
$query="SELECT * FROM users WHERE email='$email' AND password='$pass'";
$result=$con->query($query);
$rows=$result->num_rows;
if ($rows==1)
{
return 1;
}
else
{
return 0;
}
}
function isuser($email)
{
global $con;
$query="SELECT * FROM users WHERE Email='$email'";
$result=$con->query($query);
$rows=$result->num_rows;
if ($rows==1)
{
return 1;
}
else
{
return 0;
}
}
function sanitise($name,$surname,$email,$password)
{
$name=ucfirst(strtolower(stripslashes(strip_tags(htmlentities($name)))));
$surname=ucfirst(strtolower(stripslashes(strip_tags(htmlentities($surname)))));
$email=ucfirst(strtolower(stripslashes(strip_tags(htmlentities($email)))));
$password=stripcslashes(strip_tags(htmlentities($password)));
$password=hash('ripemd128',$password);
return array($name,$surname,$email,$password);
}
function validate($name,$surname,$email,$password)
{
global $con;
$query="SELECT * FROM users WHERE email='$email'";
$result=$con->query($query);
$rows=$result->num_rows;
if ($rows==0)
{
return 1;
}
else
{
echo "Email Address is already in use";
}
}
function dataentry($name,$surname,$email,$password)
{
global $con;
$query="INSERT INTO users (Name,Surname,Email,Password) VALUES ('$name','$surname','$email','$password')";
$result=$con->query($query);
if ($result)
{
return 1;
}
else
{
return 0;
}
}
?>
答案 0 :(得分:-1)
嘿,没有理由让某些电子邮件ID被接受,而有些则没有,请尝试重新启动可能有用的Apache服务器。 另外,请阅读有关SQL注入的更多信息,我知道您必须在本地工作并且不能部署它,但是仍然很了解它。和平