php注冊頁面
㈠ 求一用php寫的注冊和登錄頁面代碼
reg.php文件
<?php
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '錯誤'.$e->getmessage();
}
$name = $_POST['name'];
$pwd = md5($_POST['pwd']);
$sql = "insert into 表 (username,password) values ('$name','$pwd')";
$exec = $pdo->query($sql);
if($exec){
echo "<script>alert('成功');location.href='reg.html'</script>";
}else{
echo "<script>alert('失敗');location.href='reg.html'</script>";
}
}
?>
reg.html文件
<form action='reg.php' method='post'>
用戶名:<input type='text' name='name'>
密碼:<input type='password' name='pwd'>
<input type='submit' value='submit'>
</form>
login.html文件
<form action='reg.php' method='post'>
用戶名:<input type='text' name='name'>
密碼:<input type='password' name='pwd'>
<input type='submit' value='submit'>
</form>
login.php文件
header("Content-type:text/html;charset=utf-8");
if($_POST){
$dsn = 'mysql:dbname=1104javab;host=127.0.0.1';
$user = 'root';
$password = '';
try{
$pdo = new pdo($dsn,$user,$password,array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'')
);
}catch(Exception $e){
echo '錯誤'.$e->getmessage();
}
$name = $_POST['name'];
$pwd = $_POST['pwd'];
$sql = "select user_id from 表名 where username='$name' and password='$pwd'";
$stmt = $pdo->query($sql);
$info = $stmt->fetch(PDO::FETCH_ASSOC);
if($info){
echo "登錄成功";
}else{
echo "登錄失敗";
}
}
大概這樣
㈡ 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注冊頁面表單驗證:要完整代碼
<form id="wp_signup_form" action="" method="post">
<p style="min-height:100px;">
<label for='captcha'><?php _e('驗證碼','sly');?>:</label>
<input type="text" name="captcha" class="text" value="" size="20" onfocus="show_captcha();" />
<span style="float:right; padding-right:100px;" onclick="show_captcha();"><?php _e('點擊顯示驗證碼','sly');?></span> <br />
<b><img src="" id="captcha_img" style="display:none;" onclick="change_captcha();" title="<?php _e('點擊更新驗證碼','sly');?>" /> </b></p>
<input type="submit" id="submitbtn" name="submit" value="注冊" class="pass-button-submit" />
</form>
驗證碼js:
</script>
<script type="text/javascript">
function show_captcha(){
if(document.getElementById("captcha_img").style.display=="none"){
document.getElementById("captcha_img").src = "/wp-content/themes/caijing/framework/captcha/index.php?captcha_name=inquiry_captcha&v="+Math.random();
document.getElementById("captcha_img").style.display = "block";
}
}
function change_captcha(){
document.getElementById("captcha_img").src = "/wp-content/themes/caijing/framework/captcha/index.php?captcha_name=inquiry_captcha&v="+Math.random();
}
</script>
驗證碼驗證:
//檢查驗證碼
$captcha = $wpdb->escape($_REQUEST['captcha']);
if(empty($captcha)) {
echo "驗證碼不能為空.";
exit();
}
if($captcha_img!=$_SESSION["captcha"]) {
㈣ php製作注冊界面
同步的就用AJAX,不是同步的不用。在頁面也可以用JS,直接寫,你會JAVA,那麼JS也不難寫。就直接連接資料庫查找下用戶名,如果已經注冊就顯示已經注冊。
㈤ 用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 注冊登陸界面
你會php嗎?會的話這邊給你個思路,然後根據這思路來寫。首先注冊效果是;回1、做好注冊頁面,答放置你要的表單,給你的每一個表單取一個名字(名字自定義,不重復即可)。2、用$_post或$_get來提交到php接收頁面。3、在php頁面裡面首先是接收你注冊頁面過來的信息,用$_POST["表單名字"]或$_GET["表單名字"]方法來接。4、執行sql語句了,把接過來的內容寫進資料庫就ok了。(insert into );登陸頁就是提交過來的數據跟資料庫裡面的數據進行比對的過程,這個沒多少代碼。把提交過來的數據,通過php接過來之後跟資料庫裡面的資料庫進行查找比對。一致就登陸成功,否則登陸失敗。
㈦ php注冊頁面問題
$UserName=$_POST['username'];//這里大小寫
$str="select * from users where username='".$UserName."'";
㈧ php注冊用戶頁面代碼
<?php
$bjbm=@$_POST["textbjbm"]; $xbbm=@$_POST["textxbbm"]; $xm=@$_POST["textxm"]; $xb=@$_POST["text_xb"]; $mm=@$_POST["textmm"];
$dh=@$_POST["textdh"]; $qq=@$_POST["textqq"]; $dz=@$_POST["textdz"]; $xh=@$_POST["textxh"]; $mc=@$_POST["textbjmc"];
if(@$_POST["Submit3"])
{
$sq="insert into ziliao values ('$xh','$xm','$xb','$mm','$dh','$qq','$dz','$bjbm','$xbbm')";
$re=mysql_query($sq);
$suer_sql="insert into user values ('$xh',md5('$xh'),'r','$bjbm')";
mysql_query($suer_sql);
for($xq=1;7>$xq;$xq++)
{
$cj_sql="insert into chengji values ('$xq','$bjbm','$mc','$xh','$xm','kc1','kc2','kc3','kc4','kc5','kc6','kc7','kc8','kc9','kc10','kc11')";
mysql_query($cj_sql);
}
if($re)
{
echo "<script>alert('成功添加一個新用戶,此用戶的用戶名和初始密碼都為學號!');window.close();</script>";
}
}
?>
㈨ php做一個登錄和注冊的頁面
登錄復要做兩個頁面(熟制練以後可以合為一個文件),一個是提供給瀏覽器輸入用戶名和密碼的LOGIN.HTML,另外一個是接受用戶名和密碼判斷是否成功的LOGIN.PHP文件。
LOGIN.HTML內容如下:
<FORM ACTION=LOGIN.PHP METHOD=POST>
用戶名:<INPUT TYPE=TEXT NAME=U>
密碼:<INPUT TYPE=TEXT NAME=P>
<INPUT TYPE=SUBMIT VALUE='登錄'>
</FORM>
LOGIN.PHP文件如下:
<?PHP
IF ($_POST['U']!='' && $+POST['P']!=''){
MYSQL_CONNECT(...);
$SQL='SELECT 密碼欄位名 FROM 注冊用戶表 WHERE 用戶名欄位=".$_POST['U']."';
$RES=MYSQL_QUERY($SQL);
LIST($PASS)=MYSQL_FETCH_ROW($RES);
MYSQL_FREE_RESULT($RES);
MYSQL_CLOSE();
IF ($PASS==$_POST['P']) ECHO '登錄成功';
ELSE ECHO '登錄失敗';
} ELSE ECHO '請輸入用戶名和密碼';
?>
㈩ 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>