Hello i made a live website and when you try and login it gives me this error
Warning: mysqli_connect(): (HY000/1045): Access denied for user ‘root’@‘localhost’ (using password: NO) in C:\wamp\www\index.php on line 3
here is my code if you need it
[php]
<?php
// Connecting
$con = mysqli_connect('localhost','root','','prankvsprank');
// Testing Connection
if (mysqli_connect_errno()){
echo"Failed to connect" . mysqli_connect_error();
}
// Declairing Variables
$Username = @$_POST['Username'];
$Password = @$_POST['Password'];
$Submit = @$_POST['submit'];
// If Statements
if($Submit==TRUE){
if($Username==TRUE){
if($Password==TRUE){
$insert = mysqli_query($con, "INSERT INTO prankvsprank VALUES('','$Username','$Password')")or die("Couldnt insert data into database prankvsprank");
}else echo" Enter a password to continue";
}else echo"Enter a username to continue";
}
?>
<?php
//Login Script
$con = mysqli_connect('localhost', 'root', '', 'prankvsprank');
if (mysqli_connect_errno()) {
echo"Erry While Trying To Connect To Database" . mysqli_connect_error();
}
$Username = @$_POST['lUsername'];
$Password = @$_POST['lPassword'];
$submit = @$_POST['lsubmit'];
$logout = @$_POST['logout'];
if ($submit==TRUE) {
if ($Password==TRUE) {
if ($Username==TRUE) {
$li = "SELECT * FROM prankvsprank WHERE username = '$Username' AND password = '$Password' LIMIT 1";
$res = mysqli_query($con, $li);
if (mysqli_num_rows($res) == 1) {
session_start();
echo '
Hello, <?php echo "$lUsername"?>
';
if ($logout==TRUE) {
session_destroy();
}
}
}
}
}
?>
Register
body{background-color:black;}.registerform{position:absolute;top:20%;left:5%;}.loginform{position:absolute;top:40%;left:5%;}.box1{position:absolute;top:15%;left:25%;width:50%;height:100%;background-color:#F0FFFF;border-radius:15%;}
.line_1{width:7%;color:#F0FFFF;position:absolute;top:37%;left:1%;}.line_2{width:7%;color:#F0FFFF;position:absolute;top:37%;left:10%;}.OR{position:absolute;top:36.7%;left:8.5%;}.title1{position:absolute;top:3%;left:33%;}.introtitle{position:
absolute;top:18%;left:85%;}.introvid{position:absolute;top:25%;left:78%;}.hellouser{position:absolute;top:10%;left:30%;}.logoutbutton{position:absolute;top:36.6%;left:18%;}
Register
Username:
Password:
or
Login
Username:
Password:
PrankvsPrank
Intro
[/php]