首页 » PHP教程 » php实现登录窗口技巧_运用PHP实现用户登录和注册的功能

php实现登录窗口技巧_运用PHP实现用户登录和注册的功能

duote123 2024-12-08 0

扫一扫用手机浏览

文章目录 [+]

利用PHP实现用户登录和注册的功能,相信很多同学都可以写的出来用PHP实现登录的功能了,给一些刚入门的PHP程序员,给你们指路了。

上岸界面 login.php

php实现登录窗口技巧_运用PHP实现用户登录和注册的功能

<form action=\公众logincheck.php\公众 method=\公众post\"大众>

php实现登录窗口技巧_运用PHP实现用户登录和注册的功能
(图片来自网络侵删)

用户名:<input type=\"大众text\"大众 name=\公众username\公众 />

<br />

密码:<input type=\"大众password\公众 name=\"大众password\"大众 />

<br />

<input type=\"大众submit\"大众 name=\"大众submit\"大众 value=\公众上岸\"大众 />

<a href=\"大众register.php\"大众>注册</a>

</form>

登录处理界面 logincheck.php

<?php

if(isset($_POST[\公众submit\"大众]) && $_POST[\"大众submit\"大众] == \"大众上岸\公众)

{

$user = $_POST[\"大众username\公众];

$psw = $_POST[\"大众password\公众];

if($user == \"大众\"大众 || $psw == \"大众\公众)

{

echo \"大众<script>alert('请输入用户名或密码!
'); history.go(-1);</script>\"大众;

}

else

{

mysql_connect(\"大众localhost\公众,\"大众root\"大众,\公众sixx\公众);

mysql_select_db(\"大众vt\公众);

mysql_query(\"大众set names 'gbk'\"大众);

$sql = \"大众select username,password from user where username = '$_POST[username]' and password = '$_POST[password]'\公众;

$result = mysql_query($sql);

$num = mysql_num_rows($result);

if($num)

{

$row = mysql_fetch_array($result); //将数据以索引办法储存在数组中

echo $row[0];

}

else

{

echo \"大众<script>alert('用户名或密码禁绝确!
');history.go(-1);</script>\"大众;

}

}

}

else

{

echo \"大众<script>alert('提交未成功!
'); history.go(-1);</script>\"大众;

}

?>

送给刚入门的PHP程序员,

标签:

相关文章

php接口热证技巧_生物收集集智百科

图1:生物网络示例“集智百科精选”是一个长期专栏,持续为大家推送繁芜性科学干系的基本观点和资源信息。作为集智俱乐部的开源科学项目,...

PHP教程 2024-12-10 阅读0 评论0