search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

6 answers
Q&A This question is a bit strange? It seems that the time and IP cannot be obtained

0

/*$sql = "insert into kui3(username,password,createtime,createip)values('$username','$password',222,3333)";*/

Use the above code to change the underlined part, and you can successfully write


##$sql = "insert into kui3(username,password,createtime ,createip) values('" . $username . "','" . $password . "','" . $time . "','" . $ip . "')";

Use The code in the course, that is, the code above, always fails to write. I don’t know what the problem is?

Your Answer
submit

6 answers
1

Success code:

The table statement is as follows:

CREATE TABLE `kui3` (

`id` int(32) NOT NULL AUTO_INCREMENT ,

`username` varchar(30) DEFAULT NULL,

`password` varchar(32) DEFAULT NULL,

`createtime` int(80) DEFAULT NULL,

`createip` varchar(60) DEFAULT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 |


The complete code of the connect.php file is as follows:

##<?php

if (trim ($_POST['password']) != trim($_POST['repassword'])) {

exit('The two passwords are inconsistent, please return to the previous page');

}

$username = trim($_POST['username']);

$password = md5(trim($_POST['password']));

$time = time();

$ip = $_SERVER["REMOTE_ADDR"];

$conn = mysqli_connect('localhost', 'root', 'root');

//If there is an error, there is an error number

if (mysqli_errno($conn)) {

echo mysqli_error($conn);

exit;

}

mysqli_select_db($conn, 'kui');

mysqli_set_charset($conn, 'utf8');

$sql = "insert into kui3(username,password,createtime,createip) values('" . $username . "','" . $password . "','" . $time . "','" . $ip . "')" ;

$result = mysqli_query($conn, $sql);

if ($result) {

echo 'Success';

} else {

echo 'Failed';

}

echo 'The ID inserted by the current user is' . mysqli_insert_id($conn);

mysqli_close($ conn);

?>

2018-02-05 23:20:45

submit

1

CREATE TABLE IF NOT EXISTS user (

id int(11) NOT NULL,

username varchar(30) NOT NULL,

password char( 32) NOT NULL,

createtime int(11) NOT NULL,

createip int(11) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8;


There are two questions here:

The first one should be, password varchar(32) not null;

The second and last createip type should be set to string,


The transfer is OK after modification


The ID inserted successfully by the current user is 13


2018-02-05 23:14:22

submit

0

String concatenation of SQL statements is incorrect

2018-02-06 12:25:47

submit

0

Do we need to create a table in the database first? That is to say, the table statement must be executed first before the connection can be successful:

CREATE TABLE `kui3` (

`id` int(32) NOT NULL AUTO_INCREMENT,

`username` varchar(30) DEFAULT NULL,

`password` varchar(32) DEFAULT NULL,

`createtime` int(80) DEFAULT NULL,

`createip` varchar( 60) DEFAULT NULL,

PRIMARY KEY (`id`)

) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 |

Yes?

2018-02-08 20:44:59

submit

0

`createtime` int(80) DEFAULT NULL, isn’t this int(80) a bit scary? And you can use the date type of the database

2018-02-09 14:32:29

submit

0

Then when inserting, enclose the time in quotation marks, because the time is stored in the form of a string, both $time and ip in your question should be enclosed in parentheses

2018-02-09 14:33:59

submit

Popular tool

vc9-vc14 (32+64 bit) runtime library collection (link below)

vc9-vc14 (32+64 bit) runtime library collection (link below)

Download the collection of runtime libraries required for phpStudy installation

VC9 32-bit

VC9 32-bit

VC9 32-bit phpstudy integrated installation environment runtime library

PHP programmer toolbox full version

PHP programmer toolbox full version

Programmer Toolbox v1.0 PHP Integrated Environment

VC11 32-bit

VC11 32-bit

VC11 32-bit phpstudy integrated installation environment runtime library

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use