Current location: Hot Scripts Forums » Programming Languages » PHP » Cannot Get the user to stay ACTIVE! can't get "home" button to return "home"


Cannot Get the user to stay ACTIVE! can't get "home" button to return "home"

Reply
  #1 (permalink)  
Old 08-12-09, 06:40 PM
u192973 u192973 is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
X_X Cannot Get the user to stay ACTIVE! can't get "home" button to return "home"

Hello All! So when I created a "home" button and a "Return to member page" button, BUT when the user clicks on the button it doesn't go back to their page, it logs them out and returns them to the index page. Why? How do I keep a user active so that they can be returned to their page?

Thank you so much, this is one of the last hurtles I have.


PHP Code:



#!/usr/lib/php5/bin/php
<?php
session_start
();
// If magic quotes is turned on then strip slashes
if (get_magic_quotes_gpc()) {
  foreach (
$_POST as $key => $value) {
    
$_POST[$key] = stripslashes($value);
  }
}
  
$message="";

if(isset(
$_POST["login"])){

  
// Extract form submission
  
$theusername = (isset($_POST["username"]))?$_POST["username"]:"";  
  
$thepassword = (isset($_POST["password"]))?$_POST["password"]:"";  
 
  include(
"socialfunctions.php");


  if (
is_valid_login($theusername$thepassword)) {    
 
    
// store username obtained from the form as a session variable
    
$_SESSION['username'] = $theusername;
  
    
// store ip of the client as a session variable
    
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
 
    
// any other data needed to navigate the site or  
    // to authenticate the user can be added here  
    
login($theusername);
    
    
// include member page
    
include("socialmemberpage.inc");
  }
  else{      
    
// redirect user to index page
    
header("location:index.php");
  }
}
else if(isset(
$_POST["postMessage"]) && strcmp($_SESSION['ip'], $_SERVER['REMOTE_ADDR']) == 0){

  
// Extract form submission            
  
$fromuser = (isset($_POST["fromuser"]))?$_POST["fromuser"]:"";
  
$postdate date("Y-m-d G:i:s"time());
  
$touser = (isset($_POST["touser"]))?$_POST["touser"]:"";
  
$post = (isset($_POST["post"]))?$_POST["post"]:"";
 
  include(
"socialfunctions.php");

  
// Insert post into database
  
$message postMessage($fromuser$touser$postdate$post);

  
// include member page
  
include("socialmemberpage.inc");
}
else if(isset(
$_POST["deleteMessage"]) && strcmp($_SESSION['ip'], $_SERVER['REMOTE_ADDR']) == 0){
  
  
// Extract form submission
  
$post_id = (isset($_POST["postid"]))?$_POST["postid"]:"";

  include(
"socialfunctions.php");

  
// delete post from database
  
$message deleteMessage($post_id);
  
  
// include member page
  
include("socialmemberpage.inc");
}
else if(isset(
$_POST["logout"]) && strcmp($_SESSION['ip'], $_SERVER['REMOTE_ADDR']) == 0){

  
// Extract form submission
  
$theusername = (isset($_POST["username"]))?$_POST["username"]:"";

  include(
"socialfunctions.php");

  
// log the user out
  
logout($theusername);

  
// redirect user to index page
  
header("location:index.php");

}

else{      
  
// redirect user to index page
  
header("location:index.php");
}
?>

Last edited by wirehopper; 08-12-09 at 09:13 PM. Reason: PHP tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-12-09, 09:17 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
It looks like this script sends the user to index.php if no action is specified, if it isn't a login, post message, delete, or logout. Is that what it's supposed to do?

This line is usually used for command line scripts. Is it in all your scripts?

Quote:
#!/usr/lib/php5/bin/php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-13-09, 12:19 AM
u192973 u192973 is offline
Newbie Coder
 
Join Date: Aug 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
I really don't know too much about that line and the command line scripts; however, I believe you are correct about the if statements. I was wondering if you know how to write an if statement with those that says logically

If I am away from the member page and want to get back, I click on the link in the above navigation, if that link is clicked (socialmemberpage.php) then load that social member page and do not load the index.php.

I am wondering if this is possible if I have a href for the link...

Your help is much appreciated! Thank you!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks

Tags
active, button, home, return, session


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Classified Ads skipper23 Perl 3 11-22-05 03:22 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 11:15 AM
Quick Question for you php guru's Tokahashi PHP 3 04-09-04 01:00 PM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 07:02 AM
Classified Ads skipper23 Perl 2 12-30-03 04:43 AM


All times are GMT -5. The time now is 10:54 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.