<
!
--function.php--
>
<?php
error_reporting(0);
class Con_sqlite
{
function get_SQLite_Connection()
{
$db=new SQLiteDatabase('sqlitedb');
$sql="create table talk (userid integer primary key not null,username varchar(50) not null,pwd varchar(10) not null)";
$db->query($sql);
return $db;
}
}
?>
<?php
error_reporting(0);
class Con_sqlite
{
function get_SQLite_Connection()
{
$db=new SQLiteDatabase('sqlitedb');
$sql="create table talk (userid integer primary key not null,username varchar(50) not null,pwd varchar(10) not null)";
$db->query($sql);
return $db;
}
}
?>
2.gin.php
<
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >登录Demo </title>
</head>
< body >
< form action ="main.php" name ="frm" method ="post" >
< table align ="center" bordercolor ="#99CC66" border ="1" >
< tr > < td >用户名 </td> < td > < input type ="text" name ="username" border ="1" /> </td> </tr>
< tr > < td >密码 </td> < td > < input type ="password" name ="password" border ="1" /> </td> </tr>
< tr >
< td > < a href ="reg.html" >注册新用户 </a> </td>
< td colspan ="2" align ="right" > < input type ="submit" name ="sub" value ="登录" /> </td>
</tr>
</table>
</form>
</body>
</html>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >登录Demo </title>
</head>
< body >
< form action ="main.php" name ="frm" method ="post" >
< table align ="center" bordercolor ="#99CC66" border ="1" >
< tr > < td >用户名 </td> < td > < input type ="text" name ="username" border ="1" /> </td> </tr>
< tr > < td >密码 </td> < td > < input type ="password" name ="password" border ="1" /> </td> </tr>
< tr >
< td > < a href ="reg.html" >注册新用户 </a> </td>
< td colspan ="2" align ="right" > < input type ="submit" name ="sub" value ="登录" /> </td>
</tr>
</table>
</form>
</body>
</html>
3. main.php
<
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >主页 </title>
</head>
<?php
include_once("function.php");
$log_name=$_POST['username'];
$log_pwd=$_POST['password'];
$con_sqlite=new Con_sqlite;
$db=$con_sqlite->get_SQLite_Connection();
$check_sql="select * from talk where username='$log_name' and pwd='$log_pwd' ";
$result=$db->query($check_sql);
$row=$result->fetch(SQLITE_ASSOC);
if($row)
{
echo "欢迎".$log_name;
/*echo "---id---".$row['userid']."---用户名---".$row['username']." < br >"."---密码----".$row['pwd'];
$row=$result->fetch(SQLITE_ASSOC);*/
}else
{
echo " < script >window.history.go(-1); </script>";
}
/*$userName=$_REQUEST['username'];
$password=$_POST["password"];
echo $userName;*/
?>
< body >
</body>
</html>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >主页 </title>
</head>
<?php
include_once("function.php");
$log_name=$_POST['username'];
$log_pwd=$_POST['password'];
$con_sqlite=new Con_sqlite;
$db=$con_sqlite->get_SQLite_Connection();
$check_sql="select * from talk where username='$log_name' and pwd='$log_pwd' ";
$result=$db->query($check_sql);
$row=$result->fetch(SQLITE_ASSOC);
if($row)
{
echo "欢迎".$log_name;
/*echo "---id---".$row['userid']."---用户名---".$row['username']." < br >"."---密码----".$row['pwd'];
$row=$result->fetch(SQLITE_ASSOC);*/
}else
{
echo " < script >window.history.go(-1); </script>";
}
/*$userName=$_REQUEST['username'];
$password=$_POST["password"];
echo $userName;*/
?>
< body >
</body>
</html>
4. reg.php
<
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >用户注册 </title>
</head>
< body >
< form action ="reg_result.php" name ="frm_reg" method ="post" >
< table border ="1" >
< tr >
< td >用户名 < input type ="text" name ="reg_name" />
</td>
</tr>
< tr >
< td >密码 < input type ="password" name ="reg_pwd" />
</td>
</tr>
< tr >
< td > < input type ="submit" name ="reg_submit" value ="注册" />
</td>
</tr>
</table>
</form>
</body>
</html>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >用户注册 </title>
</head>
< body >
< form action ="reg_result.php" name ="frm_reg" method ="post" >
< table border ="1" >
< tr >
< td >用户名 < input type ="text" name ="reg_name" />
</td>
</tr>
< tr >
< td >密码 < input type ="password" name ="reg_pwd" />
</td>
</tr>
< tr >
< td > < input type ="submit" name ="reg_submit" value ="注册" />
</td>
</tr>
</table>
</form>
</body>
</html>
5.reg_result.php
<
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >Reg_result </title>
</head>
<?php
include_once("function.php");
$db_sqlite=new Con_sqlite;
$db=$db_sqlite->get_SQLite_Connection();
$reg_name=$_POST['reg_name'];
$reg_pwd=$_POST['reg_pwd'];
$sql_insert="insert into talk (username,pwd) values ('$reg_name','$reg_pwd')";
$result=$db->query($sql_insert);
if($result!=null)
{
echo '注册成功!';
}
?>
< body >
< a href ="login.html" >返回登录窗口 </a>
</body>
</html>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >Reg_result </title>
</head>
<?php
include_once("function.php");
$db_sqlite=new Con_sqlite;
$db=$db_sqlite->get_SQLite_Connection();
$reg_name=$_POST['reg_name'];
$reg_pwd=$_POST['reg_pwd'];
$sql_insert="insert into talk (username,pwd) values ('$reg_name','$reg_pwd')";
$result=$db->query($sql_insert);
if($result!=null)
{
echo '注册成功!';
}
?>
< body >
< a href ="login.html" >返回登录窗口 </a>
</body>
</html>
转载于:https://blog.51cto.com/yardan/69616