I'm trying to learn PHP & MYSQL, I done this code, it seems to work but I've a lot of "warnings", I don't know what they mean, anyway php connects to the db . Here the codes :
myPgae.php the "main" page
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href='http://localhost/prove/librerie/bootstrap/css/bootstrap.css'></script>
<script type="text/javascript" src='http://localhost/prove/librerie/angular.min.js'></script>
<script type="text/javascript" src='http://localhost/prove/librerie/bootstrap/js/bootstrap.min.js'></script>
<body>
<form action="procces.php" method="POST">
<div class="text-info identazione" class="identazione">Username : </div><input lass="form-control" type="text" name="username"/>
<div class="text-info identazione">Password : </div><input type="text" name="password"/>
<div class="identazione"><input class=" btn btn-success" type="submit"/></div>
</form>
</body>
</head>
<style>
body {
padding : 50px;
}
.identazione{
padding: 12px;
}
</style>
process.php
<?php
//da myPage a variabili locale
$username = $_POST['username'];
$password = $_POST['password'];
//per prevenire mysql injection
$username= stripcslashes($username);
$password= stripcslashes($password);
$username= mysql_real_escape_string($username);
$password= mysql_real_escape_string($password);
//connessione al server e selezione database
mysql_connect("localhost","root","");
mysql_select_db("login");
//query al database per utente
$risultato= mysql_query("select * from utenti where username = '$username' and password = '$password' ") or die("Utente non trovato, verificare le credenziali".mysql_error());
$riga = mysql_fetch_array($result);
if($riga['username']==$username && $riga['password']==$password){
echo "Login effettuato. Benvenuto".$riga['username'];
}
else
echo "Login errato. Reinserisci i dati";
?>
Here's the proof of warnings
Also,if it can help you, I'm working on Chrome and use Wampp. I wrote in italian coments I hope that isn't a problem anyway I have create the db it's name is : login, defined with username, password and id. I've creata a usertest and userpass, and they work if I try to put in the login, but with the same errors
UPDATE:
I change result in risutato, that's my error and now just two warning, anyway I have to update my knowlage, I'm working on outdate sources