<?php
$mysql_conf = array(
'host' => 'localhost',
'db' => 'zhijin',
'db_user' => 'root',
'db_pwd' => '',
);
$mysql_conn = @mysql_connect($mysql_conf['host'], $mysql_conf['db_user'], $mysql_conf['db_pwd']);
if (!$mysql_conn) {
die("could not connect to the database:
" . mysql_error());//诊断连接错误
}
mysql_query("set names 'utf8'");//编码转化
$select_db = mysql_select_db($mysql_conf['db']);
if (!$select_db) {
die("could not connect to the db:
" . mysql_error());
}
$sql = "select * from article;";
$res = mysql_query($sql);
if (!$res) {
die("could get the res:
" . mysql_error());
}
while ($row = mysql_fetch_assoc($res)) {
// print_r($row);
}
// var_dump($_POST);
$username = $_POST['username'];
$password = $_POST['pwd'];
$sql = "select * from admin where username='$username' and password = '$password'";
$str = mysql_query($sql);
$str = mysql_fetch_row($str);
if(empty($str)){
$url = 'http://localhost/index.html';
echo "<script type='text/javascript'>window.location.href='$url';alert('账号或密码输入错误')</script>";
// alert(账号或密码输入错误);
}else{
var_dump($str);
}
?>