php登入註冊頁面

來源:互聯網
上載者:User

標籤:class   users   new   擷取   int   for   put   input   form表單   

一、註冊頁面

1、首先要用form表單做一個註冊頁面:

<h1>註冊</h1><form action="chuli.php" method="post"><div>使用者名稱:<input type="text" name="uid" /></div><div>密碼:<input type="password" name="pwd" /></div><div>姓名:<input type="text" name="name" /></div><div>性別:男<input type="radio" name="sex" value="1"/>女<input type="radio" name="sex" value="0"/></div><div>生日:<input type="text" name="birthday" /></div><div><input type="submit" value="註冊" /></div></form>

2、做一個純php的頁面來擷取註冊頁面的資料

<?php//1.取提交的資料$uid=$_POST["uid"];//如果是get,就用$_GET()$pwd=$_POST["pwd"];$name=$_POST["name"];$sex=$_POST["sex"];$birthday=$_POST["birthday"];//2.向資料庫寫入$db=new MySQLi("localhost","root","123","text_0306");$sql="insert into usersvalues(‘{$uid}‘,‘{$pwd}‘,‘{$name}‘,{$sex},‘{$birthday}‘)";//這裡取每個列名if($db->query($sql)){    echo"註冊成功";}else{    echo"註冊失敗";    }?>

二、登陸頁面

1、做一個登陸頁面的form表單:

<body><h1>登陸頁面</h1><form action="denglu1.php" method="post"><div>使用者名稱:<input type="text" name="uid" /></div><div>密碼:<input type="password" name="pwd" /></div><div><input type="submit" value="登入" /></div></form></body>

2、做一個純php頁面來擷取登陸頁面的資料

<?php//1.取提交的資料$uid=$_POST["uid"];$pwd=$_POST["pwd"];//2.向資料庫寫入$db=new MySQLi("localhost","root","123","text_0306");$sql="select pwd from users where uid=‘{$uid}‘";//用密碼來驗證使用者名稱,防止被入侵$result=$db->query($sql);$arr=$result->fetch_row();if($arr[0]==$pwd && !empty($pwd))//驗證索引是否等於密碼且不可為空{    echo"登陸成功";}else{    echo"登入失敗";    }?>

 

php登入註冊頁面

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.