mysql - User Logging in getting redirected to index.php -
mysql - User Logging in getting redirected to index.php -
note: first using php, html, css, mysql (database), using dreamweaver 6 edit code in.
ok, final year project creating e-attendance tracking , monitoring system. having great difficulties creating logins multiple users. 3 users scheme staff, parents & students. this, focusing on staff
ok have...
staff_register.php staff_verify.php staff_login.php staff_home.phpso when staff wants sign must register first. have form when submitted writes database perfectly. student_register.php posts student_verify.php, in activation email gets sent user requiring them verify (click on link). 1 time user verifys, become active user. proceed log in page. when user enters details, redirected index.php in code state redirected staff_home.php below going provide code:
this staff_login.php:
<?php include_once("scripts/global.php"); $message = ''; ` `if(isset($_post['email'])){ $email = $_post['email']; $pass = $_post['pass']; $remember = $_post['remember']; ` //error handeling if( (!$email) || (!$pass) ){ $message = 'please insert both fields'; }else{ //secure info $email = mysql_real_escape_string($email); $pass = sha1($pass); $query = mysql_query("select * staff email='$email' , password='$pass' limit 1") or die("could not check member"); $count_query = mysql_num_rows($query); if($count_query == 0){ $message = 'the infomation entered incorrect'; }else{ //start sessions $_session['pass'] = $pass; while($row = mysql_fetch_array($query)){ $username = $row['username']; $id = $row['id']; } $_session['username'] = $username; $_session['id'] = $id; if($remember == "yes"){ //create cookies setcookie("id_cookie", $id, time()+60*60*24*100, "/"); setcookie("pass_cookie", $pass, time()+60*60*24*100, "/"); } header("location: staff_home.php"); } }
the php script index.php
<?php include_once("scripts/global.php"); if ($logged == 1) { header("location: staff_home.php"); exit; } ?>
i set staff_home.php in index because kept getting redirected index.php set code @ top in hope redirects me staff_home.php
the php script staff_home.php
<?php include_once("scripts/global.php"); if ($logged == 0) { header("location:staff_home.php"); exit(); } ?>
i suspect maybe have assign users roles, have not done.
so want staff login , redirected staff_home.php , pupil login , redirected student_home , parents login , redirected parent_home.
i been trying practise php few months, littlest of errors bug me lol. praying can help me ! might seem minor error(s) foreever greatful tips , advice on how improve code , function. check see if responds, , email jmudhar90@hotmail.co.uk.
regards people
i don't see session_start()
in code @ point. need phone call session_start()
before can utilize sessions in page.
php mysql redirect login
Comments
Post a Comment