PHP? ??? ?? ?? ??? ??? ?? ?? ?? ??? ?????.
?????? ?? config.php? ?? ?? head.php? ?????
<?php include("head.php");?> <?php include("config.php");?>
??? ?? ?? ??? ????, ?? ??? reg.php???.
<?php include("config.php"); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>圖書管理系統(tǒng)注冊頁面</title> <style> body,td,th {font-family: 微軟雅黑;font-size: 9px;color: #222;} body {background-color: #FFFFFF;line-height:20px;} a:link {color: #222;text-decoration: none;} a:visited {text-decoration: none;color: #222;} a:hover {text-decoration: underline;color: #FF0000;} a:active {text-decoration: none;color: #999999;} </style> </head> <script type="text/javascript"> function checkreg() { if (form1.name.value=="") { // 如果真實姓名為空,則顯示警告信息 alert("真實姓名不能為空!"); form1.name.focus(); return false; } if (form1.password.value=="" ) { // 如果密碼為空,則顯示警告信息 alert("密碼不能為空!"); form1.password.focus(); return false; } if (form1.pwd.value=="" ) { // 如果確認(rèn)密碼為空,則顯示警告信息 alert("確認(rèn)密碼不能為空!"); form1.pwd.focus(); return false; } // 兩次密碼應(yīng)一樣 if (form1.password.value!=form1.pwd.value && form1.password.value!="") { alert("兩次密碼不一樣,請確認(rèn)!"); form1.password.focus(); return false; } if (form1.email.value=="") { // 如果Email為空,則顯示警告信息 alert("Email不能為空!"); form1.email.focus(); return false; } // 檢查email格式是否正確 else if (form1.email.value.charAt(0)=="." || form1.email.value.charAt(0)=="@"|| form1.email.value.indexOf('@', 0) == -1 || form1.email.value.indexOf('.', 0) == -1 || form1.email.value.lastIndexOf("@")==form1.email.value.length-1 || form1.email.value.lastIndexOf(".")==form1.email.value.length-1) { alert("Email的格式不正確!"); form1.email.select(); return false; } return true; } </script> <?php if($_POST['submit']){ // 取得網(wǎng)頁的參數(shù) $name=$_POST['name']; $password=$_POST['password']; $email=$_POST['email']; $tel=$_POST['tel']; $address=$_POST['address']; // 加密密碼 //$password=md5($password); // 連接數(shù)據(jù)庫,注冊用戶 $sql="insert into user(name, password, email, tel, address) values('$name','$password','$email', '$tel','$address')"; mysqli_query($link,$sql); // 獲得注冊用戶的自動id,以后使用此id才可登錄 $result=mysqli_query($link,"select last_insert_id()"); $re_arr=mysqli_fetch_array($result); $id=$re_arr[0]; //注冊成功,自動登錄,注冊session變量 $_SESSION['user'] = null; $user=$id; echo "<script language=javascript>alert('注冊成功,進(jìn)入首頁!');window.location='index.php'</script>"; } ?> <body> <?php include("head.php");?> <form name="form1" method="post" action="" enctype='multipart/form-data' onSubmit="return checkreg()" > <table width="782" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <th colspan="2" bgcolor="#FFFFFF"><font size="5">用 戶 注 冊 界 面</font></th> </tr> <tr> <td width="364" align="right" bgcolor="#FFFFFF">姓 名:</td> <td width="403" bgcolor="#FFFFFF"> <input type="text" name="name"> </tr> <tr> <td align="right" bgcolor="#FFFFFF">密 碼:</td> <td bgcolor="#FFFFFF"> <input type="password" name="password"> </tr> <tr> <td align="right" bgcolor="#FFFFFF">確認(rèn)密碼:</td> <td bgcolor="#FFFFFF"> <input type="password" name="pwd"> </tr> <tr> <td align="right" bgcolor="#FFFFFF">Email:</td> <td bgcolor="#FFFFFF"> <input type="text" name="email"> </tr> <tr> <td align="right" bgcolor="#FFFFFF">電 話:</td> <td bgcolor="#FFFFFF"> <input type="text" name="tel"> </tr> <tr> <td align="right" bgcolor="#FFFFFF">地 址:</td> <td bgcolor="#FFFFFF"> <input type="text" name="address"> </tr> <tr> <td align=right bgcolor="#FFFFFF" > <input type="submit" name="submit" value="注 冊"> </td> <td align=left bgcolor="#FFFFFF"> <input type="reset" name="submit" value="重 寫"> </td> </tr> </table> </form> </body> </html>