好得很程序员自学网
  • 首页
  • 后端语言
    • C#
    • PHP
    • Python
    • java
    • Golang
    • ASP.NET
  • 前端开发
    • Angular
    • react框架
    • LayUi开发
    • javascript
    • HTML与HTML5
    • CSS与CSS3
    • jQuery
    • Bootstrap
    • NodeJS
    • Vue与小程序技术
    • Photoshop
  • 数据库技术
    • MSSQL
    • MYSQL
    • Redis
    • MongoDB
    • Oracle
    • PostgreSQL
    • Sqlite
    • 数据库基础
    • 数据库排错
  • CMS系统
    • HDHCMS
    • WordPress
    • Dedecms
    • PhpCms
    • 帝国CMS
    • ThinkPHP
    • Discuz
    • ZBlog
    • ECSHOP
  • 高手进阶
    • Android技术
    • 正则表达式
    • 数据结构与算法
  • 系统运维
    • Windows
    • apache
    • 服务器排错
    • 网站安全
    • nginx
    • linux系统
    • MacOS
  • 学习教程
    • 前端脚本教程
    • HTML与CSS 教程
    • 脚本语言教程
    • 数据库教程
    • 应用系统教程
  • 新技术
  • 编程导航
    • 区块链
    • IT资讯
    • 设计灵感
    • 建站资源
    • 开发团队
    • 程序社区
    • 图标图库
    • 图形动效
    • IDE环境
    • 在线工具
    • 调试测试
    • Node开发
    • 游戏框架
    • CSS库
    • Jquery插件
    • Js插件
    • Web框架
    • 移动端框架
    • 模块管理
    • 开发社区
    • 在线课堂
    • 框架类库
    • 项目托管
    • 云服务

当前位置:首页>后端语言>PHP
<tfoot draggable='sEl'></tfoot>

简易php注册登录 php实现简单登录和注册功能

很多站长朋友们都不太清楚简易php注册登录,今天小编就来给大家整理简易php注册登录,希望对各位有所帮助,具体内容如下:

本文目录一览: 1、 用PHP做登陆注册页面 2、 PHP来实现网站的注册和登录 3、 php 制作简单的注册页面 登陆页面 然后验证 4、 php简单网站的登录和注册怎么写 5、 怎样用php做一个网站的登录注册 6、 使用php实现用户注册和登录功能制作 !急求大神帮助! 用PHP做登陆注册页面

登录页:login.php

<?php

include("conn.php");

$username=$_POST['name'];

$password=$_POST['password'];

$yanzheng=$_POST['yanzheng'];

if(isset($_POST['submit']))

{

$sql=("select username,password from member where username='$username' and password='$password'") or die("sql语句执行失败");

//print_r($sql);

$ar=mysql_query($sql);

if($ar)

{

if($row=mysql_fetch_array($ar))

{

session_start();

if($_POST["yanzheng"])

{

if($yanzheng!=$_session[pic]||$yanzheng=="")

{

echo "验证码输入有误";

exit;

}

if($yanzheng==$_session[pic])

{

header("location:index.php");

}

}

}

else

{

echo "用户名或密码错误";

}

}

}

?>

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

<table border=1 align=center width=500 height=300 bgColor=#DFFFDF bordercolor=#fffbec>

<tr>

<td colspan=2 align=center>用户登录</td>

</tr>

<tr>

<td>用户姓名:</td>

<td><input type="text" name="name" id="name"/></td>

</tr>

<tr>

<td>用户密码:</td>

<td><input type="password" name="password" id="password"/></td>

</tr>

<tr>

<td>验证码:</td>

<td><input type="text" name="yanzheng" id="yanzheng"/>

<img src="/data/upload/help/202303/13/51998250cd085b6d7ad5c1f68e285d25.php" width="50" height="30"></img>

</td>

</tr>

<tr>

<td colspan=3 align=center>

<input type="submit" name="submit" value="登录"/>

<input type="reset" name="reset" value="重置"/>

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

</td>

</tr>

</table>

</form>

注册页:register.php

<?php

include("conn.php");

