下面是全部代码:
<?
$conn=mysql_connect("localhost","root","m1nnnnnm") or die("无法连接mysql".mysql_error());
mysql_select_db("db2",$conn) or die("无法连接mysql".mysql_error());
/*if($Submit3){
SetCookie("username", "");
SetCookie("userpass", "");
}*/
if($Submit){
//$name=$_POST['textfield'];
//$pass=$_POST['textfield2'];
/*if(empty($textfield)||empty($textfield2)){
echo("null");
echo "<META HTTP-EQUIV=REFRESH CONTENT='1;URL=user.php'>";
exit();
}*/
$sql="select * from user where name='$textfield' and passw='$textfield2'";
$query=mysql_query($sql,$conn) or die("无法1".mysql_error());
$result=mysql_fetch_array($query);
if(!empty($result)){
setcookie("username","aaa");
setcookie("userpass","bbb");
echo $HTTP_COOKIE_VARS["username"];
echo($userpass);
echo($result[name]);
}
else{
echo("用户名或密码错误");
echo "<META HTTP-EQUIV=REFRESH CONTENT='1;URL=user.php'>";
exit();
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<table width="700" border="1">
<tr>
<th scope="col">name</th>
<th scope="col">pass</th>
</tr>
<tr>
<td colspan="2">
<table width="700" border="1">
<?
//if($username&&$userpass){
if($Submit){
echo $HTTP_COOKIE_VARS["username"]; ?>
<form name="form2" method="post" action="<?php echo $PHP_SELF ?>">
<tr>
<td><label>
<input name="textfield3" type="text" value="<? echo($username); ?>">
</label>
</td>
<td>
<label>
<input name="textfield4" type="text" value="<? echo($userpass); ?>">
</label></td>
<td><label>
<input type="submit" name="Submit3" value="删除">
</label></td>
</tr>
</form>
<?
}
else{
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<tr>
<th scope="col"><label>
<input type="text" name="textfield">
</label></th>
<th scope="col"><label>
<input type="text" name="textfield2">
</label></th>
</tr>
<tr>
<td><label>
<input type="submit" name="Submit" value="提交">
</label></td>
<td><label>
<input type="reset" name="Submit2" value="重置">
</label></td>
</tr>
</form>
<?
}
?>
</table>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<?
$conn=mysql_connect("localhost","root","m1nnnnnm") or die("无法连接mysql".mysql_error());
mysql_select_db("db2",$conn) or die("无法连接mysql".mysql_error());
/*if($Submit3){
SetCookie("username", "");
SetCookie("userpass", "");
}*/
if($Submit){
//$name=$_POST['textfield'];
//$pass=$_POST['textfield2'];
/*if(empty($textfield)||empty($textfield2)){
echo("null");
echo "<META HTTP-EQUIV=REFRESH CONTENT='1;URL=user.php'>";
exit();
}*/
$sql="select * from user where name='$textfield' and passw='$textfield2'";
$query=mysql_query($sql,$conn) or die("无法1".mysql_error());
$result=mysql_fetch_array($query);
if(!empty($result)){
setcookie("username","aaa");
setcookie("userpass","bbb");
echo $HTTP_COOKIE_VARS["username"];
echo($userpass);
echo($result[name]);
}
else{
echo("用户名或密码错误");
echo "<META HTTP-EQUIV=REFRESH CONTENT='1;URL=user.php'>";
exit();
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<table width="700" border="1">
<tr>
<th scope="col">name</th>
<th scope="col">pass</th>
</tr>
<tr>
<td colspan="2">
<table width="700" border="1">
<?
//if($username&&$userpass){
if($Submit){
echo $HTTP_COOKIE_VARS["username"]; ?>
<form name="form2" method="post" action="<?php echo $PHP_SELF ?>">
<tr>
<td><label>
<input name="textfield3" type="text" value="<? echo($username); ?>">
</label>
</td>
<td>
<label>
<input name="textfield4" type="text" value="<? echo($userpass); ?>">
</label></td>
<td><label>
<input type="submit" name="Submit3" value="删除">
</label></td>
</tr>
</form>
<?
}
else{
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF ?>">
<tr>
<th scope="col"><label>
<input type="text" name="textfield">
</label></th>
<th scope="col"><label>
<input type="text" name="textfield2">
</label></th>
</tr>
<tr>
<td><label>
<input type="submit" name="Submit" value="提交">
</label></td>
<td><label>
<input type="reset" name="Submit2" value="重置">
</label></td>
</tr>
</form>
<?
}
?>
</table>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
解决方案 »
- $_SESSION变量释放问题
- 请问有什么做项目规划的软件推荐的?
- 用php开发wap2.0的基本格式是什么?
- 有啥方法及软件可以编辑JS
- 关于PHP4和PHP5时间比较问题
- PHP基础题目
- php 再求一正则表达式
- 谁发一个最新的PHP的开发环境给我.Windows2000下的
- php的搜索问题
- Notice: Undefined index: wdbadminid in e:\program files\apache group\apache\htdocs\wdb\adminglobal.php on line 8 请问这个错误是
- form的action不能正确提交
- sesion问题 请教
是不是我的方法不正确,应该如何做?