here is my code. how can i fix it? the error message goes like this
"Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\test12345\db.php on line 6"
how can i make a login page without errors? im trying to make a website that has a secure login with session?. am i doing it right?
db.php
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "web";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Can't connect to database");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
login.php
<?php
include("db.php");
session_start();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from Form
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
$password = md5($password); // Encrypted Password
$sql = "SELECT id FROM admin WHERE username='$username' and passcode='$password'";
$result = mysql_query($sql);
$count = mysql_num_rows($result);
// If result matched $username and $password, table row must be 1 row
if ($count == 1) {
session_register("username");
$_SESSION['login_user'] = $username;
header("location: welcome.php");
} else {
$error = "Your Login Name or Password is invalid";
}
}
?>
<form action="login.php" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Login "/><br />
</form>