Rumah >pembangunan bahagian belakang >tutorial php >我的第二行php代码之接受get请求连接数据库实现登录验证
<?php $conn = mysql_connect("localhost","root","") or die("failed to connect db");mysql_select_db("lio", $conn) or die ("failed to select db");//mysql_query("SET NAMES 'UTF8'",$conn);$username=$_GET['user'];$passwd=$_GET['passwd'];$sql = "select * from userinfo where user='$username' and passwd='$passwd'";$Result = mysql_query($sql, $conn);$onerow = mysql_fetch_array($Result);if ($onerow ) echo "正确";else echo "错误";?>