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!


Page 1 of 5 12345 LastLast
Results 1 to 10 of 41
  1. #1
    Join Date
    Apr 2007
    Location
    england
    Posts
    536
    Tokens
    0

    Default My newbish PHP help

    Alright, to expand my knowledge in PHP, i want to attempt to make a usersystem.

    I am currently making a registration code, and I have the following:

    PHP Code:
    <?php
    //The Variables
    $name $_POST[name];
    $password $_POST[password];
    $email $_POST[email];
    $age $_POST[age];
    $submit $_POST[submit];

    //The IFs
    if($submit !=""){

    if(
    $name !=""){
    echo 
    "Whoops! You didn't enter a username. You need that if you want to login!";
    }

    elseif(
    $password !=""){
    echo 
    "Whoops! You didn't enter a password. You need this to login to your account as well as security for your account!";
    }

    elseif(
    $email !=""){
    echo 
    "Whoops! You didn't enter an email. You need this to receive news and updates for the usersystem, as well as to verify your identity.";
    }

    elseif(
    $age !=""){
    echo 
    "Whoops! You didn't enter your age. We need this to verify you are old enough to register!";
    }

    echo 
    "Heya, $name - Welcome to $site. The details you used to sign up are as follows:<br>
    Name: 
    $name<br>
    Email: 
    $email<br>
    Age: 
    $age<br>
    <br>
    If the details are incorrect, use the back button and try again. If they are correct, please continue to the installer."
    ;
    }

    // The HTML
    echo "<form action=\"register2.php\" method=\"post\">
      Username: <input type=\"text\" name\"name\"><br>
      Password: <input type=\"text\" name\"password\"><br>
      Email: <input type=\"text\" name=\"email\"><br>
      Age: <input type=\"text\" name=\"age\"><br>
      <input type=\"submit\" name=\"submit\" value=\"Submit\">
      </form>"
    ;
      
      
    ?>
    You can view the script here: www.roflhabbos.com/dev/register2.php
    It shows me things I don't want it to, such as: " Whoops! You didn't enter your age. We need this to verify you are old enough to register!" when I did enter an age. It also doesnt show the variable I entered, it only shows what I entered for $age.

    Any help?


    Selling DJ/Habbo layout, more info here.


  2. #2
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Quote Originally Posted by adamFTW View Post
    Alright, to expand my knowledge in PHP, i want to attempt to make a usersystem.

    I am currently making a registration code, and I have the following:

    PHP Code:
    <?php
    //The Variables
    $name $_POST[name];
    $password $_POST[password];
    $email $_POST[email];
    $age $_POST[age];
    $submit $_POST[submit];

    //The IFs
    if($submit !=""){

    if(
    $name !=""){
    echo 
    "Whoops! You didn't enter a username. You need that if you want to login!";
    }

    elseif(
    $password !=""){
    echo 
    "Whoops! You didn't enter a password. You need this to login to your account as well as security for your account!";
    }

    elseif(
    $email !=""){
    echo 
    "Whoops! You didn't enter an email. You need this to receive news and updates for the usersystem, as well as to verify your identity.";
    }

    elseif(
    $age !=""){
    echo 
    "Whoops! You didn't enter your age. We need this to verify you are old enough to register!";
    }

    echo 
    "Heya, $name - Welcome to $site. The details you used to sign up are as follows:<br>
    Name: 
    $name<br>
    Email: 
    $email<br>
    Age: 
    $age<br>
    <br>
    If the details are incorrect, use the back button and try again. If they are correct, please continue to the installer."
    ;
    }

    // The HTML
    echo "<form action=\"register2.php\" method=\"post\">
      Username: <input type=\"text\" name\"name\"><br>
      Password: <input type=\"text\" name\"password\"><br>
      Email: <input type=\"text\" name=\"email\"><br>
      Age: <input type=\"text\" name=\"age\"><br>
      <input type=\"submit\" name=\"submit\" value=\"Submit\">
      </form>"
    ;
      
      
    ?>
    You can view the script here: www.roflhabbos.com/dev/register2.php
    It shows me things I don't want it to, such as: " Whoops! You didn't enter your age. We need this to verify you are old enough to register!" when I did enter an age. It also doesnt show the variable I entered, it only shows what I entered for $age.

    Any help?
    != is does not equal, you've got it so if it doesn't equal blank, then do it
    you need == instead of !=


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  3. #3
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php
    //The Variables
    $name $_POST["name"];
    $password $_POST["password"];
    $email $_POST["email"];
    $age $_POST["age"];
    $submit $_POST["submit"];

    //The IFs
    if ($submit != "")
    {

        if (
    $name == "")
        {
            echo 
    "Whoops! You didn't enter a username. You need that if you want to login!";
        }

        elseif (
    $password == "")
        {
            echo 
    "Whoops! You didn't enter a password. You need this to login to your account as well as security for your account!";
        }

        elseif (
    $email == "")
        {
            echo 
    "Whoops! You didn't enter an email. You need this to receive news and updates for the usersystem, as well as to verify your identity.";
        }

        elseif (
    $age == "")
        {
            echo 
    "Whoops! You didn't enter your age. We need this to verify you are old enough to register!";
        }

        echo 
    "Heya, $name - Welcome to $site. The details you used to sign up are as follows:<br>
    Name: 
    $name<br>
    Email: 
    $email<br>
    Age: 
    $age<br>
    <br>
    If the details are incorrect, use the back button and try again. If they are correct, please continue to the installer."
    ;
    exit;
    }

    // The HTML
    echo "<form action=\"register2.php\" method=\"post\">
      Username: <input type=\"text\" name\"name\"><br>
      Password: <input type=\"text\" name\"password\"><br>
      Email: <input type=\"text\" name=\"email\"><br>
      Age: <input type=\"text\" name=\"age\"><br>
      <input type=\"submit\" name=\"submit\" value=\"Submit\">
      </form>"
    ;

    ?>
    That should work?

  4. #4
    Join Date
    May 2007
    Location
    Brisbane, Australia
    Posts
    796
    Tokens
    0

    Default

    Quote Originally Posted by Dentafrice, View Post
    PHP Code:
    <?php
    //The Variables
    $name $_POST["name"];
    $password $_POST["password"];
    $email $_POST["email"];
    $age $_POST["age"];
    $submit $_POST["submit"];

    //The IFs
    if ($submit != "")
    {

        if (
    $name == "")
        {
            echo 
    "Whoops! You didn't enter a username. You need that if you want to login!";
        }

        elseif (
    $password == "")
        {
            echo 
    "Whoops! You didn't enter a password. You need this to login to your account as well as security for your account!";
        }

        elseif (
    $email == "")
        {
            echo 
    "Whoops! You didn't enter an email. You need this to receive news and updates for the usersystem, as well as to verify your identity.";
        }

        elseif (
    $age == "")
        {
            echo 
    "Whoops! You didn't enter your age. We need this to verify you are old enough to register!";
        }

        echo 
    "Heya, $name - Welcome to $site. The details you used to sign up are as follows:<br>
    Name: 
    $name<br>
    Email: 
    $email<br>
    Age: 
    $age<br>
    <br>
    If the details are incorrect, use the back button and try again. If they are correct, please continue to the installer."
    ;
    exit;
    }

    // The HTML
    echo "<form action=\"register2.php\" method=\"post\">
      Username: <input type=\"text\" name\"name\"><br>
      Password: <input type=\"text\" name\"password\"><br>
      Email: <input type=\"text\" name=\"email\"><br>
      Age: <input type=\"text\" name=\"age\"><br>
      <input type=\"submit\" name=\"submit\" value=\"Submit\">
      </form>"
    ;

    ?>
    That should work?


    u have if ($submit != "")
    Thanks,
    Chris
    Free Image Uploading

    __________________


    [/url]

    [/FONT]

  5. #5
    Join Date
    Apr 2007
    Location
    england
    Posts
    536
    Tokens
    0

    Default

    Okay, I added that code but when I register I get the following:

    Whoops! You didn't enter a username. You need that if you want to login!Heya, - Welcome to . The details you used to sign up are as follows:
    Name:
    Email:
    Age: 14

    If the details are incorrect, use the back button and try again. If they are correct, please continue to the installer.
    As you can see, it still has that username error, as well as it doesnt show what the user inputted in the form, only the age displays it.


    Selling DJ/Habbo layout, more info here.


  6. #6
    Join Date
    Sep 2007
    Posts
    410
    Tokens
    0

    Default

    Wouldn't the error have something to do with the elseif's? I'm no expert but looking at the code then you're ignoring all fields except the age because it's the last one and the if ends there?

  7. #7
    Join Date
    Apr 2007
    Location
    england
    Posts
    536
    Tokens
    0

    Default

    The age is an elseif too.


    Selling DJ/Habbo layout, more info here.


  8. #8
    Join Date
    Sep 2007
    Posts
    410
    Tokens
    0

    Default

    Yes, but the age is the last field. So it takes that one and outputs it.

  9. #9
    Join Date
    Apr 2007
    Location
    england
    Posts
    536
    Tokens
    0

    Default

    How wopuld I make it so it outputs them all?


    Selling DJ/Habbo layout, more info here.


  10. #10
    Join Date
    May 2007
    Location
    Nebo, NC, USA
    Posts
    2,517
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php
    //The Variables
    $name $_POST["name"];
    $password $_POST["password"];
    $email $_POST["email"];
    $age $_POST["age"];
    $submit $_POST["submit"];

    //The IFs
    if ($submit != "")
    {

        if (
    $name == "")
        {
            echo 
    "Whoops! You didn't enter a username. You need that if you want to login!";
            exit;
        }

        if (
    $password == "")
        {
            echo 
    "Whoops! You didn't enter a password. You need this to login to your account as well as security for your account!";
            exit;
        }

        if (
    $email == "")
        {
            echo 
    "Whoops! You didn't enter an email. You need this to receive news and updates for the usersystem, as well as to verify your identity.";
            exit;
        }

        if (
    $age == "")
        {
            echo 
    "Whoops! You didn't enter your age. We need this to verify you are old enough to register!";
            exit;
        }

        echo 
    "Heya, $name - Welcome to $site. The details you used to sign up are as follows:<br>
    Name: 
    $name<br>
    Email: 
    $email<br>
    Age: 
    $age<br>
    <br>
    If the details are incorrect, use the back button and try again. If they are correct, please continue to the installer."
    ;
        exit;
    }

    // The HTML
    echo "<form action=\"register2.php\" method=\"post\">
      Username: <input type=\"text\" name\"name\"><br>
      Password: <input type=\"text\" name\"password\"><br>
      Email: <input type=\"text\" name=\"email\"><br>
      Age: <input type=\"text\" name=\"age\"><br>
      <input type=\"submit\" name=\"submit\" value=\"Submit\">
      </form>"
    ;

    ?>
    Removed the elseif's and added exits.

Page 1 of 5 12345 LastLast

Posting Permissions

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