login.php:
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
header("Content-Type: text/html;charset=utf-8");
$conn =@mysql_connect("localhost","root","");
if(!$conn){
die("连接数据库失败:".mysql_connect());
}
if (empty($_POST['name']) || empty($_POST['password']) ) {
echo "不能为空";
}
else
{
echo $_POST['name'] ."登陆成功。 ";
}
register.php:
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$link=mysql_connect("localhost","root","");
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $link);
$sql="INSERT INTO test (name,password )
VALUES
('$_POST[name]','$_POST[password]')";
if (!mysql_query($sql,$link))
{
die('Error: ' . mysql_error());
}
else {
echo "注册成功,信息已录入。";
}
qq_大寒_2
茫海