簡單的php 使用者註冊程式[全套]

來源:互聯網
上載者:User

<?php
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>yd631_php_user會員管理執行個體</title>
</head>

<body><center>
  <form name="form1" method="post" action="reg_cl.php"><table width="68%" height="304"  border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr align="center" bgcolor="#CCCCCC">
      <td colspan="2">註冊(reg.php)||<a href="index.php">返回</a></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td width="29%" align="right">使用者名稱:</td>
      <td width="71%" align="left"><input name="yd631_name" type="text" id="yd631_name"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">密碼:</td>
      <td align="left"><input name="yd631_pws" type="password" id="yd631_pws"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">性別:</td>
      <td align="left"><input name="yd631_sex" type="radio" value="男" checked>
        男
           
          <input type="radio" name="yd631_sex" value="女"> 
        女</td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">年齡:</td>
      <td align="left"><input name="yd631_age" type="text" id="yd631_age" size="10" maxlength="4"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">電話:</td>
      <td align="left"><input name="yd631_call" type="text" id="yd631_call"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">郵件:</td>
      <td align="left"><input name="yd631_email" type="text" id="yd631_email"></td>
    </tr>
    <tr bgcolor="#CCCCCC">
      <td align="right">地址:</td>
      <td align="left"><input name="yd631_address" type="text" id="yd631_address" size="40"></td>
    </tr>
    <tr align="center" bgcolor="#CCCCCC">
      <td colspan="2"><input type="submit" name="Submit" value="提交">  
        <input type="reset" name="Submit" value="重設"></td>
    </tr>
  </table>
  </form>
</center>

</body>
</html>

註冊php處理頁面

<?php
//註冊處理頁面
//www.yd631.com
//技術D.JOY
function checkmail($nmail){   /// 驗證電子郵件地址
 if(ereg("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+",$nmail))
  return true;
 else
  return false;
}

include("config.php"); //參數頁面提取過來

if(empty($_POST["yd631_name"])){
echo ("<script type='text/javascript'> alert('使用者名稱不能是空的');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_pws"])){
echo ("<script type='text/javascript'> alert('密碼為空白了吧');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_sex"])){
echo ("<script type='text/javascript'> alert('性別呢');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_age"])){
echo ("<script type='text/javascript'> alert('年齡不可為空');history.go(-1);</script>");
exit;
}
if(!is_numeric($_POST["yd631_age"])){
echo ("<script type='text/javascript'> alert('年齡要是數位');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_call"])){
echo ("<script type='text/javascript'> alert('電話不可為空');history.go(-1);</script>");
exit;
}
if(!is_numeric($_POST["yd631_call"])){
echo ("<script type='text/javascript'> alert('電話要是數位');history.go(-1);</script>");
exit;
}
if(empty($_POST["yd631_email"])){
echo ("<script type='text/javascript'> alert('郵箱不可為空');history.go(-1);</script>");
exit;
}
if($_POST["yd631_email"]!=""){

  if(!checkmail($_POST["yd631_email"])) {
 echo ("<script type='text/javascript'> alert('不對了,郵箱格式');history.go(-1);</script>");
 exit;
  }
}

if(empty($_POST["yd631_address"])){
echo ("<script type='text/javascript'> alert('地址不可為空');history.go(-1);</script>");
exit;
}

$yd631_name=$_POST["yd631_name"];
$yd631_pws=$_POST["yd631_pws"];
$yd631_sex=$_POST["yd631_sex"];
$yd631_age=$_POST["yd631_age"];
$yd631_call=$_POST["yd631_call"];
$yd631_email=$_POST["yd631_email"];
$yd631_address=$_POST["yd631_address"];
$yd631_time=date("Y-m-d");
$yd631_pass="no";

$db=mysql_connect($servername,$sqlservername,$sqlserverpws);
mysql_select_db($sqlname,$db) ;
$sql="select * from $sqltable where yd631_name='$yd631_name'";
$result=mysql_fetch_row(mysql_query($sql));

if($result){
echo ("<script type='text/javascript'> alert('使用者名稱在,你就不能註冊這個名字');history.go(-1);</script>");

}
else{
$sql="insert into $sqltable(yd631_name,yd631_pws,yd631_sex,yd631_age,yd631_call,yd631_email,yd631_address,yd631_time,yd631_pass) values('$yd631_name','$yd631_pws','$yd631_sex','$yd631_age','$yd631_call','$yd631_email','$yd631_address','$yd631_time','$yd631_pass') ";
mysql_query($sql);

echo ("<script type='text/javascript'> alert('添加成功');location.href='index.php';</script>");
}
?>

mysql資料庫

--
-- 表的結構 `yd631_users`
--

CREATE TABLE `yd631_users` (
  `yd631_id` int(10) NOT NULL auto_increment,
  `yd631_name` varchar(10) default NULL,
  `yd631_pws` varchar(10) default NULL,
  `yd631_sex` varchar(4) default NULL,
  `yd631_age` varchar(4) default NULL,
  `yd631_call` varchar(15) default NULL,
  `yd631_email` varchar(20) default NULL,
  `yd631_address` text,
  `yd631_pass` varchar(4) default NULL,
  `yd631_time` date default NULL,
  PRIMARY KEY  (`yd631_id`)
) ;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.