Parašė WhiZz· 2014 Bal. 23 17:04:51
#1
Sveiki.
Norėčiau jūsų paklausti gal kas nors turite ideja kaip reiketu padaryti permetima i prisijungimo puslapi, jeigu prisijungimo forma rodoma modulyje?
Stai mano kodas:
<?php
include('config.php');
echo '<form method="post">';
echo 'El. Pastas<br>';
echo '<input type="email" name="email"><br>';
echo 'Slaptazodis<br>';
echo '<input type="password" name="password1"><br>';
echo '<input type="submit" name="jungtis" value="Prisijungti"><br>';
echo '</form>';
//Pradedam session
session_start();
//Array talpinam error tikrinimus
$errmsg_arr = array();
//tikrinam error flag
$errflag = false;
//Sanitize irasymus
$a = $_POST['username'];
$password = $_POST['password1'];
//Tikrinam
/*if($login == '') {
$errmsg_arr[] = 'Kur el.pastas?';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Kur slaptazodis?';
$errflag = true;
}
//Jei tikrinam teigiama, graziname i forma
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}*/
//Sukurti query
$qry="SELECT * FROM members WHERE email = '$a' AND password = '$password'";
$result=mysql_query($qry);
echo $qry;
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) > 0) {
//Login Successful
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['id'];
$_SESSION['SESS_FIRST_NAME'] = $member['fname'];
header("location: lol.php");
exit();
}else {
//Blogas prisijungimas
header("location: index.php");
exit();
}
}else {
die("Query klaidingas");
}
?>