Problema php script logare
Scris: Dum Oct 15, 2017
Salut!
Nu gasesc greseala al acestui cod ce l-am facut ...
fisierul logare.php arata cam asa
Dau pe butonul de intra si nu afiseaza nici macar eroare ca nu am scris nimic in campurile de nume si parola ... pur si simplu se da un fel de refresh la popup-ul ce imi afiseaza formularul de logare ...
Nu gasesc greseala al acestui cod ce l-am facut ...
fisierul logare.php arata cam asa
Cod: Selectaţi tot
<?php session_start(); include('../conectare.php');
if(isset($_GET['login']) OR isset($_GET['logout']))
{
$login = $_GET['login'];
$logout = $_GET['logout'];
}
// daca se logheaza //
if(isset($login))
{
$n = $_POST['nume'];
$nume = strtolower($n);
$parola = $_POST['parola'];
$pass = md5($parola);
if(strlen($_POST['nume']) < 3)
{
echo ' <div style="font-weight:bold;color:red;">
<img src="/imagini/meniu-sus/stare-error.png"> Numele de utilizator trebuie sa fie de minim 3 caractere!
</div>';
}
else if(strlen($_POST['parola']) < 6)
{
echo ' <div style="font-weight:bold;color:red;">
<img src="/imagini/meniu-sus/stare-error.png"> Parola trebuie sa fie de minim 6 caractere!
</div> ';
}
else {
$login = "SELECT * FROM `membri` WHERE `nume` = '$nume' AND `parola` = '$pass' LIMIT 1";
$conectlogin = $dbh->query($login);
$logare = $conectlogin->fetch(PDO::FETCH_ASSOC);
if($logare == true)
{
$_SESSION['authorized'] = true;
$_SESSION['id'] = $logare['id'];
$_SESSION['nume'] = strtolower($nume);
$_SESSION['parola'] = strtolower($pass);
$ipvisit = $_SERVER['REMOTE_ADDR'];
setlocale(LC_TIME, array('ro.utf-8', 'ro_RO.UTF-8', 'ro_RO.utf-8', 'ro', 'ro_RO', 'ro_RO.ISO8859-2'));
date_default_timezone_set('Europe/Bucharest');
$dtvisit = strftime('%d %B %Y ora %H:%M:%S');
$on = time() + '60';
$onlineuserlogin = $dbh->query("UPDATE membri SET online='$on', ipvisit='$ipvisit', dtvisit='$dtvisit' WHERE id='$_SESSION[id]'");
?>
<script type="text/javascript"><!--
var adress = $('#adress').val();
parent.window.location.href=''+adress+'';
--></script>
<?php }
else
{
echo '<div style="font-weight:bold;color:red;">
<img src="/imagini/meniu-sus/stare-error.png"> Numele de utilizator sau parola sunt incorecte!
</div>';
}
}
}
// daca se delogheaza //
else if(isset($logout))
{
session_start();
include("../conectare.php");
// sterge online //
$nn = $_SESSION['nume'];
$nume = strtolower($nn);
$deleteon = $dbh->query("UPDATE membri SET online='2' WHERE nume='$nume'");
// sterge online //
session_start();
session_destroy();
header("Location: /index.php");
exit;
}
// daca e accesata adresa simpla //
else
{ ?>
<link rel="stylesheet" type="text/css" href="/css.css" />
<div style="padding-top:20px;color: green;text-align: center;font-weight: bold;">
<img src="/imagini/meniu-sus/succes.png" width="50" height="50">
Conecteaza-te cu noi SAU <a href="/inregistrare.php" class="register">Inscrie-te </a>!!!
<img src="/imagini/meniu-sus/succes.png" width="50" height="50">
</div>
<center>
<div id="login_box">
<div class="logare">Intrare</div>
<div class="inregistrare"><a href="/inregistrare.php" class="register">Inscrie-ma !</a></div>
<div class="form">
<form method="post">
<p><font color="blue"><b>Nume Utilizator</b></font></p>
<p>
<input class="textbox" name="nume" id="nume" size="23" type="text">
</p>
<p><font color="blue"><b>Parola</b></font></p>
<p>
<input class="textbox" name="parola" id="parola" size="23" type="password">
</p>
<p><a href="/recuperare-parola.php">Ai uitat parola?</a></p>
<p>
<input type="submit" class="logarepesite" name="submit" id="logare" value="">
</p>
</div>
</form>
</div>
<div id="resp"></div>
</center>
<script type="text/javascript" src="js.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
$('.logare').submit(function() {
var name = $(this).find('input[name="nume"]');
var parola = $(this).find('input[name="parola"]');
$('*').removeClass('error');
var error = 0;
if(error==0) {
var srl = $(this).serialize();
$.ajax({
type: 'post',
url: 'login.php',
data: srl,
beforeSend: function() {
$('#resp').html('<img src="/imagini/stare-loading.gif"><font color="orange"><b> Te rugam asteapta!</b></font>');
},
timeout: 10000,
error: function(xhr, status, error) { alert('Eroare: '+ xhr.status+ ' - '+ error); }, // afiseaza Alert cu eroare
success: function(raspuns) {
$('#resp').html(raspuns);
}
});
}
return false;
});
});
function close_popup() {
(new popWindow().close());
}
function open_popup(uri,wi,he) {
close_popup();
(new popWindow({iframeUrl:uri}).open());
}
//--></script>
<?php }
?>