if(isset($_POST['submit'])$_POST['submit']) {

if($_POST['username']=='')

{

echo "用户名不能为空";

exit();

}

if($_POST['password']=='')

{

echo "密码不能为空";

exit();

}

if($_POST['realpass']!=$_POST['password'])

{

echo "两次密码输入不一致";

exit();

}

$sql="insert into member(username,real_name,password,email,headimg) values('$_POST[username]','$_POST[username]','$_POST[password]','$_POST[email]','')";

$ar=mysql_query($sql);

if($ar)

{

header("location:index.php");

}

else

{

echo mysql_error();

}

}

?>

<body>

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

<table border=1 align=center width=500>

<tr>

<td height=40 bgColor=#DFFFDF colspan=2>会员注册 [<a href="login.php">返回登录页</a>]</td>

</tr>

<tr>

<td height=40 bgColor=#fffbec >会员ID</td>

<td><input type="text" name="username" id="username"/></td>

</tr>

<tr>

<td height=40 bgColor=#fffbec>密码</td>

<td><input type="password" name="password" id="password"/></td>

</tr>

<tr>

<td height=40 bgColor=#fffbec>确认密码</td>

<td>

<input type="password" name="realpass" id="realpass"/>

</td>

</tr>

<tr>

<td height=40 bgColor=#fffbec>EMAIL</td>

<td><input type="text" name="email" id="email"/>

</tr>

<tr>

<td height=40 bgColor=#fffbec></td>

<td><input type="submit" name="submit" value="注册"/><input type="reset" value="重置"></td>

</tr>

</table>

</form>

</body>

主页显示:index.php

<?php

include("conn.php");

function cutstr($str,$cutleng)

{

$str = $str; //要截取的字符串

$cutleng = $cutleng; //要截取的长度

$strleng = strlen($str); //字符串长度

if($cutleng>$strleng)return $str;//字符串长度小于规定字数时,返回字符串本身

$notchinanum = 0; //初始不是汉字的字符数

for($i=0;$i<$cutleng;$i++)

{

if(ord(substr($str,$i,1))<=128)

{

$notchinanum++;

}

}

if(($cutleng%2==1)($notchinanum%2==0)) //如果要截取奇数个字符,所要截取长度范围内的字符必须含奇数个非汉字,否则截取的长度加一

{

$cutleng++;

}

if(($cutleng%2==0)($notchinanum%2==1)) //如果要截取偶数个字符,所要截取长度范围内的字符必须含偶数个非汉字,否则截取的长度加一

{

$cutleng++;

}

return substr($str,0,$cutleng);

}

?>

<html>

<head>

<script type="text/javascript">

function All(e, itemName)

{

var aa = document.getElementsByName(itemName);

for (var i=0; i<aa.length; i++)

aa[i].checked = e.checked; //得到那个总控的复选框的选中状态

}

function Item(e, allName)

{

var all = document.getElementsByName(allName)[0];

if(!e.checked) all.checked = false;

else

{

var aa = document.getElementsByName(e.name);

for (var i=0; i<aa.length; i++)

if(!aa[i].checked) return;

all.checked = true;

}

}

</script>

</head>

<?php

include("conn.php");

if(isset($_POST['del']))

{

$mm = $_POST["selected"];

$id =implode(",",$mm);

$sql = "delete from forums where id in(".$id.")";

//echo $sql;

$result=mysql_query($sql);

echo $result?"删除成功":"删除失败";

}

?>

<table style="BORDER-BOTTOM-WIDTH: 1px; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=600 align=center border=1 bordercolor=#ddddff>

<tr align=middle>

<td height=40 bgColor=#DFFFDF colspan=3>论坛列表</td>

</tr>

<tr>

<td colspan=3><a href="login.php" style="float:right">[退出系统]</a><a href="add_forum.php" style="float:right">[添加论坛]</a></td>

<td></td>

</tr>

<tr align=middle>

<td height=40 bgColor=#DFFFDF width=80>状态</td>

<td height=40 bgColor=#DFFFDF>论坛</td>

<td height=40 bgColor=#DFFFDF>最后更新</td>

