Web Design and Web Development Forum

  1. #1
    grantmc1's Avatar
    Join Date
    May 2006
    Location
    Dumfries, Scotland
    Age
    20
    Posts
    95
    Rep Power
    7
  2. grantmc1 is on a distinguished road
  3. htlp with registering script

    hi there i need help witha registering script can any body debug this for me ?
    [highlight=php]
    <?php
    $firstname = $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $username = $_POST['username'];
    $password = $_POST['password'];

    if(!$firstname or !$lastname or !$username or !$password)
    {
    $form ="Please enter all you detail...";
    $form.="<form action='register.php' method='post'>";
    $form.="First Name: <input type='text' name='firstname'>";
    $form.="<br />Last Name: <input type='text' name='lastname'>";
    $form.="<br />Username: <input type='text' name='username'>";
    $form.="<br />Password: <input type='password' name='password'>";
    $form.="<br /><input type='submit' value='submit'>";
    $form.="</form>";
    echo($form);
    }
    else
    {
    $conn = mysql_connect("localhost","ngssrerv","-----") or die (mysql_error());
    $dbh = mysql_connect ("localhost", "ngssrerv_grantmc", "-----") or die ('I cannot connect to the database because: ' . mysql_error());
    $sql = mysql_select_db ("ngssrerv_main"); mysql_query("INSERT INTO users (FirstName,LastName,Username,Password) VALUES ('$firstname','$lastname','$username','password')" ) or die(mysql_error());
    {
    echo("New user $username added");
    }
    ?>
    <html>
    <head>
    <title>Register to GrantMc.co.uk</title>
    </head>

    <body>

    </body>
    </html>
    [/highlight]
    look at www.grantmc.co.uk/new/register.php to see what the original problem is

    thank you in advance for any help!
    Last edited by unclekyky; 06-26-2006 at 10:54 AM. Reason: added php tags
    Reply With Quote Reply With Quote
  4. #2
    unclekyky's Avatar
    Join Date
    Sep 2004
    Age
    22
    Posts
    5,184
    Rep Power
    13
  5. unclekyky is on a distinguished road
  6. Re: htlp with registering script

    you have not closed the last else statement (you need another bracket).

    EDIT: Actually, I think the problem might be the extra bracket you have on line 24.
    Last edited by unclekyky; 06-26-2006 at 10:53 AM.
    Spore-Game - The Ultimate Spore Fan-Site
    Abnegating Avunculicide Since 1601 | YC Wiki - "Quidquid latine dictum sit, altum sonatur."
    Reply With Quote Reply With Quote
  7. #3
    Join Date
    Mar 2006
    Location
    Toronto, Ontario
    Posts
    2,270
    Rep Power
    9
  8. Nick Presta is on a distinguished road
  9. Re: htlp with registering script

    Also, you should use this to check if a field hasn't been entered,

    PHP Code:

    $username 
    trim($_POST['username']);
    ...

    if(!isset(
    $username) && empty($username)) {
    die(
    "Please enter your username");
    }
    ... 
    Last edited by Nick Presta; 06-26-2006 at 01:34 PM.
    Reply With Quote Reply With Quote

Similar Threads

  1. help on a upload script
    By grantmc1 in forum PHP Scripting
    Replies: 3
    Last Post: 05-08-2006, 04:27 PM
  2. Need help installing a script!!!!
    By fishhits in forum PHP Scripting
    Replies: 0
    Last Post: 11-06-2005, 05:16 PM
  3. PHP mail script
    By eazman in forum PHP Scripting
    Replies: 7
    Last Post: 06-06-2005, 01:53 PM
  4. PHP News Script
    By unclekyky in forum PHP Articles
    Replies: 0
    Last Post: 09-03-2004, 08:07 PM