1. 程式人生 > >php編碼登入介面

php編碼登入介面

html/css部分程式碼(王勁鬆   吳楊楊)

<meta http-equiv="Content-Type" content="text/html";charset="gbk">
 <form method="POST" action="second.php">
  使用者名稱:<input type="text" name="username"/><br/>
  密  碼:<input type="password" name="password"/><br/>
  驗證碼:<input type="text" name="code" size=5/>1234<br/>
  郵  件:<input type="text" name="email"/><br/>
  介  紹:<textarea row="6" cols="25" name="content"></textarea><br/>
  <input type="submit" value="提交" name="send"/>
  </form>
  

<?php
header('Content-Type:text/html;charset=gbk'); 
if(!isset($_POST['send'])){
	header('Location:first.php');
	exit;
}
$username=trim($_POST['username']);
$password=trim($_POST['password']);
$code=trim($_POST['code']);
$email=trim($_POST['email']);
$content=htmlspecialchars($_POST['content']);
if(strlen($username)<2 || strlen($username)>10){
	echo "<script>alert('使用者名稱不能小於兩位或者不能大於十位');history.back();</script>";
	exit;
}
if(strlen($password )<6 ){
	echo "<script>alert('密碼不能少於六位');history.back();</script>";
	exit;
}
if(strlen($code)!=4 || !is_numeric($code)){
	echo "<script>alert('驗證碼必須是四位並且是純數字');history.back();</script>";
	exit;
}
if(!preg_match('/([\w\.]{2,255})@([\w\-]{1,255}).([a-z]{2,4})/',$email)){
	echo  "<script>alert('電子郵件不合法');history.back();</script>";
	exit;
}
echo '使用者名稱:'.$username.'<br/>';
echo '介  紹:'.$content.'<br/>';
echo '郵  件:',$email.'<br/>'; 
?>