色www,五月婷婷深爱五月,午夜国产一级片,色噜噜综合,国产大胸无码视频,清纯美女被操黄网站在线观看,波多野结衣av高清一区二区三区

php注冊和登錄界面的實現(xiàn)案例

時間:2025-11-21 17:47:06 php語言

php注冊和登錄界面的實現(xiàn)案例

  當(dāng)初接觸電腦編程的時間覺得一個網(wǎng)站上注冊和登錄這兩個功能很神奇,后來自己研究一下發(fā)現(xiàn)其實道理很簡單,下面小編就為大家?guī)硪黄猵hp注冊和登錄界面的實現(xiàn)案例,感興趣的同學(xué)一起來看看怎么實現(xiàn)的吧。

  首先在電腦上建了幾個文件:

  login.html (登錄頁面)

  register.html(注冊頁面)

  success.html(登錄成功跳轉(zhuǎn)頁面)

  return.html(注冊成功頁面)

  login.php

  register.php

  登錄界面和注冊界面以及success.html并沒有

  什么都是些html標(biāo)記如下:

  <html>

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <title>登錄界面</title>

  </head>

  <body>

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

  賬號:

  <input type="text" name="usernamel"><br/><br/>

  密碼:

  <input type="password" name="passwordl">

  <input type="submit" value="登錄" name="subl">

  <a href="/pic/register.html">沒有賬號,注冊</a>

  </form>

  </body>

  </html>

  <html>

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <title>會員注冊</title>

  </head>

  <body>

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

  賬  戶:

  <input type="text" name="username"><br/><br/>

  密  碼:

  <input type="password" name="password"><br/><br/>

  密碼確認:

  <input type="password" name="password2">

  <input type="submit" value="注冊" name="sub">

  </form>

  </body>

  </html>

  return.html是注冊成功之后呈現(xiàn)的頁面,里面有一段js代碼是用來定時返回登錄界面的

  <html>

  <head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

  <title>無標(biāo)題文檔</title>

  </head>

  <body>

  注冊成功!<br/>

  5秒后返回登錄界面<br/>

  你也可以直接點擊回到<a href="/pic/login.html">登錄頁面</a>

  <script type="text/javascript">

  setTimeout("ren()",5000);

  function ren()

  {

  window.location="/pic/login.html";

  }

  </script>

  </body>

  </html>

  register.php這是與注冊頁面相對應(yīng)后臺頁面

  <?php

  $link=mysql_connect("localhost","root","207207");/pic/p>

  header("Content-type:text/html;charset=utf-8");

  if($link)

  {

  /pic/p>

  $select=mysql_select_db("login",$link);/pic/p>

  if($select)

  {

  /pic/p>

  if(isset($_POST["sub"]))

  {

  $name=$_POST["username"];

  $password1=$_POST["password"];/pic/p>

  $password2=$_POST["password2"];

  if($name==""||$password1=="")/pic/p>

  {

  echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."請?zhí)顚懲瓿桑?quot;."\"".")".";"."</script>";

  echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."/pic/register.html"."\""."</script>";

  exit;

  }

  if($password1==$password2)/pic/p>

  {

  $str="select count(*) from register where username="."'"."$name"."'";

  $result=mysql_query($str,$link);

  $pass=mysql_fetch_row($result);

  $pa=$pass[0];

  if($pa==1)/pic/p>

  {

  echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."該用戶名已被注冊"."\"".")".";"."</script>";

  echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."/pic/register.html"."\""."</script>";

  exit;

  }

  $sql="insert into register values("."\""."$name"."\"".","."\""."$password1"."\"".")";/pic/p>

  /pic/p>

  mysql_query($sql,$link);

  mysql_query('SET NAMES UTF8');

  $close=mysql_close($link);

  if($close)

  {

  /pic/p>

  /pic/p>

  echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."/pic/return.html"."\""."</script>";

  }

  }

  else

  {

  echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."密碼不一致!"."\"".")".";"."</script>";

  echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."/pic/register.html"."\""."</script>";

  }

  }

  }

  }

  ?>

  login.php登錄界面對應(yīng)后臺文件

  <?php

  header("Content-type:text/html;charset=utf-8");

  $link=mysql_connect("localhost","root","207207");

  if($link)

  {

  $select=mysql_select_db("login",$link);

  if($select)

  {

  if(isset($_POST["subl"]))

  {

  $name=$_POST["usernamel"];

  $password=$_POST["passwordl"];

  if($name==""||$password=="")/pic/p>

  {

  echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."請?zhí)顚懻_的信息!"."\"".")".";"."</script>";

  echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."/pic/login.html"."\""."</script>";

  exit;

  }

  $str="select password from register where username="."'"."$name"."'";

  mysql_query('SET NAMES UTF8');20       $result=mysql_query($str,$link);

  $pass=mysql_fetch_row($result);

  $pa=$pass[0];

  if($pa==$password)/pic/p>

  {

  echo"登錄成功!";

  echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."/pic/success.html"."\""."</script>";

  }

  {

  echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."登錄失敗!"."\"".")".";"."</script>";

  echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."/pic/login.html"."\""."</script>";

  }

  }

  }

  }

  ?>

  以上就是小編為大家?guī)淼膒hp注冊和登錄界面的實現(xiàn)案例全部內(nèi)容了,自己閑來無事做的還有許多要完善的地方,歡迎大家提問討論,提供更簡便的方法!

【php注冊和登錄界面的實現(xiàn)案例】相關(guān)文章:

php用cookie實現(xiàn)記住登錄狀態(tài)02-02

PHP中使用session實現(xiàn)保存用戶登錄信息12-14

PHP如何實現(xiàn)注冊后郵箱驗證和帳號激活11-03

php的curl實現(xiàn)get和post的代碼08-30

php實現(xiàn)編輯和保存文件的方法02-27

PHP實現(xiàn)文件上傳和多文件上傳01-19

實現(xiàn)PHP實現(xiàn)限制IP訪問02-23

PHP實現(xiàn)股票趨勢圖和柱形圖01-24

PHP實現(xiàn)定時任務(wù)的幾種方式和詳解08-11