redirect - php file that runs and then directs to another file -


i trying create home page. once user comes site , inputs username , password data posted checklogin.php file verify data user entered. there way after checks data , redirects user page home page? want entire checklogin script not on home page. if user in different part of site, , click home, check login script run again , fail. understand can use session variables see if have logged in , somehow bypass checklogin script on home page if have logged in, correct way this?

<?php include'vive_fns.php';   $v_username = trim($_post['viveuser']);  $v_password = trim($_post['vivepass']);   if(!isset($_post['viveuser'])|| empty($v_username)){      echo"please enter username"; //should change redirect      die();  }   elseif(!isset ($v_username) || empty($v_username)) {      echo "please enter password"; //should change redirect      die();  }  //if data entered want check password      $mysqli = connect_db();  //set database query           $sql1 = "select password vive_user username = "."'$v_username'";   //check make sure result returned     if(!$result1 = $mysqli->query($sql1)){     echo 'could not query database. please try again later.';//should change redirect     die();     }      else {      $data = $result1->fetch_array(mysqli_num);      $db_pass = $data[0];     }      if($db_pass !== $v_password){        $title = 'incorrect login info';        //do_html_header($title); sets page title        echo"incorrect password";//should change redirect        die();    }  //if checks out need establish user info        $title = 'home';        do_html_header($title);          //echo"logged in";        session_start();        $_session['valid_user']=$v_username;  // @ point want redirect        header("location: home.php");        exit(); 

check out think under stand logic here first login page user can put login info

 <form action="reg_auth.php" method="post" accept-charset="utf-8">          <div id="inrlog" style="display:none;">          <div class="form-group required">          	<label for="userfirstname">email</label>              <input name="firstname" class="form-control" maxlength="255" type="text" id="userfirstname" required="required"/>          </div>          <div class="form-group required">          	<label for="userlastname">password</label>              <input name="lastname" class="form-control" maxlength="255" type="password" id="userlastname" required="required"/>          </div>          </div>                		 </div>  		  <div class="modal-footer">                         <p style="text-align:left;"></p><div class="submit"><input  class="btn btn-primary" title="login" name="login" type="submit" value="login"/></div><div style="display:none;"></div></form>

here authenticate page code user info authenticate

<?php   if($_post['login']){  		$email = $_post['email'];	  		$pwd   = $_post['pwd'];    		$m = mysql_fetch_assoc(mysql_query("select * `register` `email`='$email' , `pwd`='$pwd'"));  		if(!empty($m['email'])){    			if($m['status'] == 1){  				$_session['login'] 	   = $m['id'];  				$_session['displayaname'] = $m['fname'].' '.$m['lname'];  				header("location: myaccount.php");  			}else{  				header("location: reg_auth.php?msg=4");  			}  			exit();  		}else{  			unset($_session['login']);  			unset($_session['displayaname']);    			header("location: reg_auth.php?msg=3");  			exit();  		}  	}	  	      if($_get['msg'] == 2){  		$msg = "email exists! please try different email.";	  	}  	if($_get['msg'] == 3){  		$msg = "invalid username or password! please try again.";  	}  ?>


Comments