SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2006
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    connect database

    can someone explaint to me why i cannot have the result :
    this is the login screen, which try to connect to database, I check on the $query, the statement is correct. system return a blank page for me.
    my code as below :

    <?
    session_start();
    include("photoconfig.php");
    function usernameTaken($username){

    if(!get_magic_quotes_gpc()){
    $username = addslashes($username);
    }
    $query = "select diver_name from diverlist where diver_name = '$username'";
    print $query;
    $result = mysql_query($query);
    return (mysql_numrows($result) > 0);
    }
    function addNewUser($username, $password){
    $query = "INSERT INTO diverlist VALUES ('$username', '$password','1','NO','$emailaccount')";
    echo $query;
    return mysql_query($query);
    }

    function displayStatus(){
    $uname = $_SESSION['reguname'];
    if($_SESSION['regresult']){
    ?>

    <h1>Registered!</h1>
    <p>Thank you........... <b><? echo $uname; ?></b>, your information has been added to the database, you may now <a href="index.php" title="Login">log in</a>.</p>

    <?
    }
    else{
    ?>

    <h1>Registration Failed</h1>
    <p>We're sorry, but an error has occurred and your registration for the username <b><? echo $uname; ?></b>, could not be completed.<br>
    Please try again at a later time.</p>

    <?
    }
    unset($_SESSION['reguname']);
    unset($_SESSION['registered']);
    unset($_SESSION['regresult']);
    }

    if(isset($_SESSION['registered'])){
    /**
    * This is the page that will be displayed after the
    * registration has been attempted.
    */
    ?>

    <html>
    <title>Registration Page</title>
    <body>

    <? displayStatus(); ?>

    </body>
    </html>

    <?
    return;
    }

    if(isset($_POST['subjoin'])){
    /* Make sure all fields were entered */
    if(!$_POST['user'] || !$_POST['pass']){
    die('You didn\'t fill in a required field.');
    }

    /* Spruce up username, check length */
    $_POST['user'] = trim($_POST['user']);
    if(strlen($_POST['user']) > 30){
    die("Sorry, the username is longer than 30 characters, please shorten it.");
    }
    echo $_POST['user'] ;
    /* Check if username is already in use */
    if(usernameTaken($_POST['user'])){
    $use = $_POST['user'];
    die("Sorry, the username: <strong>$use</strong> is already taken, please pick another one.");
    }

    /* Add the new account to the database */
    $md5pass = md5($_POST['pass']);
    $_SESSION['reguname'] = $_POST['user'];
    $_SESSION['regresult'] = addNewUser($_POST['user'], $md5pass);
    $_SESSION['registered'] = true;
    echo "<meta http-equiv=\"Refresh\" content=\"0;url=$HTTP_SERVER_VARS[PHP_SELF]\">";
    return;
    }
    else{
    /**
    * This is the page with the sign-up form, the names
    * of the input fields are important and should not
    * be changed.
    */

    include("heading.html");
    ?>

    <html>
    <title>Registration Page</title>
    <body>
    <h1>Register</h1>
    <form action="<? echo $HTTP_SERVER_VARS['PHP_SELF']; ?>" method="post">
    <table align="left" border="0" cellspacing="0" cellpadding="3">
    <tr><td>Username/td><td><input type="text" name="user" maxlength="30"></td></tr>
    <tr><td>Password/td><td><input type="password" name="pass" maxlength="30"></td></tr>
    <tr><td>Email /td><td><input type="text" name="emailaccount" maxlength="50"></td></tr>
    <tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Join!"></td></tr>
    </table>
    </form>
    </body>
    </html>

    <?
    }
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2006
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    system return me with Registration Failed
    We're sorry, but an error has occurred and your registration for the username Carlos antony, could not be completed.
    Please try again at a later time

    and Carlos antony is not in my database, why cannot registered?

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure that your included "heading.html" contains proper codes that you need? And why are you including this?

    Also please format your code with respective tags like php for [PHP] so that it could be read easily.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2006
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    heading.html is the design of the heading in top of the page. just display, it shouldn't affected the connectivity.


Bookmarks

Posting Permissions

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