SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Logging out instead of being re-directed

    I have this upload script where web visitors can upload files to my web site. At the end of the upload script page they are automatically re-directed to another page. However, when I tested this I was able to open my browser and go back to the upload page after being re-directed.

    I'd like it so that after uploading, the user is logged-out so he can't go back to that page withour logging-in again.

    On the main menu, a user can manually log-out, by selecting Log Out which uses the line of code: <A href='index.php?command=account&param=logout'>

    My question is how do I automatically get the user logged out? Under "Location" in the code below, would it be correct to replace the re-direction code:

    header("Location: http://www.someotherplace.com");

    with this:

    header("Location: A href='index.php?command=account&param=logout');

    or would that code be incorrect?

    I posted the last part of the code page below. Thanks for your help.
    Ideally, it would be great to automatically have the user log-out and be redirected somewhere.

    Code:
    function upload_file($upload_directory, $upload_uri) {global $account;
            $file_name = $_FILES["userfile"]["name"];
    	$file_name = str_replace(" ","_",$file_name);
    	$ext=pathinfo($file_name,PATHINFO_EXTENSION);
            $file_name = basename($file_name, '.' . $ext);
            $file_path = $upload_directory. $file_name.'-'. $account->get_user_name().'.'.$ext;
    
    	$temporary = $_FILES["userfile"]["tmp_name"];
    
    	$result = move_uploaded_file($temporary, $file_path);
    	if(!chmod($file_path,0777))
    	$message = "ERROR: A folder to place the files was not found, or the files need to be CHMODed to 777.";
    	else $message = ($result)?"File has been uploaded." : "An error has occurred.";
    
    	header("Location: http://www.someotherplace.com");
    	exit();
    
    	return $message;
    	}
    ?>

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    header("Location: index.php?command=account&param=logout'); 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks, but....

    Thanks for your reply and assistance, but I get this error now that i've implemented your suggestion. Can you help me?

    thanks.

    Parse error: syntax error, unexpected $end in C:\Inetpub\wwwroot\http\home\upload1.php on line 119

  4. #4
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    header("Location: http://www.whatever.com/index.php?command=account&param=logout");//double quotes
    exit; 
    my mobile portal
    ghiris.ro

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    thanks

    thanks..........
    Last edited by ChrisjChrisj; Oct 15, 2007 at 14:38.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •