Really wo'shi, I have tried many methods and watched many videos. It is obviously the same code. Why are mine unsuccessful? I don't know other people's... It's very annoying. The unsuccessful prompt box is also missing. The error point is not displayed, and it feels like it is going to crash. 0_0
login.php:
<!DOCTYPE>
<html>
< ;head>
<meta charset="utf-8">
<title>Login</title>
<script>
function init(){
if(myform.username.value==""){
alert("Please enter the username");
/ /Move the cursor to the text box
myform.username.focus ();
Return false;
##} if (myForm.userpwd. Value == "") {# Alert ("Please enter the password");## myform.userpwd.focus ()
Return false;
This # }
if(myform.code.value==""){
alert("Please enter the verification code");
myform.code.focus() ;
return false; ">
.code{
width: 80px;
}
.title{
font-size: 20px;
font-weight: bold;
position: relative;
left: 50px;
}
.bd{
background-color:#f0f0f0;
width: 230px;
}
</style>
</head>
<body>
<form action="logincheck.php" method="post" name="myform">
<div>
<div>User login</div>
</div>
<div>
<span>Username:< ;/span>
<span><input type="text" name="username" id="username" placeholder="Please enter username"></span>
</div>
" id="userpwd" placeholder="Please enter your password"></span>
</div>
<div>
" <span> ;Verification code: </span>
<span><input type="text" name="code" id="code" class
="code" placeholder= "Please enter the verification code"></span>
<!-- <span><img src="img.php" onclick="this.src='pic.php? nocache=' Math.random()" style="cursor:pointer"></span> -->
<span><img src="img.php">< ;/span>
</div>
<div>
<span><button>Log in now</button></span> ;
<span><a href="register.php">Register</a></span>
</div>
<span><input type="hidden" value="hidden"></span>
</form>
< /body>
</html>
regcheck.php
<?php
header("content-Type: text/html; charset=Utf-8");
session_start();
//Registration processing page regcheck.php
if (isset($_POST["hidden"]) &&$_POST["hidden"]=="hidden") {
$user=trim($_POST["username"]);//Use the trim function to remove whitespace characters on both sides of the string
$pwd=md5(trim($_POST["userpwd"]));
$pwd_confirm=md5(trim($_POST["confirm"]));
$code=$_POST["code"];
if($user==""||$pwd==""||$pwd_confirm==""){
// echo "<script>alert("Please confirm the integrity of the information"):history.go(-1);</script>";
}elseif ($code!=$_SESSION[ "var_code"]) {
// echo "<script>alert("Verification code is incorrect"):history.go(-1);</script>";
}else{
if ($pwd==$pwd_confirm) {
$conn=mysql_connect("localhost","root","a123456");//Account to connect to the database Password
if (mysqli_errno($conn)) {
echo mysqli_errno($conn);
exit;
}
mysqli_select_db($conn,"userdb");//Select database
mysqli_set_charset($conn,"utf8");//Set character set
// $sql="select username from USER where username='$user'";//sql statement
$sql = "SELECT * FROM `user` PROCEDURE ANALYSE()";
// mysql_query(query)
$result=mysqli_query($conn,$sql);//Execute SQL statements
$num = mysqli_num_rows($result); //Count the number of rows affected by the execution results
if($num) //If the user already exists
{
echo "<script>alert('Username already exists'); history .go(-1);</script>";
}
else //The current registered user name does not exist
{
$ ip=ip2long($_SERVER['REMOTE_ADDR']); // Convert ip address to integer
$time=time();
$sql_insert = "insert into `user` (`username`,`userpwd`,`createtime`,`createip`) values('" . $user . "','" . $psw ."','".$time."','".$ ip."')";
//$sql = "SELECT * FROM `user` PROCEDURE ANALYSE()";
$res_insert = mysqli_query($conn,$sql_insert);
if($res_insert)
{
echo "<script>alert('Registration successful! ');window.location.href='login.php';</script>";
}
else
{
echo "<script>alert('The system is busy, please wait!'); history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('Passwords are inconsistent!'); history.go(-1) ;</script>";
}
}
}
else
{
/ / echo "<script>alert('Submission failed!');</script>";
echo "<script>alert('weichenggong');</script>";
}
?>
logincheck.php
<?php
header("content-Type: text/ html; charset=Utf-8");
session_start();
//Login processing interface logincheck.php
//Determine whether to press the submit button
if(isset($_POST["hidden"]) && $_POST["hidden"] == "hidden")
{
//Save the username and password into the variable for subsequent use
$user = trim($_POST["username"]);//trim() function removes whitespace characters on both sides of the string
$psw = md5(trim($_POST["userpwd"]));//The password is encrypted once with md5() and stored in the database
$code = $_POST["code"];
if($user == "" || $psw == "")
{
//If one of the username or password is empty, a dialog box will pop up. After confirmation Return to the previous page of the current page
echo "<script>alert('Please enter your username or password!'); history.go(-1);</script>";
}else if($code != $_SESSION[' ver_code']){
echo "<script>alert('The verification code is incorrect, please re-enter! '); history.go(-1);</script>";
}
else
{ //Confirm that the username and password verification code is not empty , then connect to the database
$conn = mysqli_connect("localhost","root","a123456");//The database account password is set when installing the database
if(mysqli_errno($conn )){
echo mysqli_errno($conn);
exit;
}
mysqli_select_db($conn,"userdb");
mysqli_set_charset($conn,'utf8');
$sql = "select username,userpwd from user where username = '$user' and userpwd = '$psw'";
//$sql = "SELECT * FROM `user` PROCEDURE ANALYSE()";
$result = mysqli_query($conn,$sql);
$num = mysqli_num_rows($result );
if($num)
{
echo "<script>alert('Successfully logged in'); window.location.href='index.php ';</script>";
}
else
{
echo "<script>alert('Username or password is incorrect!');history.go(-1);</script>";
}
}
}
else
{
echo "<script>alert('Submission failed!');</script>" ;
}
?>
register.php
<!DOCTYPE html>
<html>
<head>
<title>php.cn</title>
<meta charset="utf-8" />
<style>
.box{
width:250px;
height:120px;
background:#f0f0f0;
}
</style>
</head>
<body>
<!-- Registration interface register.php-->
<div class="box" align="center">
<div>User registration</div>
<form action="regcheck.php" method="post">
<table>
<tr>
<td align ="right">Username:</td>
<td><input type="text" name="username" maxLength="6"/></td>
</tr>
<tr>
<td align="right">Password: </td>
<td><input type="password" name="userpwd" maxLength="6"/></td>
</tr>
<tr> ;
<td align="right">Confirm password:</td>
<td><input type="password" name="confirm" maxLength= "6"/></td>
</tr>
<tr>
<td colspa="2" align="right "><input type="Submit" name="Submit" value="Register"/></td>
</tr>
</table> ;
</form>
</div>
</body>
</html>
Please God solve it, I think if I can’t solve it, all my hair will fall out
好好学PHP。