使用php来查询数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

<?php
include("config.php");
$username = $_GET['username'];
$con = mysql_connect(MYSQL_IP.':'.MYSQL_PORT,MYSQL_USER,MYSQL_PSWD);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}else
{
mysql_select_db("ypw", $con);
mysql_query("SET NAMES UTF8");
$result = mysql_query("SELECT * FROM `users` WHERE `username` = '$username';");
$row = mysql_fetch_array($result);
echo $row['password'];
mysql_close($con);
}
?>

http://xxx.com/login.php?username=ypw