我的密码

<?php
session_start();
require './SIGNUP/connects1010101.php';
require './LOGIN/connects1010101.php';
$srausername = $_SESSION['SRAUSERNAME'];
$srapassword = $_SESSION["SRAPASSWORD"];
if ($srausername && $srapassword) {
    $data0 = mysqli_query($con, "SELECT * FROM `INFO` WHERE `USERNAME` = '$srausername' AND `PASSWORD` = '$srapassword'");
    $data1 = mysqli_fetch_array($data0);
}
?>


我是PHP的初学者。我的问题是我要在mysql中进行帐户注册,但是如何检查帐户是否存在?

最佳答案

请像这样更改您的代码,

<?php
session_start();
require './SIGNUP/connects1010101.php';
require './LOGIN/connects1010101.php';
$srausername = $_SESSION['SRAUSERNAME'];
$srapassword = $_SESSION["SRAPASSWORD"];
if ($srausername && $srapassword) {
    $data0 = mysqli_query($con, "SELECT * FROM `INFO` WHERE `USERNAME` = '$srausername' AND `PASSWORD` = '$srapassword'");
    //$data1 = mysqli_fetch_array($data0);

    if (mysqli_num_rows($data0) > 0) {
        // Account already exists
    }else {
        // No account exists and you can save the details here
    }
}
?>

10-05 18:16