6 Replies - 1757 Views - Last Post: 13 July 2003 - 03:50 PM Rate Topic: -----

#1 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Login Varible Problems

Posted 13 July 2003 - 12:09 AM

hey long time no see guys, i havent coded in so long. im alittle rusty right now. im having alittle bit of a problem. i made a simple database 1 table with 4 fields, id,username,pass,content. i got it so when the user put in the right username and pass they make to the page where then can veiw/edit the content. but i i need it to be when the login redirects them, it brings them to something like loggedin.php?username=

i cant remember how to do this. like i said i havent coded in forever. this is my code now.
<?php require_once('Connections/conn.php'); ?> 
<?php
mysql_select_db($database_conn, $conn);
$query_a = "SELECT * FROM profile";
$a = mysql_query($query_a, $conn) or die(mysql_error());
$row_a = mysql_fetch_assoc($a);
$totalRows_a = mysql_num_rows($a);

// *** Start the session
session_start();
// *** Validate request to log in to this site.
$FF_LoginAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING']!="") $FF_LoginAction .= "?".$HTTP_SERVER_VARS['QUERY_STRING'];
if (isset($HTTP_POST_VARS['username'])) {
  $FF_valUsername=$HTTP_POST_VARS['username'];
  $FF_valPassword=$HTTP_POST_VARS['pass'];
  $FF_fldUserAuthorization="";
  $FF_redirectLoginSuccess="loginedin.php"; $FF_redirectLoginFailed="index.php"; $FF_rsUser_Source="SELECT username, pass 
"; if ($FF_fldUserAuthorization != "") $FF_rsUser_Source .= "," . $FF_fldUserAuthorization; 
$FF_rsUser_Source .= " FROM profile WHERE username='" . $FF_valUsername . "' AND 
pass='" . $FF_valPassword . "'"; mysql_select_db($database_conn, $conn); $FF_rsUser=mysql_query($FF_rsUser_Source, 
$conn) or die(mysql_error()); $row_FF_rsUser = mysql_fetch_assoc($FF_rsUser); 
if(mysql_num_rows($FF_rsUser) > 0) { // username and password match - this is 
a valid user $MM_Username=$FF_valUsername; session_register("MM_Username"); if 
($FF_fldUserAuthorization != "") { $MM_UserAuthorization=$row_FF_rsUser[$FF_fldUserAuthorization]; 
} else { $MM_UserAuthorization=""; } session_register("MM_UserAuthorization"); 
if (isset($accessdenied) && false) { $FF_redirectLoginSuccess = $accessdenied; 
} mysql_free_result($FF_rsUser); session_register("FF_login_failed"); $FF_login_failed 
= false; header ("Location: $FF_redirectLoginSuccess"); exit; } mysql_free_result($FF_rsUser); 
session_register("FF_login_failed"); $FF_login_failed = true; header ("Location: 
$FF_redirectLoginFailed"); exit; } ?> 
<html>
<head>
<title>Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#CCCCCC">
<table width="95%" border="1" align="center" cellpadding="3" bordercolor="#000000">
  <tr>
    <td bgcolor="#003366"><strong><font color="#FF9900">welcome to the script i made just for you</font></strong></td>
  </tr>
  <tr>
    <td>LOGIN: 
      <form name="form1" method="POST" action="<?php echo $FF_LoginAction?>">
        username : 
        <input name="username" type="text" id="username">
        <br>
        password: 
        <input name="pass" type="password" id="pass">
        <br>
        <input type="submit" name="Submit" value="Submit">
        <input type="reset" name="Submit2" value="Reset">
      </form>
   not a member yet? <a href="register.php">register</a></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($a);
?>



Is This A Good Question/Topic? 0
  • +

Replies To: Login Varible Problems

#2 Unimagined  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 95
  • Joined: 06-September 02

Re: Login Varible Problems

Posted 13 July 2003 - 04:25 AM

Why don't you take the login php code and put it in a seperate php file. Then have the form's action use that file. After the php login processor does what it does make it redirect the user that's logged in to another page called loggedin.php and pass the username variable along to it?

http://www.website.c...na...=$username

Or did you want the actual code, and all this read retarded?
Was This Post Helpful? 0
  • +
  • -

#3 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: Login Varible Problems

Posted 13 July 2003 - 07:32 AM

see when i try to redirect it with the uservarible in it i get a phase error. redirecting it is simple look this code right here does it.
$FF_redirectLoginSuccess="loginedin.php"; $FF_redirectLoginFailed="index.php";

but once i add the varible it gets all fucked up.
Was This Post Helpful? 0
  • +
  • -

#4 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Login Varible Problems

Posted 13 July 2003 - 08:06 AM

why do you need the querystring? just store the id in the session variable and pull it out wherever you need it....
Was This Post Helpful? 0
  • +
  • -

#5 iamcenz  Icon User is offline

  • You wish you were my hand!
  • member icon

Reputation: 7
  • View blog
  • Posts: 2,442
  • Joined: 26-March 01

Re: Login Varible Problems

Posted 13 July 2003 - 12:46 PM

huh?

i never said i was good at php.... want to explain.
Was This Post Helpful? 0
  • +
  • -

#6 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: Login Varible Problems

Posted 13 July 2003 - 03:44 PM

My login script:


<?
include_once("/home/..../public_html/configfile.php");

$logpass = "$password";
$sql = "SELECT * FROM clients WHERE username='$username'";
$db = mysql_select_db("$dbName", $connection) or die("Couldnt select DB");
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");
while ($row = mysql_fetch_array($sql_result))
       { extract($row);
    
       }

// CHECK IF THE ACCOUNT IS ACTIVE YET   

        if ($verifiedd != "1") {
header("Location: /errors/notactive.php");
}

// LOOK FOR A ROW IN THE USERS TABLE THAT MATCHES THE LOGIN ENTRY
$sql = "SELECT * FROM clients WHERE username='$username' AND password='$logpass'";
$db = mysql_select_db("$dbName", $connection) or die("Couldnt select DB");
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");
$found = mysql_num_rows($sql_result);

// IF NO MATCHES ARE FOUND SEND THEM TO A INVALID ACCOUNT PAGE
if ($found == "0") {
header("Location: /errors/invalidaccount.php");
} else {


// IF MATCH IS FOUND UPDATE ROW FOR LATEST LOGIN AND IP
 $userHost = gethostbyaddr ("$REMOTE_ADDR");
 $today = date("F j, Y, g:i a");
 $sql = "UPDATE clients SET LastLogin='$REMOTE_ADDR', LastDate='$today' WHERE username='$username'";
 $db = mysql_select_db("$dbName", $connection) or die("Couldnt select DB");
 $sql_result = mysql_query($sql, $connection) or die("Couldnt ssexec Query");


// SET COOKIE
setcookie ("ss", "$username|$password", time()+$cookieTime, "/");

// IF USER ROW HAS "1" IN THE "ISADMIN" FIELD, SEND THEM TO THE ADMINISTRATIVE SECTION
if ($isadmin == "1"){ header("Location: /admin/"); } else { header("Location: /account/"); }
}
}
?>

