當前位置:首頁 » 編程語言 » php注冊頁面

php注冊頁面

發布時間: 2022-06-08 17:37:34

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的注冊頁面中,不想讓用戶可以重復注冊,怎樣解決改了好多遍就是不行。希望有人幫助解決,謝謝了。

這個知道你的意思是什麼?你說的重復注冊可以理解為兩種:
第一種:就是相同用戶只能注冊一次,這個加個主鍵就可以了,也可以通過查詢資料庫是不是存在這個用戶,如果存在,提示該用戶已經注冊,這個最好的辦法是採用Ajax在注冊頁面直接判斷。
第二種:就是一個人職能注冊一個帳號,這個就有記錄IP地址了,

㈢ 怎樣用php做一個網站的登錄注冊

在php文件中嵌入html代碼(包含表單,做好表單驗證),提交到一個表單處理文件(php文件),處理文件里查詢資料庫,和用戶提交的用戶名,密碼匹配,異常則登錄失敗,正常則登錄成功,跳轉頁面(重定向或轉發)。注冊同理做好html頁面,提交到注冊處理頁,先校驗資料庫是否存在用戶名,有則返回注冊頁,提示注冊失敗,無則在資料庫插入用戶注冊表單的信息。

㈣ PHP如何實現注冊和登錄

注冊頁面前面加個下拉框或者單選按鈕,然後把值傳過去,登錄的時候也選擇,傳值,然後在相應的分類查找這個人。注冊頁面前面加個下拉框或者單選按鈕,然後把值傳過去,登錄的時候也選擇,傳值,然後在相應的分類查找這個人。

㈤ php 實現簡單的注冊頁面 並把注冊信息插入到 mysql 資料庫中

注冊頁面:reg.html

<form action="reg.php" method="POST">
<table>
<tr><td>用戶名:</td><td><input type="username" size="20"></td></tr>
<tr><td>密碼:</td><td><input type="userpass" size="20"></td></tr>
<tr><td>確認密碼:</td><td><input type="ruserpass" size="20"></td></tr>
<tr><td>郵箱:</td><td><input type="email" size="50"></td></tr>
<tr><td>電話:</td><td><input type="telphone" size="20"></td></tr>
<tr><td><input type="Submit" value="注冊"></td></tr>
</table>
</form>

接收頁面:reg.php
<%php
$db = mysql_connect("localhost", "root", "12345");
mysql_select_db("dataname", $db);
mysql_query("insert into tablename(username, userpass, email, telphone) values('$_POST[username]', '$_POST[userpass]', '$_POST[email]', '$_POST[telphone]')");
echo "注冊成功";
%>

㈥ 用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="yanzheng1.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注冊頁面問題

朋友你好
提示:Parse error: parse error in D:\web\htdocs\z\register.php on line 15
line 15也就是下面的:$result1=$conn- >query($str);
這句話就是說你的sql有問題,你sql語句裡面的變數名是用的小寫$username
而你在接受賦值是又是$UserName=$_POST['username'];這樣的,所以他找不到你所申明的變數,那麼就會報錯;
這里要說明一點php裡面變數是區分大小寫的;注意這種小問題就好了。
我也是初學,希望大家共同進步

㈧ 如何用php在登錄頁面中設置「注冊」按鈕,然後點擊後即進入注冊頁面啊在此先感謝了

用Form表單,如<form action="你要跳轉的頁面網址" name="form" method="post"/
<input type="submit" name="name" value="注冊"/>

></form>
這樣的話,點擊注冊按鈕就跳轉到你想要的網址那兒去了

㈨ 做一個簡單的php 注冊登陸界面

你會php嗎?會的話這邊給你個思路,然後根據這思路來寫。首先注冊效果是;1、做好注冊頁面,放置你要的表單,給你的每一個表單取一個名字(名字自定義,不重復即可)。2、用$_post或$_get來提交到php接收頁面。3、在php頁面裡面首先是接收你注冊頁面過來的信息,用$_POST["表單名字"]或$_GET["表單名字"]方法來接。4、執行sql語句了,把接過來的內容寫進資料庫就ok了。(insert into );登陸頁就是提交過來的數據跟資料庫裡面的數據進行比對的過程,這個沒多少代碼。把提交過來的數據,通過php接過來之後跟資料庫裡面的資料庫進行查找比對。一致就登陸成功,否則登陸失敗。

㈩ php簡單注冊頁面代碼怎麼寫

test.php
<?php
if($_POST){
$name = $_POST[name];
$pass = $_POST[pass];
獲取表單的值
執行sql語句;
}

?>
<html>
<form action="test.php" method="post">
用戶名:<input type="type">
密碼:<input type="pass">
<input type="submit" value="提交">
</html>

熱點內容
maven預編譯 發布:2025-02-08 09:20:34 瀏覽:751
手機電量緩存 發布:2025-02-08 09:01:37 瀏覽:898
java怎麼寫程序 發布:2025-02-08 09:00:55 瀏覽:868
javaphp加密 發布:2025-02-08 08:59:45 瀏覽:986
股票避險資產配置哪個好 發布:2025-02-08 08:57:44 瀏覽:878
谷歌瀏覽器開啟ftp 發布:2025-02-08 08:55:08 瀏覽:33
安卓工程師開發是什麼專業 發布:2025-02-08 08:38:15 瀏覽:678
怎麼用電腦和朋友遠程伺服器連接 發布:2025-02-08 08:29:52 瀏覽:233
如何播放咪咕視頻的緩存電影 發布:2025-02-08 08:28:17 瀏覽:574
台式電腦修改密碼在哪裡修改 發布:2025-02-08 08:25:18 瀏覽:298