Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2008
    Posts
    64
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Help with php form!

    i have mysql set up correctly and i cant get this script to work. I get a white screen. I hope you can help me!

    PHP Code:
    <?php
    include("functions.php");

    connect();

    if(!
    $_POST['submit']){
        echo 
    "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
        echo 
    "form method=\"post\" action=\"register.php\">\n";
        echo 
    "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n";
        echo 
    "<tr><td>Username</td><td><input type=\"text\" name=\"password\"></td></tr>\n";
        echo 
    "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td</tr>\n";
        echo 
    "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td</tr>\n";
        echo 
    "<tr><td>E-mail</td><td><input type=\"text\" name=\"email\"></td</tr>\n";
        echo 
    "<tr><td>Name</td><td><input type=\"text\" name=\"name\"></td</tr>\n";
        echo 
    "<tr><td>AIM Address</td><td><input type=\"text\" name=\"aim\"></td</tr>\n";
        echo 
    "<tr><td colspan=\"2\" align=\"center\"<input type=\"submit\" name=\"submit\" value =\"Register\"></td></tr>\n";
    }else {
       
    $username protect($_POST['username']);
       
    $password protect($_POST['password']);
       
    $confirm protect($_POST['passconf']);
       
    $email protect($_POST['email']);
       
    $name protect($_POST['name']);
       
    $aim protect($_POST['aim']);
       
       
    $errors = array();
       
               if(!
    $username) {
                   
    $errors[] = "Username is not defined!";
            }
            
            if(!
    $password) {
                   
    $errors[] = "Password is not defined!";
            }
            
            if(!
    $password) {
                if(!
    $confirm) {
                       
    $errors[] = "Confirmation password is not defined!";
                   }
            }
            
            if(!
    $email) {
                   
    $errors[] = "E-mail is not defined!";
            }
            
             if(!
    $name) {
                   
    $errors[] = "Name is not defined!";
            }
            
            if(
    $username) {
                if(!
    ctype_alnum($username)) {
                    
    $errors[] = "Username can only contaion numbers and letters!";
                }
                
                
    $range range(1,32);
                if(!
    in_array(strlen($username),$range)) {
                    
    errors[] = "Username must be in between 1 and 32 characters!";
                }
            }
            
            if(
    $password && $confirm) {
                if (
    $password != $confirm) {
                    
    $errors[] = "Passwords do not match!";
                }
            }
            
            if(
    $name) {
                
    $range2 range(3,64);
                if(!
    in_array(strlen($name),$range2)) {
                    
    errors[] = "Name must be in between 3 and 64 characters!";
                }
            }
            
            if(
    $aim) {
                
    $range3 range(3,16);
                if(!
    in_array(strlen($aim),$range3)) {
                    
    errors[] = "AIM  screename must be in between 3 and 16 characters!";
                }
            }
            
            if(
    $username) {
                
    $sql "SELECT * FORM 'users' WHERE 'username'='{$username}'";
                
    $res mysql_query($sql) or die (mysql_error());
                
                    if(
    mysql_num_rows($res) > {
                        
    $errors[] = "The username you supplied is already in use!"
                    
    }
            }
            if(
    $email) {
                 
    $sql2 "SELECT * FORM 'users' WHERE 'email'='{$email}'";
                
    $res2 mysql_query($sql2) or die (mysql_error());
                
                    if(
    mysql_num_rows($res) > {
                        
    $errors[] = "The e-mail address you supplied is already in use!";
                    }
            }
            
                    if(
    $aim) {
                 
    $sql3 "SELECT * FORM 'users' WHERE 'aim'='{$aim}'";
                
    $res3 mysql_query($sql3) or die (mysql_error());
                
                    if(
    mysql_num_rows($res3) > {
                        
    $errors[] = "The AIM address you supplied is already in use!";
                    }
            }
            
            if(
    count($errors 0) {
                foreach(
    $errors AS $error {
                    echo 
    $error "<br>\n";
                }
            }else {
                
    $sql4 "INSERT INTO 'users'
                        ('username', 'password', 'email', 'name', 'aim')
                         VALUES ('$username','"
    .md5($password)."','$email', '$name', 'aim');";
                
    $res4 mysql_query($sql4) or die(mysql_error());
                echo 
    "Your have successfully registered with the username of <b>{$username}</b> and the password of <b>{$password}</b>";
            }
    }

    ?>
    Last edited by westes; 08-13-2008 at 03:01 AM.

  • #2
    New Coder
    Join Date
    Jul 2008
    Location
    New York
    Posts
    24
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Arrow

    Watch your syntax, multiple errors through out, I reposted your code with the comments of where your errors are.

    PHP Code:
    <?php
    include("functions.php");

    connect();

    if(!
    $_POST['submit']){
    echo 
    "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
    echo 
    "form method=\"post\" action=\"register.php\">\n";
    echo 
    "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n";
    echo 
    "<tr><td>Username</td><td><input type=\"text\" name=\"password\"></td></tr>\n";
    echo 
    "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td</tr>\n";
    echo 
    "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td</tr>\n";
    echo 
    "<tr><td>E-mail</td><td><input type=\"text\" name=\"email\"></td</tr>\n";
    echo 
    "<tr><td>Name</td><td><input type=\"text\" name=\"name\"></td</tr>\n";
    echo 
    "<tr><td>AIM Address</td><td><input type=\"text\" name=\"aim\"></td</tr>\n";
    echo 
    "<tr><td colspan=\"2\" align=\"center\"<input type=\"submit\" name=\"submit\" value =\"Register\"></td></tr>\n";
    }else {
    $username protect($_POST['username']);
    $password protect($_POST['password']);
    $confirm protect($_POST['passconf']);
    $email protect($_POST['email']);
    $name protect($_POST['name']);
    $aim protect($_POST['aim']);

    $errors = array();

    if(!
    $username) {
    $errors[] = "Username is not defined!";
    }

    if(!
    $password) {
    $errors[] = "Password is not defined!";
    }

    if(!
    $password) {
    if(!
    $confirm) {
    $errors[] = "Confirmation password is not defined!";
    }
    }

    if(!
    $email) {
    $errors[] = "E-mail is not defined!";
    }

    if(!
    $name) {
    $errors[] = "Name is not defined!";
    }

    if(
    $username) {
    if(!
    ctype_alnum($username)) {
    $errors[] = "Username can only contaion numbers and letters!";
    }

    $range range(1,32);
    if(!
    in_array(strlen($username),$range)) {
    $errors[] = "Username must be in between 1 and 32 characters!";  // HERE - MISSING $ IN FRONT OF ERRORS
    }
    }

    if(
    $password && $confirm) {
    if (
    $password != $confirm) {
    $errors[] = "Passwords do not match!";
    }
    }

    if(
    $name) {
    $range2 range(3,64);
    if(!
    in_array(strlen($name),$range2)) {
    $errors[] = "Name must be in between 3 and 64 characters!";  // HERE - MISSING $ IN FRONT OF ERRORS
    }
    }

    if(
    $aim) {
    $range3 range(3,16);
    if(!
    in_array(strlen($aim),$range3)) {
    $errors[] = "AIM screename must be in between 3 and 16 characters!";  // HERE - MISSING $ IN FRONT OF ERRORS
    }
    }

    if(
    $username) {
    $sql "SELECT * FORM 'users' WHERE 'username'='{$username}'";
    $res mysql_query($sql) or die (mysql_error());

    if(
    mysql_num_rows($res) > 0) {                // HERE - MISSING CLOSING )
    $errors[] = "The username you supplied is already in use!";        //  HERE - MISSING ;
    }
    }
    if(
    $email) {
    $sql2 "SELECT * FORM 'users' WHERE 'email'='{$email}'";
    $res2 mysql_query($sql2) or die (mysql_error());

    if(
    mysql_num_rows($res) > 0) {        // HERE - MISSING CLOSING )
    $errors[] = "The e-mail address you supplied is already in use!";
    }
    }

    if(
    $aim) {
    $sql3 "SELECT * FORM 'users' WHERE 'aim'='{$aim}'";
    $res3 mysql_query($sql3) or die (mysql_error());

    if(
    mysql_num_rows($res3) > 0) {        // HERE - AND AGAIN MISSING CLOSING )
    $errors[] = "The AIM address you supplied is already in use!";
    }
    }

    if(
    count($errors 0)) {        // HERE - ANOTHER MISSING )
    foreach($errors AS $error) {    // HERE - YET ANOTHER MISSING )
    echo $error "<br>\n";
    }
    }else {
    $sql4 "INSERT INTO 'users'
    ('username', 'password', 'email', 'name', 'aim')
    VALUES ('$username','"
    .md5($password)."','$email', '$name', 'aim');";
    $res4 mysql_query($sql4) or die(mysql_error());
    echo 
    "Your have successfully registered with the username of <b>{$username}</b> and the password of <b>{$password}</b>";
    }
    }

    ?>

  • #3
    New Coder
    Join Date
    Aug 2008
    Posts
    64
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Those are already there

    THOSE WHERE ALREADY THERE


    PHP Code:
    <?php 
    include("functions.php"); 

    connect(); 

    if(!
    $_POST['submit']){ 
    echo 
    "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"
    echo 
    "form method=\"post\" action=\"register.php\">\n"
    echo 
    "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n"
    echo 
    "<tr><td>Username</td><td><input type=\"text\" name=\"password\"></td></tr>\n"
    echo 
    "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td</tr>\n"
    echo 
    "<tr><td>Confirm</td><td><input type=\"password\" name=\"passconf\"></td</tr>\n"
    echo 
    "<tr><td>E-mail</td><td><input type=\"text\" name=\"email\"></td</tr>\n"
    echo 
    "<tr><td>Name</td><td><input type=\"text\" name=\"name\"></td</tr>\n"
    echo 
    "<tr><td>AIM Address</td><td><input type=\"text\" name=\"aim\"></td</tr>\n"
    echo 
    "<tr><td colspan=\"2\" align=\"center\"<input type=\"submit\" name=\"submit\" value =\"Register\"></td></tr>\n"
    }else { 
    $username protect($_POST['username']); 
    $password protect($_POST['password']); 
    $confirm protect($_POST['passconf']); 
    $email protect($_POST['email']); 
    $name protect($_POST['name']); 
    $aim protect($_POST['aim']); 

    $errors = array(); 

    if(!
    $username) { 
    $errors[] = "Username is not defined!"


    if(!
    $password) { 
    $errors[] = "Password is not defined!"


    if(!
    $password) { 
    if(!
    $confirm) { 
    $errors[] = "Confirmation password is not defined!"



    if(!
    $email) { 
    $errors[] = "E-mail is not defined!"


    if(!
    $name) { 
    $errors[] = "Name is not defined!"


    if(
    $username) { 
    if(!
    ctype_alnum($username)) { 
    $errors[] = "Username can only contaion numbers and letters!"


    $range range(1,32); 
    if(!
    in_array(strlen($username),$range)) { 
    $errors[] = "Username must be in between 1 and 32 characters!";  // HERE - MISSING $ IN FRONT OF ERRORS-------NO ITS IN FRONT OF IT



    if(
    $password && $confirm) { 
    if (
    $password != $confirm) { 
    $errors[] = "Passwords do not match!"



    if(
    $name) { 
    $range2 range(3,64); 
    if(!
    in_array(strlen($name),$range2)) { 
    $errors[] = "Name must be in between 3 and 64 characters!";  // HERE - MISSING $ IN FRONT OF ERRORS ------ITS THERE



    if(
    $aim) { 
    $range3 range(3,16); 
    if(!
    in_array(strlen($aim),$range3)) { 
    $errors[] = "AIM screename must be in between 3 and 16 characters!";  // HERE - MISSING $ IN FRONT OF ERRORS ITS THERE



    if(
    $username) { 
    $sql "SELECT * FORM 'users' WHERE 'username'='{$username}'"
    $res mysql_query($sql) or die (mysql_error()); 

    if(
    mysql_num_rows($res) > 0) {                // HERE - MISSING CLOSING ) -----NO ITS TWO LINES DOWN
    $errors[] = "The username you supplied is already in use!";        //  HERE - MISSING ; ------ITS THERE


    if(
    $email) { 
    $sql2 "SELECT * FORM 'users' WHERE 'email'='{$email}'"
    $res2 mysql_query($sql2) or die (mysql_error()); 

    if(
    mysql_num_rows($res) > 0) {        // HERE - MISSING CLOSING ) -------ITS THERE
    $errors[] = "The e-mail address you supplied is already in use!"



    if(
    $aim) { 
    $sql3 "SELECT * FORM 'users' WHERE 'aim'='{$aim}'"
    $res3 mysql_query($sql3) or die (mysql_error()); 

    if(
    mysql_num_rows($res3) > 0) {        // HERE - AND AGAIN MISSING CLOSING )-------- ITS THERE
    $errors[] = "The AIM address you supplied is already in use!"



    if(
    count($errors 0)) {        // HERE - ANOTHER MISSING )  -------ITS THERE
    foreach($errors AS $error) {    // HERE - YET ANOTHER MISSING ) ------ITS THERE
    echo $error "<br>\n"

    }else { 
    $sql4 "INSERT INTO 'users' 
    ('username', 'password', 'email', 'name', 'aim') 
    VALUES ('$username','"
    .md5($password)."','$email', '$name', 'aim');"
    $res4 mysql_query($sql4) or die(mysql_error()); 
    echo 
    "Your have successfully registered with the username of <b>{$username}</b> and the password of <b>{$password}</b>"



    ?>

  • #4
    New Coder
    Join Date
    Jul 2008
    Location
    New York
    Posts
    24
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Arrow

    If you look at your first post you are missing all those things, when I made the comments I also corrected your code. Sorry for the miscommunication.


  •  

    Tags for this Thread

    Posting Permissions

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