</tr>

<?php

$sql="select * from forums";

$result=mysql_query($sql);

$num=mysql_num_rows($result);

if($num>0)

{

while($row=mysql_fetch_array($result)){

?>

<tr align=middle>

<td bgColor=#fffbec><input type="checkbox" name="selected" value="1"/></td>

<td height=50 bgColor=#fffbec width=300>

<?php

echo "<div><a href=\"forums.php?F=".$row['ID']."\">".$row['forum_name']."</a></div>";

echo cutstr($row['forum_description'],24);//最多显示24个字节,12个字,多余部分用省略号代替

echo "……";

?>

</td>

<td height=50 bgColor=#fffbec><div><?php echo $row['last_post_time']."by".$row['last_post_author']?></div></td>

</tr>

<?php

}

}

else

{

echo "<tr bgColor=#fffbec><td colspan=3>对不起,论坛尚在创建中……</td></tr>";

}

?>

<tr>

<td colspan=3> <input type="checkbox" name="selected" value="1" onclick="All(this,'selected')"/>全选/不全选</td>

</tr>

<tr>

<td><input type="button" name="del" id="del" value="删除选中项"/>

<?php

?>

</td>

</tr>

</table>

</html>

数据库你就自己建,望采纳~

PHP来实现网站的注册和登录

说明: 对于小白学习php还是先下一个phpstudy吧 比较便捷许多且自带mysql

1、打开phpstudy并启动

2、打开mysql管理器并启动MYSQL-front 如图所示

1、建立一个名为register的html文件

2、建立一个名为registApi的php文件并刚建立的html相连

-拿到用户的字段和密码

-查询是否有重名现象(注:可以在php中嵌入html语句但一般写在外面如该图末尾所示)

-根据返回值判断是否成功

1、返回登录页面

2、创建一个名为loginApi的php文件并与刚刚的html相连接

3、若用户登录成功返回一个成功的界面所以创建一个success的html

php 制作简单的注册页面 登陆页面 然后验证

user表 字段id int(11) username varchar(20) password varchar(32)

这3个字段就够了。

html页面 rel.html

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

用户名:<input type="text" name="name"><br><br>

密码:<input type="password" name="password"><br><br>

<input type="submit" name="submit" value="注册">

</form>

rel.php

<?php

//连接数据库的代码我就不写了 你应该会吧?不会百度一下就好了

$submit = isset($_POST['submit']) ? $_POST['submit'] : '';

if($submit){//如果有表单提交

$username = isset($_POST['username']) ? $_POST['username'] : '';

$password = isset($_POST['password']) ? $_POST['passowrd'] : '';

$password = md5($password);

//先查询数据库是否存在该用户名 注:用户登陆就是等于这个查询 不过查询的时候多加一个password 就是WHERE `username` = '$username` AND `password` = '$password` 就OK拉。

$sqlSelect = "SELECT `username` FROM `user` WHERE `username` = '$username'";

$querySelect = mysql_query($sqlSelect);

@$resultSelect = mysql_fetch_array($querySelect);

if($resultSelect['username']){

echo "<script>alert('该用户名已经存在。');location.href='rel.html';</script>";

}else{//可以注册。

$sqlInsert = "INSERT INTO `user`(`username`,`password`) VALUES('$username','$password')";

$queryInsert = mysql_query($sqlInsert);

if($queryInsert){//注册成功

echo "<script>alert('恭喜,注册成功。');location.href='这里写你注册成功的页面地址。';</script>";

}else{

echo "<script>alert('对不起,注册失败。');location.href='rel.html';</script>";

}

}

}

?>

这就是个简单的注册页面 登陆的话你就把验证用户是否存在的那个单拿出来就行了。。

纯手打,望采纳。

----------------------

对啊 那句话就是注释啊。

php简单网站的登录和注册怎么写

注册:

用户名 :手机号或者邮箱

密码:规定6-16位字符或者6-12位,不能出现_、等字符,规定只能数字和英文字符组成

验证码:随机图片

