Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2005
    Location
    Nottingham
    Posts
    5,277
    Tokens
    75

    Latest Awards:

    Default My logon system doesn't seem to register.

    Thats the code below but everytime I try and register it says that the username is already registered but the datafile is empty. I'm stuck.

    PHP Code:
    <html> 
    <head> 
    <title>Register</title> 
    </head> 
    <body> 


    <?php 
    //php user script
    //ben speakman


    $datafile 'data.txt'


    if(
    $_GET['action'] == 'signup') { 
         
        if(!isset(
    $_POST['name']) || !isset($_POST['email']) || !isset($_POST['url']) || !isset($_POST['username']) || !isset($_POST['password'])){ 
            
            
    error_message('One or more required fields were left blank!'$_POST['name'], $_POST['email'], $_POST['url'], $_POST['username'], $_POST['password']); 
        } 
        
        
    $file file($datafile); 
        while(list(,
    $value)=each($file)){  //check if user exists
            
    list($fname,$femail,$furl,$fuser,$fpass,$blank)=split"\|"$value); 
            if(
    $username==$fuser){ 
                
                
    error_message('Username is allready in use.'$_POST['name'], $_POST['email'], $_POST['url'], $_POST['username'], $_POST['password']); 
            } 
        } 
        
        
    $fp fopen($datafile'a'); 
        
    fwrite($fp$_POST['name'] . '|' $_POST['email'] . '|' $_POST['url'] . '|' $_POST['username'] . '|' $_POST['password'] . "|\n"); 
        
    fclose($fp); 
        
    //html for sucessfull signup
    ?> 


                  You have been sucessfulle registered.<br>
                  You may now <a href="user.php">login</a> using the followin details   <br>         
                  username: <?echo $username;?> <br>             
                  password: <?echo $password;?>  


    </body>
    </html>


    <?php 
    } else { 
     
    //html for sign up
    ?> 


    <html>
    <head>
    <title>Register</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <LINK REL="STYLESHEET" TYPE="text/css">
    </head>
    <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">




    <FORM action="<?php echo $_SERVER['PHP_SELF']; ?>?action=signup" method="post"> 


    <p>Name: 
      <INPUT type="text" name="name"></p> 


    <p>E-mail Address: 
        <INPUT type="text" name="email"> </p>


    <p>Website Address: 
        <INPUT type="text" name="url"> </p>


    <p>Desired Username: 
        <INPUT type="text" name="username"> </p>


    <p>Password: 
        <INPUT type="password" name="password"> </p>


    <INPUT type="submit" value="Sign-up"> 
    </FORM> 
    </body>
    </html>




    <?php 

    function 
    error_message($message$name$email$url$username$password) { 
    ?> 


    <html>
    <head> //html for signing up error
    <title>Error</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <LINK REL="STYLESHEET" TYPE="text/css">
    </head>
    <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">


                <?php echo $message;?> //error message


    <FORM action="<?php echo $_SERVER['PHP_SELF']; ?>?action=signup" method="post">
     
    <P>Name: <INPUT type="text" name="name" value="<?php echo $name;?>"> 


    <P>E-mail Address: <INPUT type="text" name="email" value="<?php echo $email;?>"> 


    <P>Website Address: <INPUT type="text" name="url" value="<?php echo $url;?>"> 


    <P>Desired Username: <INPUT type="text" name="username" value="<?php echo $username;?>">
     
    <P>Password: <INPUT type="password" name="password" value="<?php echo $password;?>"> 


    <P><INPUT type="submit" value="Sign-up"> 
    </FORM> 
    </body>
    </html>




    <?php 
        
    exit; 

    ?> 


    </body> 
    </html>
    VR|46

  2. #2
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    havent read ur code but is your flatfile chmodded too 777?


  3. #3
    Join Date
    Jun 2005
    Location
    Nottingham
    Posts
    5,277
    Tokens
    75

    Latest Awards:

    Default

    No it isn't, sorry for being a noob but how do I do that?
    VR|46

  4. #4
    <?PHP> Guest

    Default

    Go onto your ftp program, right click file, chmod/edit permissions, 777, OK

  5. #5
    Join Date
    Jun 2005
    Location
    Nottingham
    Posts
    5,277
    Tokens
    75

    Latest Awards:

    Default

    Did that but now there's an error, I'll post it in a min.

    Ok now it just doesn't register, It stills says username is in use but the error is gone and data file is chmodded to 777
    Last edited by iAdam; 19-02-2008 at 03:47 PM.
    VR|46

  6. #6
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    PHP Code:
    <html> 
    <head> 
    <title>Register</title> 
    </head> 
    <body> 


    <?php 
    //php user script
    //ben speakman


    $datafile 'data.txt'


    if(
    $_GET['action'] == 'signup') { 
         
        if(!isset(
    $_POST['name']) || !isset($_POST['email']) || !isset($_POST['url']) || !isset($_POST['username']) || !isset($_POST['password'])){ 
            
            
    error_message('One or more required fields were left blank!'$_POST['name'], $_POST['email'], $_POST['url'], $_POST['username'], $_POST['password']); 
        } 
        
        
    $file file($datafile); 
        while(list(,
    $value)=each($file)){  //check if user exists
            
    list($fname,$femail,$furl,$fuser,$fpass,$blank)=split"\|"$value); 
            if(
    $_POST['name'] == $fuser){ 
                
                
    error_message('Username is allready in use.'$_POST['name'], $_POST['email'], $_POST['url'], $_POST['username'], $_POST['password']); 
            } 
        } 
        
        
    $fp fopen($datafile'a'); 
        
    fwrite($fp$_POST['name'] . '|' $_POST['email'] . '|' $_POST['url'] . '|' $_POST['username'] . '|' $_POST['password'] . "|\n"); 
        
    fclose($fp); 
        
    //html for sucessfull signup
    ?> 


                  You have been sucessfulle registered.<br>
                  You may now <a href="user.php">login</a> using the followin details   <br>         
                  username: <?echo $username;?> <br>             
                  password: <?echo $password;?>  


    </body>
    </html>


    <?php 
    } else { 
     
    //html for sign up
    ?> 


    <html>
    <head>
    <title>Register</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <LINK REL="STYLESHEET" TYPE="text/css">
    </head>
    <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">




    <FORM action="<?php echo $_SERVER['PHP_SELF']; ?>?action=signup" method="post"> 


    <p>Name: 
      <INPUT type="text" name="name"></p> 


    <p>E-mail Address: 
        <INPUT type="text" name="email"> </p>


    <p>Website Address: 
        <INPUT type="text" name="url"> </p>


    <p>Desired Username: 
        <INPUT type="text" name="username"> </p>


    <p>Password: 
        <INPUT type="password" name="password"> </p>


    <INPUT type="submit" value="Sign-up"> 
    </FORM> 
    </body>
    </html>




    <?php 

    function 
    error_message($message$name$email$url$username$password) { 
    ?> 


    <html>
    <head> //html for signing up error
    <title>Error</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <LINK REL="STYLESHEET" TYPE="text/css">
    </head>
    <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">


                <?php echo $message;?> //error message


    <FORM action="<?php echo $_SERVER['PHP_SELF']; ?>?action=signup" method="post">
     
    <P>Name: <INPUT type="text" name="name" value="<?php echo $name;?>"> 


    <P>E-mail Address: <INPUT type="text" name="email" value="<?php echo $email;?>"> 


    <P>Website Address: <INPUT type="text" name="url" value="<?php echo $url;?>"> 


    <P>Desired Username: <INPUT type="text" name="username" value="<?php echo $username;?>">
     
    <P>Password: <INPUT type="password" name="password" value="<?php echo $password;?>"> 


    <P><INPUT type="submit" value="Sign-up"> 
    </FORM> 
    </body>
    </html>




    <?php 
        
    exit; 

    ?> 


    </body> 
    </html>

  7. #7
    Join Date
    Jun 2005
    Location
    Nottingham
    Posts
    5,277
    Tokens
    75

    Latest Awards:

    Default

    Have u corrected anything?
    VR|46

  8. #8
    Join Date
    Dec 2006
    Location
    Swindon
    Posts
    3,299
    Tokens
    215
    Habbo
    dunko

    Latest Awards:

    Default

    Quote Originally Posted by DJ-Simpson View Post
    Have u corrected anything?
    Just try it.

  9. #9
    Join Date
    Jun 2005
    Location
    Nottingham
    Posts
    5,277
    Tokens
    75

    Latest Awards:

    Default

    Thankyou thats worked but now I cant login it always says username/password bad combination or something.

    PHP Code:
    <?php
    //php user script
    //ben speakman
    session_start(); 
    header("Cache-control: private");
    ?> 
    <html> 
    <head> 
    <title>Logged-in</title> 
    </head> 
    <body> 
    <?php
     
    $datafile
    ="data.txt"//name of the data file
    if($_GET['action'] == "login") { 
        
        if(!isset(
    $_POST['username']) || !isset($_POST['password'])){ //this checks that all the fields are filled in
            
            
    error_message("One or more required fields were left blank!"$username$password); 
        } 
         
        
    $file file($datafile); 
        while(list(,
    $value) = each($file)) { 
            list(
    $fname,$femail,$furl,$fuser,$fpass,$blank) = explode('|'$value); 
            if(
    $_POST['username'] == $fuser && $_POST['password'] == $fpass){ 
      
    $_SESSION['name'] = $fuser;
    $_SESSION['realname'] = $fname;
    $_SESSION['url'] = $furl;
    $_SESSION['email'] = $femail//adds the users data to the php session
    $_SESSION['pass'] = $fpass;
       
    //insert html for sucessfull log on here
    //you can use  . $_SESSION['name'] . for username
    // replace name with realname, url, email to display different name
    ?> 
    you are logged in.<br>
    view you profile <a href="profile.php">here</a><br>
    or logout <a href="logout.php">here</a>.
    </body>
    </html>

    <?php
    $logink 
    true


        if(
    $logink !== true) { 
    ?>
    Login failed, bad username/password
    <?

    } elseif(
    $_GET['action'] == 'change') { 
        
        if(!isset(
    $_POST['name']) || !isset($_POST['email']) || !isset($_POST['url']) || !isset($_POST['newpass'])) { 
             
       
    //this checks that all the fields are filled in
            
    ?>
      all fields were not filled in
      <?
        

         
        
    $file file($datafile); 
        while(list(,
    $value) = each($file)){ 
            list(
    $fname,$femail,$furl,$fuser,$fpass) = explode('|'$value); 
            if(
    $_SESSION['name'] == $fuser){ 
                
    //opens data file to change it
                
    $oldword "$fname|$femail|$furl|$fuser|$fpass|"
                
    $newword $_POST['name'] . '|' $_POST['email'] . '|' $_POST['url'] . '|' $_SESSION['name'] . '|' $_POST['newpass'] . '|'
                
    $fp fopen($datafile'r'); 
                
    $data fread($fpfilesize($datafile)); 
                
    fclose($fp); 
                
    $newdata str_replace($oldword$newword$data); 
                
    $fp fopen($datafile'w'); 
                
    fwrite($fp,$newdata) or die ('error writing'); 
                
    fclose($fp); 
                
    $succ true//data changed sucessfully
    ?>            
    Everything was changed successfully please <a href="user.php">login</a>
    <?
    $_SESSION
    ['name'] = FALSE
    $_SESSION['pass'] = FALSE
    $_SESSION['url'] = FALSE
    $_SESSION['realname'] = FALSE
    $_SESSION['email'] = FALSE
        } 
        } 
        if(
    $succ !== true) { 
    ?>
    Login failed, bad username/password
    <?
        

    } else { 
        exit; 

    ?>
    VR|46

Posting Permissions

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