① php+SQLserver製作一個簡單的登錄功能。
<!-- content starts -->
<?php
if(isset($_POST['add']))
{
date_default_timezone_set('Etc/GMT-8');
$txtname=$_POST['username'];
$txpassword=$_POST['userpwd'];
$txtvalue=$_POST['quxnain'];
$sqlstr = "select * from T1_user where name='".$txtname."'and password=".$txpassword.";";
$conn = mysql_connect("192.168.0.3","root","root");//此處替換用戶名和密碼
if (!$conn)
{
die('Could not connect: ' . mysql_error());
}
$result = mysql_query($sqlstr);
$rs=mysql_fetch_array($result);
if($rs)
{
echo "<script>alert('登錄成功!')</script>";
if($txtvalue==1)
echo "<meta http-equiv=refresh content='0;url=../face.php'>";
else
echo "<meta http-equiv=refresh content='0;url=welcome.htm'>";
}
else
echo "<script>alert('用戶名或密碼錯誤!')</script>";
}
?>
<body>
<div id="Layer1" style="position:absolute; width:100%; height:100%; z-index:-1">
<img src="images/真煩人.gif" height="100%" width="100%"></img>>
</div>
<div style='height=100'></div>
<form name="form1" method="post" enctype="multipart/form-data" action="" onSubmit="return check()">
<div style="background-image:url(images/登錄小窗口.jpg);margin-left:150px;margin-top:140px;width:542px;height:220px">
<table width="449" height="139" style="margin-left:50px;margin-top:55px;">
<tr>
<td width="187">用戶名: <input name=username type=text class=radio0 size=19></td>
<td width="30" style="width:70px;"></td>
<td width="216"><button name="add" type="submit" style="background-image:url('images/登陸按鈕.jpg');width:210px;height:43px"></button></td>
</tr>
<tr></tr>
<tr>
<td>密 碼:<input name=userpwd type=password class=radio0 size=20></td>
<td></td>
<td></td>
</tr>
<tr>
<td >權 限:<select name="quxnain" style="width:90px">
<option value="1">用戶</option>
<option value="2">管理員</option>
</select></td>
<td></td>
<td><button type="reset" style="background-image:url('images/注冊按鈕.jpg');width:210px;height:43px" onClick="location='register.php'"></button></td>
</tr>
</table>
</div>
</form>
</body>
</html>
拿走用吧