Page 2 of 2

Posted: Mon Sep 26, 2005 12:56 pm
by shiznatix
what is line 61 and what are the few lines before and after?

Posted: Mon Sep 26, 2005 1:00 pm
by cnl83
They had a bunch of spaces to line 61 so I removed that, and now its saying 43 so here are lines from 26-43

Code: Select all

If ($error > 0) { 
header("location: authenticated.php");
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>


</body>

</html>
Here is the entire code

Code: Select all

<?php 
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php"); 

$page_protect = new Access_user; 
// $page_protect->login_page = "login.php"; // change this only if your login is on another page 
$page_protect->access_page(); // only set this this method to protect your page 

if (isset($_GET['action']) && $_GET['action'] == "log_out") { 
   $page_protect->log_out(); // the method to log off 
} 
//NEW smurf 
//Error Checker 
$error = 0; 

$rnquery = mysql_query("SELECT * FROM tbl_USERS WHERE real_name = '".$realname."'"); 

//Foreach row check to make sure the fields are filled in 
while ($row = mysql_fetch_assoc($rnquery))  { 

  If ($row['real_name'] = "") {//change $value to $row['field_name_you_are_checking_here'] 
    $error = $error + 1; 
  } 

} 

If ($error > 0) { 
header("location: authenticated.php");
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>


</body>

</html>

Posted: Mon Sep 26, 2005 1:06 pm
by shiznatix

Code: Select all

If ($error > 0) {
header("location: authenticated.php");
?>
you forgot the end } on that if. put a } before the ?> then put the ?> on the next line

Posted: Mon Sep 26, 2005 1:11 pm
by cnl83
That worked, but humorously enough..its saying that the fetch is not valid mysql result.

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home3/cnl83/actionfx-www/classes/access_user/example.php on line 18

Posted: Mon Sep 26, 2005 1:14 pm
by shiznatix
change

$rnquery = mysql_query("SELECT * FROM tbl_USERS WHERE real_name = '".$realname."'");

to

$rnquery = mysql_query("SELECT * FROM tbl_USERS WHERE real_name = '".$realname."'") or die(mysql_error());

Posted: Mon Sep 26, 2005 1:26 pm
by cnl83
That seemed to clear up all the errors, Now i get "No Database Selected".

So I went in and put the connection info in manually. Then it said that USERS was not a table, so I changed it to lowercase and I guess it works fine, because all I get now is a blank page. It hasnt gone over the aunthenticated.php as assigned.

Posted: Mon Sep 26, 2005 1:32 pm
by shiznatix
try this

change:
If ($error < 0) {
header("location: authenticated.php");
}

to:

Code: Select all

If ($error == 0)
  header("location: authenticated.php");
else
  echo 'There Was A Error';

Posted: Mon Sep 26, 2005 1:38 pm
by cnl83
Yes, that did send it to the correct location, but even though there is nothing populated in the field real_name, it is still sending me to authenticated. I even tried to add a new entry to the database, just in case something was coo coo about the field.

Posted: Mon Sep 26, 2005 1:53 pm
by shiznatix
what are you trying to do? I don't understand what the idea is here

Posted: Mon Sep 26, 2005 1:55 pm
by cnl83
If the field "real_name" is not populated then send them to update_user_profile.php, and if it is goto authenticated.php .

Now it seems like it should work as coded, but it appears that it is not checking to see if its populated.

Posted: Mon Sep 26, 2005 1:59 pm
by shiznatix
try this

Code: Select all

<?php
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");

$page_protect = new Access_user;
// $page_protect->login_page = "login.php"; // change this only if your login is on another page
$page_protect->access_page(); // only set this this method to protect your page

if (isset($_GET['action']) && $_GET['action'] == "log_out") {
   $page_protect->log_out(); // the method to log off
}
//NEW smurf
//Error Checker

$rnquery = mysql_query("SELECT * FROM tbl_USERS WHERE real_name = '".$realname."' LIMIT 1");

if (mysql_num_rows($rnquery) == 1)
  header("location: authenticated.php");
else
  header("location: update_user_profile.php");

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>


</body>

</html>

Posted: Mon Sep 26, 2005 2:08 pm
by cnl83
No this is doing the same thing.

I know I may have left this out... Now its per the user.

If user "testlogin" logs in and real_name isnt populated

.$_SESSION['user']." !"

Posted: Mon Sep 26, 2005 2:19 pm
by shiznatix
i don't understand what you are saying. there is no sessions in the code you posted. with the code now, if there is a db entry for the $realuser then it will redirect you to authenticated.php and if not then it will redirect you to the other site. what is it your talking about

Posted: Mon Sep 26, 2005 2:23 pm
by cnl83
What you just explained is exactly what I want. However, the problem is that this page is being accessed after a successful login. So this is how it works..

You have login.php
checks login from access_user.php
from login.php it goes to example.php (the one we been working on)
Then if the real_name is populated for the current user then it needs to goto authenticated.php.
if not then it should goto update_user_profile.php .

Im trying to make this stuff work with little php knowledge. I really appreciate your help.

The code we are working with is not working, so I figured that it might have something to do with my class file and user sessions.

Posted: Mon Sep 26, 2005 3:27 pm
by cnl83
This worked for me. I really really appreciate your help on this. Thanks ..you deffinitely pointed me in the right direction, and code most of it.

Code: Select all

$rnquery = mysql_query("SELECT real_name FROM users WHERE login = '".$_SESSION['user']."'") or die(mysql_error());
$row = mysql_fetch_assoc($rnquery);

if (empty($row['real_name']))
{
    header("location: update_user.php");
}
else
{
    header("location: authenticated.php");
}

?>