Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 995b682

Browse files
添加php加密之md5()函数
1 parent b03fc0c commit 995b682

File tree

2 files changed

+43
-53
lines changed

2 files changed

+43
-53
lines changed

‎.idea/workspace.xml‎

Lines changed: 34 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎php-encrypt/register_ok.php‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,27 @@ class ChkInput{ //定义chkinput 类
1111
var $name; //定义成员变量
1212
var $pwd;
1313

14-
// function chk_input($x,$y){ //定义成员方法
15-
// $this->name = $x;
16-
// $this->pwd = $y;
17-
// echo $x.'<br>',$y;
18-
// }
1914
function checkipput($name,$pwd){ // 定义方法,完成用户注册
2015
$this->name = $name;
2116
$this->pwd = $pwd;
2217
echo $name.'<br>'.$pwd;
23-
// include "conn.php"; //通过include 调用数据库连接文件
2418
$conn = mysqli_connect("localhost","root","");
2519
mysqli_select_db($conn,'test11') or die ('数据库访问错误'.mysqli_errno($conn));
20+
mysqli_query($conn,"SET AUTOCOMMIT=1");
2621
mysqli_query($conn,"set names utf8_general_ci");
27-
// 执行查询
28-
// mysqli_query($conn,"SELECT * FROM tb_user");
29-
// $info = mysqli_query($conn,"insert into tb_user('user','password')values ($name,$pwd)");
30-
$info = mysqli_query($conn,"INSERT INTO tb_user (id,user,password) VALUES ('3',$name,$pwd)");
31-
if($info == false){ //如果添加操作的返回结果,给出提示信息
22+
$info = "INSERT INTO tb_user (user,password) VALUES ('$name','$pwd')";
23+
if(mysqli_query($conn,$info)){ //如果添加操作的返回结果,给出提示信息
24+
$_SESSION['admin_name'] = $name; //注册成功后,将用户名赋给SESSION变量
3225
mysqli_close($conn);
33-
echo "<script>alert('会员注册失败!');history.back()</script>";
26+
echo "<script>alert('恭喜您,注册成功!');window.location.href='index.php'</script>";
27+
3428
}else {
35-
$_SESSION['admin_name'] = $this->name; //注册成功后,将用户名赋给SESSION变量
29+
echo"<script>alert('会员注册失败!');history.back()</script>";
3630
mysqli_close($conn);
37-
echo"<script>alert('恭喜您,注册成功!');window.location.href='index.php'</script>";
31+
3832
}
3933
}
4034

4135
}
4236
$obj = new ChkInput(); //实例化类
43-
//$obj->chk_input(trim($_POST['username']),trim(md5($_POST['password'])));
44-
$obj ->checkipput(trim($_POST['username']),trim($_POST['password']));//返回对象调用方法执行注册操作
37+
$obj ->checkipput(trim($_POST['username']),trim(md5($_POST['password'])));//返回对象调用方法执行注册操作

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /