저는 SQL과 PHP를 처음 접했습니다.PHP 로그인 스크립트 SQL 오류
간단한 로그인 스크립트를 작성하려고합니다. HTML 문서에 양식이 있는데 필요한 2 개의 변수에 올바른 데이터를 게시했지만 SQL이 실행될 때 스크립트가 실패합니다 ...
또한 mysqlWorkbench에서 SQL을 테스트했으며 내가 원하는 결과 ???
도와주세요.
<?PHP
$odbc = mysql_connect('localhost', 'root', '') or die ("could not connect to database");
mysql_select_db('examresults', $odbc) or die("Could not find database");
// username and password sent from form
$username=$_POST['username'];
$password=$_POST['password'];
$sql='SELECT * FROM tuser where username = '.$username.' and password = '.$password.'';
$result = mysql_query($sql, $odbc) or die ("Error in SQL");
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
//If result matched username and password, table row must only equal 1 row
if($count==1)
{
header("location:exammenu.php");
}
else
{
echo 'username and password do not match';
}
?>
새로운 기능이라면 mysql_connect를 사용하지 말고 (익숙한 경우) mysqli를 찾아 보시기 바랍니다. http://www.php.net/manual/en/function.mysql-connect.php – Lucas
mysql을 사용해야합니다. – Matt
어떤 오류가 발생합니까? – Lucas