Page 2 of 5 FirstFirst 12345 LastLast
Results 11 to 20 of 41
  1. #11
    Join Date
    Jan 2007
    Location
    England, Uk, World, Universe,
    Posts
    1,012
    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 == "")
        {
            die (
    "Whoops! You didn't enter a username. You need that if you want to login!");
     
        }
     
        if (
    $password == "")
        {
            die (
    "Whoops! You didn't enter a password. You need this to login to your account as well as security for your account!");
     
        }
     
        if (
    $email == "")
        {
            die (
    "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.");
                }
     
        if (
    $age == "")
        {
            die (
    "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>"
    ;
     
    ?>
    Last edited by rh4u; 21-11-2007 at 04:50 PM.
    my sig ran away,

  2. #12
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    You should really clean input :S

    PHP Code:
    function clean($tobecleaned)
    {
    $cleaned strip_tags(addslashes(stripslashes(htmlspecialchars($tobecleaned))));
    return 
    $cleaned;

    then do
    PHP Code:
    clean($_POST[variablename]); 
    instead of
    PHP Code:
    $_POST[variablename]; 
    Coming and going...
    Highers are getting the better of me

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

    Latest Awards:

    Default

    Quote Originally Posted by rh4u 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 == "")
        {
            die (
    "Whoops! You didn't enter a username. You need that if you want to login!");
     
        }
     
        if (
    $password == "")
        {
            die (
    "Whoops! You didn't enter a password. You need this to login to your account as well as security for your account!");
     
        }
     
        if (
    $email == "")
        {
            die (
    "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.");
                }
     
        if (
    $age == "")
        {
            die (
    "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>"
    ;
     
    ?>
    Ewww, don't use die. Just do an echo, then an exit.

    Quote Originally Posted by Cj555 View Post
    You should really clean input :S

    PHP Code:
    function clean($tobecleaned)
    {
    $cleaned strip_tags(addslashes(stripslashes(htmlspecialchars($tobecleaned))));
    return 
    $cleaned;

    then do
    PHP Code:
    clean($_POST[variablename]); 
    instead of
    PHP Code:
    $_POST[variablename]; 
    Better clean function:

    PHP Code:
    <?php

    function clean($string)
    {

        
    $string htmlspecialchars($stringENT_QUOTES);

        if (
    get_magic_quotes_gpc())
        {

            
    $string stripslashes($string);

        }

        
    $string str_replace("\""""$string);
        
    $string htmlentities($string);
        
    $string mysql_real_escape_string($string);

        return 
    $string;

    }


    ?>

  4. #14
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    $string = str_replace("\"", "", $string);

    is not just the same as stripslashes?

    Lol, but use denta's is looks more complicated and probs better
    Coming and going...
    Highers are getting the better of me

  5. #15
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    PHP Code:
    <?php

    //Clean function, comment out if not wanted.

    function clean($this){
    $this strip_tags($this);
    $this htmlspecialchars($thisENT_QUOTES);
    $this mysql_real_escape_string($this);
    return 
    $this;
    }

    if(isset(
    $_POST['submit'])){

    //The form was sent, let's do some stuff!

    $name clean($_POST['name']);
    $password clean($_POST['password']);
    $email clean($_POST['email']);
    $age clean($_POST['age']);

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

        if (!isset(
    $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 (!isset(
    $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 (!isset(
    $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.
        "
    );

    }else{

    //The form hasn't yet been sent! Display it.

      
    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>
      "
    );

    }

    die();

    ?>
    Fixed everything, used a clean function seen as them lot are raving about it ^^
    Last edited by lolwut; 21-11-2007 at 05:27 PM.
    i've been here for over 8 years and i don't know why

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

    Latest Awards:

    Default

    !isset($age)

    Anytime you submit a post..

    $age = $_POST["age"];

    Thats set, you need to check to see if it is blank, not set.

  7. #17
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default

    isset() is the same as blank?
    PHP assumes if a variable is blank then it is not set.
    I.e.
    PHP Code:
    $this "";
    if(!isset(
    $this)){ die('lolnosoz'); } 
    Correct me if I'm wrong.
    i've been here for over 8 years and i don't know why

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

    Latest Awards:

    Default

    Nope:

    PHP Code:
    <?php

    $bla 
    $_GET["hey"];
    if (!isset(
    $bla))
    {
        echo 
    "Not set";
    }
    else
    {
        echo 
    "Word: $bla";
    }

    ?>
    if you visit filename.php without putting the get, it is unset.

    If you visit filename.php?hey it is set, but it is blank So it doesn't check to see if it is blank.

  9. #19
    Join Date
    Sep 2006
    Location
    Hobart, Australia
    Posts
    593
    Tokens
    0

    Default

    Er, that code won't work. Unless I'm mistaken, mysql_real_escape_string requires a connection to the database in order to execute.

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

    Latest Awards:

    Default

    it does, and certainly he will use a DB

Page 2 of 5 FirstFirst 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
  •