This post has been edited by Quik: 13 July 2003 - 03:47 PM

Was This Post Helpful? 0
  • +
  • -

#7 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: Login Varible Problems

Posted 13 July 2003 - 03:50 PM

the script i INCLUDE on any page that needs customer login

<?
include("config file..");

// CHECK IF COOKIE IS SET
if (isset($HTTP_COOKIE_VARS['ss'])) {

// SEPERATE USERNAME AND PASSWORD WITHIN COOKIE
$userpass = explode("|", $ssacct);

// LOOK FOR A ROW WITHIN THE CLIENT TABLE THAT MATCHES USER/PASS
$sql = "SELECT * FROM clients WHERE username='$userpass[0]' AND password='$userpass[1]'";
$db = mysql_select_db("$dbName", $connection) or die("Couldnt select DB");
$sql_result = mysql_query($sql, $connection) or die("Couldnt exec Query");

$found = mysql_num_rows($sql_result);

// IF NOT FOUND SEND THEM TO A NO AUTHORIZATION PAGE
if ($found == "0") {
header("Location: /errors/noauth.php");
}

} else { header("Location: /errors/noauth.php"); }

// IF YOU GET THROUGH TO THIS STEP IT LOADS THE PAGE WITHOUT SENDING THEM TO ANOTHER PAGE

?>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1