ajax提交时验证用户名是否合法(邮箱或手机号验证)。去掉首尾空白。判断数据格式(过滤html标签,防止sql注入)

判断密码格式和长度

判断验证码正确

三者都正确。提交到后台处理:

查询用户名是否存在,如果存在,不能注册,返回页面。如果不存在则将密码加密处理(md5或者哈希加密生成一段密文,然后输入密码拼接生成的密文存入数据库更保险)

插入成功成功,返回登录界面。

登录:

和注册一样判断用户名。

提交到后台

后台可以用mysql_real_escape_string()函数对用户名和密码进行转义,防止sql注入

密码同样道理加密。去数据库查询用户名和密码,返回成功,则将用户id号和用户名存入session里。跳转页面。

怎样用php做一个网站的登录注册

在php文件中嵌入html代码(包含表单,做好表单验证),提交到一个表单处理文件(php文件),处理文件里查询数据库,和用户提交的用户名,密码匹配,异常则登录失败,正常则登录成功,跳转页面(重定向或转发)。注册同理做好html页面,提交到注册处理页,先校验数据库是否存在用户名,有则返回注册页,提示注册失败,无则在数据库插入用户注册表单的信息。

使用php实现用户注册和登录功能制作 !急求大神帮助!

1、需要建立一个数据表test

id int(10) primary key not null increment

name char(4) not null

pass char(10) not null

age int(2)

city char(5)

2、html页面自己写,用表单post传参

3、.php页面,处理接收到的参数,于数据库里面的用户名和密码比对,若果正确,用Js框,输出欢迎页面,如果不多返回到登陆页面

这里告诉你一个小技巧,很多时候我们都是拿用户名和密码一起比对,如果都正确则跳转。这个地方其实我们需要防止sql注入攻击,我们可以写两条语句,当用户名正确,我们才执行下一条密码比对语句,这样可以有效防止sql的注入攻击。

关于简易php注册登录的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。

查看更多关于简易php注册登录 php实现简单登录和注册功能的详细内容...

声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did207911
更新时间:2023-05-03   阅读:32次

上一篇: 关于phptxt文本读取的信息

下一篇:php在线答题功能 php在线答题系统代码

最新资料更新

  • 1.php每天更新数据 php数据库更新语句
  • 2.零基础php模板 php0基础教程
  • 3.php双色球案例 双色球php复式逻辑
  • 4.redis缓存类php php redis页面缓存
  • 5.php获取数组坐标 php获取数组的值
  • 6.基于php在线聊天 php 在线聊天
  • 7.phpajix的简单介绍
  • 8.php批量取中间 php批量删除数据
  • 9.php在线做点兼职 php在线做点兼职是真的吗
  • 10.包含phpgetitems的词条
  • 11.php链接数据库创建表格 php连接数据库的方法
  • 12.php怎样打开url php链接怎么打开
  • 13.php中国什么意思 php叫什么
  • 14.php仿站技术 用仿站小工具制作网站
  • 15.php加密解密 php数据加密解密
  • 16.php用户资料转移 php迁移java
  • 17.破解php登录才能查看 破解php登录才能查看吗
  • 18.php输出jq代码 php输出hello
  • 19.php的如何使用数组if php中数组
  • 20.php网站依赖 php运行网址

CopyRight:2016-{hedonghua:year}{hedonghua:sitegs} 备案ICP:湘ICP备09009000号-16 {hedonghua:sitejym}
本站资讯不构成任何建议,仅限于个人分享,参考须谨慎!
本网站对有关资料所引致的错误、不确或遗漏,概不负任何法律责任。
本网站刊载的所有内容(包括但不仅限文字、图片、LOGO、音频、视频、软件、程序等)版权归原作者所有。任何单位或个人认为本网站中的内容可能涉嫌侵犯其知识产权或存在不实内容时,请及时通知本站,予以删除。

网站内容来源于网络分享,如有侵权发邮箱到:kenbest@126.com,收到邮件我们会即时下线处理。
网站框架支持:HDHCMS   51LA统计 百度统计
Copyright © 2018-2026 「好得很程序员自学网」
[ SiteMap ]