Jump to content

Recommended Posts

Posted

My Issue: My form will not submit. It will just refresh login.php, whereas it should be posting to login_sub.php

was handling all the login with login.php, but decided to add that to a different page to further diagnose the problem.

 

I really dont understand why it wouldnt submit.

 

Im running these and some other functions on a few other pages right now, like inserting into mysql, and those work perfectly fine.

 

 

The code:

 

Includes on login.php

<?php include('lib/class_lib.php'); ?>
<?php
$session = new funcs();
$session->session();

$user_login = new funcs();
$user_login->login_submit();

$user_logout = new funcs();
$user_logout->logout();
?>

 

My login.php form

<form name="login" action="login_sub.php" method="POST">
<label>Username:</label>
<input name="uname" type="text" />
<br /><br />
<label>Password:</label>
<input name="pword" type="password" />
<br /><br />
<input name="submit" value="Log In" type="submit" />
</form>

 

the called functions. login_submit() is irrelivent atm because I have replaced calling that variable with just a straight forward action

function session() {
	if (!isset($_SESSION)) {
 			session_start();
	}	
}
function logout() {
	// ** Logout the current user. **
	$this->logout_link = $_SERVER['PHP_SELF']."?doLogout=true";
	if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
 			$this->logout_link .="&". htmlentities($_SERVER['QUERY_STRING']);
	}

	if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
			//to fully log out a visitor we need to clear the session varialbles
 			$_SESSION['MM_Username'] = NULL;
 			$_SESSION['MM_UserGroup'] = NULL;
 			$_SESSION['PrevUrl'] = NULL;
			unset($_SESSION['MM_Username']);
 			unset($_SESSION['MM_UserGroup']);
 			unset($_SESSION['PrevUrl']);

 			$this->logout_direct = "login.php";
 			if ($this->logout_direct) {
   			header("Location: $this->logout_direct");
  			exit;
 			}
	}
}

Posted

figured out my problem, but unsure how to fix it.

 

lies within this code.

 

login_rs is getting set properly, but the query from login_query is not outputting anything.

function login($post_user, $post_pass) {
       if (isset($_POST['uname'])) {
             $this->login_user = $post_user;
             $this->login_pass = $post_pass;
             $this->userAuthorization = "";
             $this->direct_success = "index.php";
             $this->direct_fail = "";
             $this->direct_refer = false;    

           $this->login_rs = "SELECT username, password FROM users WHERE username='$this->login_user' AND password='$this->login_pass'"; 

             $this->login_query = mysql_query($this->login_rs);
             $this->found_user = mysql_num_rows($this->login_query);
             if ($this->found_user) {
                $this->user_group = "";

               if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
                   //declare two session variables and assign them
                   $_SESSION['MM_Username'] = '$this->login_user';
                   $_SESSION['MM_UserGroup'] = '$this->user_group';          

               if (isset($_SESSION['PrevUrl']) && false) {
                     $this->direct_success = $_SESSION['PrevUrl'];    
               }
               header("Location: " . $this->direct_success );
             }
            else {
               header("Location: ". $this->direct_fail );
             }
       }
   }  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...