This is my current code in config.php:
mysql_connect("localhost","roof") or die(mysql_error());
mysql_select_db("tarclibrary") or die(mysql_error());
this is my current code in register.php:
require('config.php');
if(isset($_POST["submit"])){
//Perform the verification of the nation
$email1 =$_POST['email1'];
$email2 =$_POST['email2'];
$pass1 =$_POST['pass1'];
$pass2 =$_POST['pass2'];
if($email1 == $email2){
if($pass1 == $pass2){
//All good.carry on
$fname = mysql_real_escape_string($_POST['fname']);
$lname = mysql_real_escape_string($_POST['lname']);
$uname = mysql_real_escape_string($_POST['uname']);
$pass1 = mysql_real_escape_string($pass1);
$pass2 = mysql_real_escape_string($pass2);
$email1 = mysql_real_escape_string($email1);
$email2 = mysql_real_escape_string($email2);
$pass1= md5($pass1);
$sql = mysql_query("SELECT * FROM 'users' WHERE 'uname' = '$uname'");
if(mysql_num_rows($sql) > 0){
echo "Sorry, that user already exits";
exit();
}
mysql_select_db('library') or die(mysql_error());
mysql_query("INSERT INTO users (id, fname, lname, uname, pass, email) VALUES (NULL, '$fname', '$lname', '$uname'. '$pass1', '$email1')") or die (mysql_error());
}else{
echo "sorry,your passwords do not match.<br/>";
exit();
}
}else{
echo "sorry your email's do not match<br/><br/>";
}
}else{
$form = <<<EOT
<h1><center>Register</center></h1>
<br>
<form action="register.php" method="post">
<table class="t1" align="center" width="600" height="400">
<tr>
<th scope="row">First name</th>
<td><input type="text" name="fname" required type="text"/></td>
</tr>
<tr>
<th scope="row">Last name</th>
<td><input type="text" name="lname" required type="text"/></td>
</tr>
<tr>
<th scope="row">Username</th>
<td><input type="text" name="uname" required type="text"/></td>
</tr>
<tr>
<th scope="row">Password</th>
<td><input type="password" name="pass1" required type="text" /></td>
</tr>
<tr>
<th scope="row">Confirm Password</th>
<td><input type="password" name="pass2" required type="text"/></td>
</tr>
<tr>
<th scope="row">Email</th>
<td><input type="text" name="email1" required type="text"/></td>
</tr>
<tr>
<th scope="row">Confirm Email</th>
<td><input type="text" name="email2" required type="text"/></td>
</tr>
</table>
<input id="register" type="submit" value="Register" name="submit"/>
</form>
EOT;
echo $form;
}
when I submit my register the output is:
Access denied for user ''@'localhost' to database 'library'
someone help pls , why is this happened??