how to convert this old fastioned mysql statements to pdo?
<?php
error_reporting(0);
define("host","localhost");
define("user","root");
define("password","");
define("db","pass2");
$connect_db=mysql_connect(host,user,password) or die("cannot connect");
mysql_select_db(db, $connect_db);
$username=strtolower(addslashes($_POST['username']));
$password=strtolower(addslashes($_POST['password']));
$sql="SELECT * FROM users WHERE username='$username' AND password='$password'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
if($count==1 && $_POST['userlevel'] == "admin")
{
session_start();
$_SESSION['id']=$row['id'];
header("location: admin.php");
}
else if($count==1 && $_POST['userlevel'] == "managers")
{
header("location: managers.php");
}
else if($count==1 && $_POST['userlevel'] == "supervisors")
{
header("location: supervisors.php");
}
else if($count==1 && $_POST['userlevel'] == "users")
{
header("location: users.php");
}
else
{
echo "<body bgcolor='lightgreen'>";
echo "<br><br>";
echo "<h1> <center>Invalid User Name or Password</center> </h1><br/>";
echo "</body>";
}
?>
hope some one will solve this problem. thanks in advance.