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 6 of 6
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Problems with Register Script

    what the hell is wrong with this code ??? please help

    PHP Code:
    <html>

    <head>
      <title></title>
    </head>

    <body>

    <?

    // set this
    $db_host "localhost";
    $db_username "root";
    $db_password "*******";
    $database "mydb";

    // REGISTER
    // ok always remember this baby ;)


    if($_POST['submit']) {


    // lets check they didnt leave the god damned things blank
    // for future reference
    // name = $name = $_POST['name']
    // lastname = $lname = $_POST['lname']
    // email address = $email = $_POST['email']
    // age = $age = $_POST['age']
    // username = $user = $_POST['user']
    // password = $pass = $_POST['pass'] remember to md5
    // signdate = now()

    $name $_POST['name'];
    $lname $_POST['lname'];
    $email $_POST['email'];
    $user $_POST['user'];
    $pass $_POST['pass'];
    $age $_POST['age'];

    // make sure no users typed any characters that they shouldnt have

    $name stripslashes($name);
    $lname stripslashes($lname);
    $email stripslashes($email);
    $user stripslashes($user);
    $age stripslashes($age);


    //check if they entered it
                              
    if(!$name) {
                              echo 
    "<font color=\"red\"><b>Please enter your first name</font></b>";
                              die;
                              }
                              if(!
    $lname) {
                              echo 
    "<font color=\"red\"><b>Please enter your last name</font></b>";
                              die;
                              }
                              if(!
    $email) {
                              echo 
    "<font color=\"red\"><b>Please enter your email</font></b>";
                              die;
                              }
                              if(!
    $user) {
                              echo 
    "<font color=\"red\"><b>Please enter a username</font></b>";
                              die;
                              }
                              if(!
    $pass) {
                              echo 
    "<font color=\"red\"><b>Please enter a password</font></b>";
                              die;
                              }

    // make the password md5 secure ;)
    $monkey $pass;
    $pass md5($pass);
    // see if they already exist
    $username_check mysql_query("SELECT username FROM users WHERE username='$username'");
    $email_check mysql_query("SELECT email_address FROM users WHERE email_address='$email'");
    $norow_username mysql_num_rows($username_check);
    $norow_email mysql_num_rows($email_check);
    if (
    $norow_username 0) {
      echo 
    "<font color=/"red/"><b>Sorry username already exists :D</b></font>";
      unset(
    $user);
        die;
    }

    if (
    $norow_email 0) {
    echo 
    "<font color=\"red\"><b>Sorry email address is already registered</b></font>";
    unset(
    $email);
    die;
    }

    // ok lets put it in :D

    $conn mysql_connect($db_host,$db_username,$db_password) or die ("Problems connecting to mysql".mysql_error());
    mysql_select_db ($database,$conn) or die ("Could not select database");

    // connected!
    //oops forgot to register time ;)
    $mydate now();


    $queryone "INSERT INTO users
    ('first_name','last_name','email_address','username','password','age','signup_date')
    VALUES
    ('$name','$lname','$email','$user','$pass','$mydate')"
    ;
    mysql_query($queryone$conn);
    if(!
    queryone) {
    echo 
    "There has been a error creating your account";
    } else {
    $userid mysql_insert_id();
    $to $email;
    $subject "Membership at TiG, $name $lname";
    $message "Dear $name $lname

    you have recently signed up at TiG, we thank you for this...
    you must click the link below to activate your account thank you

    click here: http://tig.deathdragon.net/test/activate.php?id=$userid&code=$pass

    if the link does not appear copy the link to your address bar

    You signed up with the following information
    Username : $user
    Password : $monkey

    Thanks!
    TiG Staff

    This is a automatic response please do not reply!"
    ;
    mail($to$subject$message,
            
    "From: TiG\n
            X-Mailer: PHP/" 
    phpversion());

    echo 
    "Your membership details have been mailed to the address supplied please follow the instructions in the email";
    }
    }else {
    ?>
    <form method=post action="register.php">
    <b>First Name*   : </b><input type="text" name="name"><br />
    <b>Last Name*    : </b><input type="text" name="lname"><br />
    <b>Email Address*: </b><input type="text" name="email"><br />
    <b>Age*          : </b><input type="text" name="age"><br />
    <b>Username*     : </b><input type="text" name="user"><br />
    <b>Password*     : </b><input type="text" name="pass"><br />
    <input type="submit" name="submit"><br>
    <b>* = Required</b>
    </form>
    <?
    }
    ?>


    </body>

    </html>
    I just get a blank screen , argh
    Last edited by missing-score; 05-04-2004 at 11:03 PM. Reason: Added a more descriptive title
    ...not bad for a thirteen year old

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just a quick look revealed that your checking username and email with a mysql query and you havent connected to the database untill further into the script

  • #3
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    line 83 " escaped with / sould be \

    line 23 sould be
    PHP Code:
    if(isset($_POST['submit'])) { 
    lines 36 to 49 could be shortened like so
    PHP Code:
    $name stripslashes($_POST['name']); 

    line 78 reffers to $username which dosent exsist

    and you might want to add
    PHP Code:
    error_reporting(E_ALL); 
    to the start of you script so you can see any error messages, remove it once development is done

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi ASPdude, a couple of things to consider next time you post:

    • Your post title should be descriptive of what you are attempting to do... I will change the thread title to "Problems with Register Script"
    • The wording in your post was not extremely helpful... "why the hell wont this work" isn't really the best thing to say... You could say what you have tried and give some more in depth information.


    I understand that you are new here, so I wont go on and on, but please consider reading our posting guidelines at http://www.codingforums.com/postguide.htm

  • #5
    New Coder
    Join Date
    Apr 2004
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool ok :s

    ok a few things : I thought the 'isset' function was optional. ??? :: What does that error thing do ??

    thank you for all your help and sorry bout all the bad grammer topics and comments
    ...not bad for a thirteen year old

  • #6
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    while the script is still likley to function without the isset, it should always be used to check the presence of a variable... On systems with higher error reporting, if you check a variable without isset, you will get an error.

    The error reporting section, which has E_ALL within it, turns up error reporting to display all errors... If you dont use isset here you will get errors. It is always a good idea to have error reporting set to E_ALL for testing so you can see all errors as they happen.


  •  

    Posting Permissions

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