SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member Cas's Avatar
    Join Date
    Jun 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sitepoint tutorial, help needed

    I am trying to get to grips with user login and sessions. I've ran this sript by kevin Yankl on my server and everything loads ok (the form). However when I submit the form or leave a field blank nothing seems to happen, no error message or anything. The Form just reloads. I have all the php includes in the same directory.
    Where am I going wrong.
    Thank you in advance for any help.


    <?php //signup.php

    include("common.php");
    include("db.php");

    if (!isset($submitok)):
    // Display the user signup form
    ?>

    <html>
    <head><title>New User Registration</title></head>
    <body>
    <h3>New User Registration Form</h3>
    <p><font color=orangered size=+1><TT><B>*</b></tt></font>
    indicates a required field</p>
    <form method=post action="<?php echo $PHP_SELF; ?>">
    <table border=0 cellpadding=0 cellspacing=5>
    <tr>
    <td align=right>
    <p>User ID</p>
    </td>
    <td>
    <input name=newid type=text maxlength=100 size=25>
    <font color=orangered size=+1><TT><B>*</b></tt></font>
    </td>
    </tr>
    <tr>
    <td align=right>
    <p>Full Name</p>
    </td>
    <td>
    <input name=newname type=text maxlength=100 size=25>
    <font color=orangered size=+1><TT><B>*</b></tt></font>
    </td>
    </tr>
    <tr>
    <td align=right>
    <p>Email Address</p>
    </td>
    <td>
    <input name=newmail type=text maxlength=100 size=25>
    <font color=red size=+1><TT><B>*</b></tt></font>
    </td>
    </tr>
    <tr valign=top>
    <td align=right>
    <p>Other Notes</p>
    </td>
    <td>
    <textarea wrap name=newnotes rows=5 cols=30></textarea>
    </td>
    </tr>
    <tr>
    <td> <td align=right colspan=2>
    <hr noshade colour=black>
    <input type=reset value="Reset Form">
    <input type=submit name="submittok" value=" OK ">
    </td>
    </tr>
    </table>
    </form>

    </body>
    </html>


    <?php

    else:

    // Process signup submission
    dbConnect('sessions');

    if ($newid=="" or $newname=="" or $newemail=="") {
    error("One or more required fields were left blank.\\n".
    "Please fill them in and try again.");

    }

    // Check for existing user with the new id

    $sql = "SELECT COUNT (*) FROM user WHERE userid = '$newid'";
    $result = mysql_query($sql);
    if (!$result) {
    error("Adatabase error occurred in processing your ".
    "SUBMISSION.\\nIf this error persists, please ".
    "contact me@somewhere.Net.");
    }
    if (mysql_result($result,0,0)>0) {
    error("A user already exists with your chosen userid.\\n".
    "Please try another.");
    }

    $newpass = substr(md5(time()),0,6);

    $sql = "INSERT INTO user SET
    userid = '$newid',
    password = PASSWORD('$newpass'),
    fullname = '$newname',
    email = '$email''
    notes = '$newnotes'";
    if (!mysql_query($sql))
    error("A database error occured in processing your ".
    "submission.\\nIf this error persists, please ".
    "contact me@somewhere.Net");


    // Email the new password to the person.
    $message = "G'Day!


    Your personal account for the Project Web Sitehas
    been created! To log in, proceed to the
    following address:

    http://www.theproject.com/

    Your personal login ID and password are as follows:

    userid: $newid
    password: $newpass

    You aren't stuck with this password!
    You can change it at any time after you have logged in.
    If you have any problems, feel free to contact me at
    <kevin@sitepoint.com>.
    -Kevin Yank Project Webmaster";

    mail($newemail,"Your Password for the Project Website",
    $message, "From:Kevin Yank <kevin@sitepoint.com>");

    ?>
    <html>
    <head>
    <title> Registration Complete </title>
    </head>
    <body>
    <p><strong>User registration successful!</strong></p>
    <p>Your userid and password have been emailed to
    <strong><?=$newemail?></strong>, the email address
    you just provided in your registration form. To log in,
    click <a href="index.php">here</a> to return to the login
    page, and enter your new personal userid and password.</p>
    </body>
    </html>

    <?php

    endif;


    ?>
    "Tell me and I will forget , show me and I'll learn.
    Involve me and I will remember. " Confucius.

  2. #2
    SitePoint Zealot New Oddity's Avatar
    Join Date
    Jun 2001
    Location
    Georgia
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First off, put you script inside [#php] ...code... [#/php]
    do it w/o the hashes (#). It will be easier for someone to help you.
    --Odd
    "We all live in a yellow subroutine."
    "Some call it insanity; I call it inspiration!"

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change

    <input type=submit name="submittok" value=" OK ">

    to

    <input type=submit name="submitok" value=" OK ">

    and all should work. You named the sumit button submittok and then checked the value of submitok. Thus submitting the form was not setting the value of submitok.
    Marty H.


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
  •