Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Registration

  1. #1
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Registration

    I tried and tried with databases they just don't wanna work for me. Anyways, I was attempting to find a way to edit login.php to recognize more users/pass', i.e. a registration. I worked at it for a while with no luck, I've done something wrong I'm just not sure what. Someone might get after me for not using DBs or flat files (text, since I guess PHP is flat), but oh well. Please just tell me what I've screwed up.

    Code:
    $user=$_POST['user'];
    $pass=$_POST['pass'];
    $email=$_POST['email'];
    $data2="elseif(\$user==\"$user\" && \pass==\"$pass\") {
    session_start();
    \$_SESSION['user']='$user';
    \$_SESSION['pass']='$pass';
    \$_SESSION['logged']='yes';
    \$_SESSION['email']='$email';
    
    else {";
    
    $data=fopen("","r+");
    $data3=str_replace("else {", $data2, $data);
    
    fwrite($data, $data3);
    
    fclose($data);
    
    print("dfg");
    You can visit the form here:
    The print was simply a confirmation that it was working, since its not printing I'd guess theres a syntax error.

    Thanks,
    Tim

    edit: and as you may have guessed, the little "What color is behind" thing isn't doing jack right now so you don't need to answer it.
    Last edited by TimFA; 01-23-2008 at 04:16 PM.

  2. #2
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Ok, its printing it out but not changing login.php.

  3. #3
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    you can't change the file that the server is running
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  4. #4
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    It isn't running login.php at the moment. That file is inactive, even if I would run into problems later I don't care right now. If the error still lies in that, then explain what "running" is. The file register.php is supposed to make the changes not login.php.

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    This line,

    Code:
    $data=fopen("http://fassist.profusehost.net/test/phpscripts/login.php","r+");
    change to a relative path to login.php.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Well, it did SOMETHING atleast. This is my output:

    Code:
    Resource id #1_POST['user'];
    $pass=$_POST['pass'];
    $redir="<head>
    <script language=\"JavaScript\">
    var time = null
    function move() {
    window.location = 'http://fassist.profusehost.net/'
    }
    </script>
    </head>
    <body  onload=\"timer=setTimeout('move()',1)\">
    </body>";
    $rediralt="<head>
    <script language=\"JavaScript\">
    var time = null
    function move() {
    window.location = 'http://fassist.profusehost.net/'
    }
    </script>
    </head>
    <body  onload=\"timer=setTimeout('move()',2000)\">
    <div
    style=\"width:100%;font-family:arial;font-size:10pt;text-align:center;\">
    Login failed, please try again.
    </div>
    </body>";
    
    if($user=="xxxxxxx" && $pass=="xxxxxx") {
    session_start();
    $_SESSION['user']='xxxxxx';
    $_SESSION['pass']='xxxxxx';
    $_SESSION['email']='admin@fassist.profusehost.net';
    $_SESSION['logged']='yes';
    
    print("$redir");
    }
    
    elseif($user=="xxxxxx" && $pass=="xxxxxx") {
    session_start();
    $_SESSION['user']='xxxxx';
    $_SESSION['pass']='xxxxx';
    $_SESSION['logged']='yes';
    $_SESSION['email']='xxxxxxxxxxxxx';
    
    print("$redir");
    }
    
    else {
    print("$rediralt");
    
    ?>
    Please note that both entries already in the above script I had in place already, the x's are to blank out user/pass. As you can see it removed the <?php and put in some "Resource" garbage. WTH.

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Just as a test, try doing this in place of fwrite:

    Code:
    $user=$_POST['user'];
    $pass=$_POST['pass'];
    $email=$_POST['email'];
    $data2="elseif(\$user==\"$user\" && \$pass==\"$pass\") {
    session_start();
    \$_SESSION['user']='$user';
    \$_SESSION['pass']='$pass';
    \$_SESSION['logged']='yes';
    \$_SESSION['email']='$email';
    
    else {";
    
    $data=fopen("phpscripts/login.php","r+");
    $data3=str_replace("else {", $data2, $data);
    
    echo htmlentites($data3);
    //fwrite($data, $data3);
    
    fclose($data);
    
    print("dfg");
    If it outputs something like Resource_id #1, then it is an issue with the fopen command and you may need to choose a different mode or recode it to read the file, then rewrite the file.
    Hope this helps.

    Edit: Also, in your $data2 string, you are missing the part in red. You may want to add it so that the script will work after you get the writing to the file part worked out.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Now it doesn't do anything, was I supposed to keep the //fwrite() or not.

  9. #9
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Yes, all the // does is comment out that line. As for the script not showing anything, that's odd. I will have to play around with this and let you know unless someone else can figure it out in the meantime.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  10. #10
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Could this be the culprit?

    htmlentities

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
  •