Home  >  Q&A  >  body text

Why is my code never submitted successfully? Please help me. 0_0

Really, I have tried many methods and watched many videos. It is obviously the same code. Why are mine unsuccessful? I don’t know why others are... It’s very annoying. The unsuccessful prompt box does not show an error. Wherever I click, I feel like it’s 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 Move to the text box

myform.username.focus();

return false;

}

if(myform.userpwd.value== ""){

        alert("Please enter your password");

        myform.userpwd.focus();

## if(myform.code.value==""){

alert("Please enter the verification code");

myform.code.focus();

                                                                                                                                                                                                                

.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 the submit button is pressed

if(isset($_POST["hidden"]) && $_POST["hidden"] == "hidden")

{

//Save the username and password into variables for subsequent use

$user = trim($_POST["username"]);//The trim() function removes the characters on both sides of the string Blank characters

$psw = md5(trim($_POST["userpwd"]));//The password is encrypted once with md5() and stored in the database

$code = $_POST[ "code"];

if($user == "" || $psw == "")

{

//One of the username or password If it 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 username and password verification If the code is not empty, 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('Successful login'); window.location.href= 'index.php';</script>";

}

else

{

echo "<script>alert('User The name or password is incorrect! ');history.go(-1);</script>";

}

}

}

else

{

 echo "<script>alert('提交未成功!');</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>

  <!-- 注册界面 register.php-->

  <div class="box" align="center">

  <div>用户注册</div>

<form action="regcheck.php" method="post"> 

<table>

<tr>

<td align="right">用户名:</td>

<td><input type="text" name="username"  maxLength="6"/></td>

</tr>

<tr>

<td align="right">密 码:</td>

<td><input type="password" name="userpwd" maxLength="6"/></td>

</tr>

<tr>

<td align="right">确认密码:</td>

<td><input type="password" name="confirm" maxLength="6"/></td>

</tr>

<tr>

<td colspa="2" align="right"><input type="Submit" name="Submit" value="注册"/></td>

</tr>

</table>

</form>

 </div> 

 </body>

</html>

求大神解决,我觉得再解决不出来,我的头发都要掉光了


﹋南初°﹋南初°2393 days ago1888

reply all(4)I'll reply

  • dsfasdfsafs****dsf

    dsfasdfsafs****dsf2018-04-23 11:24:50

    The code is too long and I can’t read it. I can take a screenshot of the error message or remotely to help you check it

    reply
    0
  • PHP中文网

    PHP中文网2018-04-23 10:04:47

    Please tell me the error message or execution result

    reply
    0
  • ﹋南初°

    I just don’t know what the error message is, so I can’t change it.

    ﹋南初° · 2018-04-23 10:31:00
  • PHP中文网

    PHP中文网2018-04-23 10:04:38

    It’s too long and I can’t read it


    reply
    0
  • Cancelreply