Help with User registration

deadfingersdeadfingers Senior MemberThe Royal RAM
Alright well ive search around here but nothing specifically answers my problem so im posting this. Ok im using this tutorial http://www.howthenetworks.org/view.php?id=2 so ive done all the 1st page and the form and everything, but it doesnt work. Ok here are my questions, the 1st part of the tutorial says to make a table inside my DB, so does that code go in with the form.html one? or in the page where i have my DB script? i put it in the form one. Second my db name is 'deadfingers' so instead of were it says 'user' i put deadfingers correct? well i did all that yet when i uploaded it, the page says There was an error. The user account was not created., or this
Parse error: parse error, unexpected T_VARIABLE in /home/sites/ur-fragged.co.uk/public_html/deadfingers/signup.php on line 19 what the heck? i got that second error when i closed up some spaces, like i had
$user = addslahes($user)
$pass = addslahes($pass)
so i closed up the spaces where the '=' was then it said that, are there some parts of the script that need to have spaces like that? in the tutorial everything has a space so idk. how can i fix this?
sig.jpg

Comments

  • PythonPython Forum Leader The Royal RAM
    you are putting a selicolon at the end of each command right? eg:

    $user = addslahes($user);
    $pass = addslahes($pass);

    The Royal Ram

  • deadfingersdeadfingers Senior Member The Royal RAM
    lol ok i saw what the problem was, one was yes i forgot to put the ';' on like 5 or six lines lol so yeah that was 2 of them, and second i mispelled slashes, i put slahes and so did u lol so now its
    [PHP]$user=addslashes($user);
    $pass=addslashes($pass);[/PHP]

    so yeah now it has nothing wrong scriptwise now :) i had a lol of things missing and some misspellings :eek: lol i did this pretty late at night heh. anyways now it wont work, it says "user/pass was not long enough" but i put

    [PHP]$min_len=6;
    if(strlen($user) < $min_len || strlen($pass) < $min_len);
    {
    die("the User/Password was not long enough");
    }[/PHP]

    even when i put a user like
    deadfingers
    password

    so whats going on? the $min_len=6; is supposed to mean the minimum length must be like 6 characters long at least no? whats wrong? im lost now :confused:

    heres the link to what im practicing www.ur-fragged.co.uk/formt.html
    sig.jpg
  • deadfingersdeadfingers Senior Member The Royal RAM
    alright well i figured out my last problem i had, i had an extra ';' so it automatically went to the 'die' function but it works now, well not fully.
    Now it goes to the last 'echo' function yet i have no reason why, im thinking im overseeing this very small thing i messed up on and thats why its doing that :confused:

    [PHP] mysql_select_db("deadfingers");
    $pass=md5($pass);
    $request="INSERT INTO users values (0,'".$user."','".$pass."')";
    $results = mysql_query($request,$conn);
    if ($results)
    {
    echo "Account created succesfully";
    }
    else
    {
    echo "there was an error, user account not created";
    }

    ?>[/PHP]

    sorry if thats too long but does anyone notice any problems with this part of the script? when i input my user and pass it goes to "there was an error, user account not created" rrr oh well im getting there little by little :D
    sig.jpg
  • CannonBallGuyCannonBallGuy Moderator Shared Hoster
    Im a total noob to php... But surely, with an if statment it should be like:
    IF x = y then do THIS
    ELSE do THAT
    You just have:
    IF x do THIS
    Else do THAT
    You havent specified when to do this and that... If you get what I mean.
  • deadfingersdeadfingers Senior Member The Royal RAM
    hmm yeah i get what u mean and yea i do have that but on the tutorial its exactly like this, i went over it 2 times to make sure and yup its like that so idk? is there something missing that i need here? anyone wit good PHP exp in this stuff?
    sig.jpg
  • deadfingersdeadfingers Senior Member The Royal RAM
    so anyone at all? i even copied and pasted the code and nothing :S i changed the pass and watnot to mine. anyone have a good tutorial on this? one that shows user registration were u can input ur own user name and password? thanx
    sig.jpg
  • ForgeForge Senior Member The Royal RAM
    you dont have a $conn variable assigned from what i can see. Just put...

    $results = mysql_query($request);

    Then it should work.
    Can fat people Go skinny Dipping?
  • deadfingersdeadfingers Senior Member The Royal RAM
    thanx Forge but actually i do have it i just didnt want to post it since it had my user and pass but ill just edit it out
    [PHP]$conn = mysql_connect("localhost","username","password");

    //now choose the database to use
    mysql_select_db("deadfingers");

    //encrypt the users password so it cannot be retrieved by anyone!
    $pass=md5($pass);

    //the function md5 creates a unique 32 character string,
    //no matter what the length of the data you encrypt!

    //Save the request in SQL syntax to a string
    $request = "INSERT INTO users values(0,'".$user."','".$pass."')";

    //Pass the request to the mysql connection,
    //and the data is returned in a blob and
    //saved in $results
    $results = mysql_query($request,$conn);

    if($results)
    {
    echo "User account created";
    }
    else
    {
    echo "There was an error. The user account was not created.";
    }


    //End PHP file signup.php
    ?>
    [/PHP]
    ok there it is cept it has username and password instead of my stuff, so whats going on? hopefully theres something i forgot and not just a bad tutorial i was reading thanx! :D :rog:
    sig.jpg
  • ForgeForge Senior Member The Royal RAM
    Ok, Let me just redo this for you please. I think if you look at my example, you'll learn from it. The tutorial is teaching basics. But what about if the username is already taken huh?
    
    <?
    
    $conn = mysql_connect("localhost","username","password");
    $sdb   = mysql_select_db("deadfingers");
    
    $query  = "SELECT * FROM users WHERE username='". $user ."'";
    $result = mysql_query($query);
    
    if(mysql_num_rows($result) > 0){
    echo "That username has already been taken, please try another";
    exit();
    }
    else {
    $pass = md5($pass);
    $query  = "INSERT INTO users VALUES('NULL','$user','$pass')";
    $result = mysql_query($query);
     if($result){
      echo "Congrat's! The username <span style=\"text-decoration: underline\">$user</span> Was not taken and was created without failure";
    }
    else {
    echo "Nope...";
    }
    }
    
    ?>
    
    

    Thats just my method...
    Can fat people Go skinny Dipping?
  • deadfingersdeadfingers Senior Member The Royal RAM
    hmmm alright ill try that, and yeah i need to know the basics 1st anyways so lol
    sig.jpg
  • deadfingersdeadfingers Senior Member The Royal RAM
    www.ur-fragged.co.uk/deadfingers/form.html it still doesnt work man, see if u type in a pass and user u get a prob on line 18 and it says 'nope' which means it didnt work
    [PHP]if(mysql_num_rows($result) > 0){[/PHP] thats line 18, so whats missing? i replaced all my code wit just that code u put up, so it has all that code in the 'signup.php' i think im gonna use one from 'spoono.com' just need to get around to it lol
    sig.jpg
  • MacMac Beginner Link Clerk
    good stuff ;)
  • deadfingersdeadfingers Senior Member The Royal RAM
    lmao, why is everyone bringing up old posts now? i have like 4 emails with replies to posts i made like almost 4 months ago lol
    sig.jpg
Sign In or Register to comment.