Buongiorno a tutti,
Ho iniziato da pochissimo a lavorare con il linguaggio PHP e HTML, e già mi trovo davanti ad un problema che non so proprio come risolvere.
Il problema sta nel fatto che non mi viene riconosciuto il codice PHP del file "VerificaLog.php", dopo varie prove ho notato che appena uso il carattere ">" all'interno del codice php, il browser vede la parte di codice che parte da "<?php ....." a">" come un commento.
So che magari per alcuni di voi può sembrare una cosa semplice da risolvere, ma io proprio non ne riesco a venire a capo.
Grazie in anticipo!
index.html:
<!DOCTYPE html>
<html>
<head>
<title>LOGIN</title>
<meta charset="UTF-8">
<script src="verifica.js">
</script>
</head>
<body>
<h1>Inserire nome utente e password</h1>
<form name="dati_utente" method='POST' action='VerificaLog.php' onsubmit="return valida()">
<fieldset style="width:250px">
<legend>Accedi</legend>
user <input type="text" name="usr" id="usr"/><br/>
<br/>
password <input type="password" name="psw" id="psw"/><br/>
<br/>
<input type="submit" value="OK" id="OK" name="OK"/>
</fieldset>
</form>
</body>
</html>
verifica.js:
function valida(){
if( document.getElementById('psw').value.length<6){
alert("La password è errata");
return false;}
if( document.getElementById('usr').value.length==0){
alert("User name non corrisponde");
return false;}
else return true;
}
VerificaLog.php:
<!DOCTYPE html>
<html>
<head>
<title>ACCESSO</title>
</head>
<body>
ACCESSO:
<?php
$usr=$_POST['usr'];
$psw=$_POST['psw'];
$conn= mysql_connect("localhost", "root","");
if(!($conn)){print 'CONNESSIONE NON DISPONIBILE. <a "href=index.html" >HOME PAGE</a>'; }
else{
if(!(mysql_select_db("utenti",$conn))){
print "IMPOSSIBILE APRIRE IL DATABASE<br/>";
print "<a href='index.html' title='HOME' alt='HOME'>HOME PAGE</a>";}
else{
$sql="SELECT * FROM accesso WHERE pws='$psw' and username='$usr'";
$result=mysql_query($sql,$conn);
if(mysql_num_rows($result) > 0){
print "CONSENTITO";
}
else print "NEGATO";
print "<br/>";
print "<a href='index.html' title='HOME' alt='HOME'>HOME PAGE</a>";
}
}
?>
</body>
</html>