<?php $host=\"localhost\"; $username=\"root\"; $password=\"root\"; $db_name=\"te
ID: 3615960 • Letter: #
Question
<?php
$host="localhost";
$username="root";
$password="root";
$db_name="test";
mysql_connect("$host", "$username","$password")or die("cannot connect"); ------------7
mysql_select_db("$db_name")ordie("cannot select DB");
$username=$_POST['username'];
$password=$_POST['password'];
$username =stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$flag="OK";
$msg="";
if(strlen($username) < 1){
$msg=$msg."Please enter the username<br>";
$flag="NOTOK";
}
if(strlen($password) < 1 ){
$msg=$msg."Please enter thepassword<br>";
$flag="NOTOK";
}
if($flag<>"OK"){
echo "<left>$msg <br> <inputtype='button' value='Retry'onClick='history.go(-1)'></left>";
}else{
$sql="SELECT * FROM users WHEREusername='$username' and password='$password'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("username");
session_register("password");
header("location:loginsuccess.php");
} else {
echo "Incorrect User Name ORPassword Found";
echo"<left><br><input type='button' value='Retry'onClick='history.go(-1)'></left>";
}
}
?>
Explanation / Answer
Are you sure your login details are correct? According tohttp://www.apachefriends.org/en/faq-xampp-linux.html#sicherer XAMPPthe default password is unset--meaning it is an empty string ratherthan root Try changing $password="root"; to $password="";
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.