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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Registration page

    Im trying to set up a registration form that returns the user to the form if they forget to fill some fields but i would like not to clear the fields. I haven't got around to displaying the error message to the users yet

    PHP Code:
    <?
    if( ( isset($_POST['Account_Username']) && isset($_POST['Account_Password']) 
    && isset(
    $_POST['Account_PasswordConfirm']) && isset($_POST['Contact_FullName'])  
    && isset(
    $_POST['Contact_Email']) ) )
    {
        
    $Username $_POST['Account_Username'];
        
    $Password $_POST['Account_Password'];
        
    $ConfirmP $_POST['Account_PasswordConfirm'];
        
    $FullName $_POST['Contact_FullName'];
        
    $Address1 $_POST['Contact_StreetAddress'];
        
    $Address2 $_POST['Contact_Address2'];
        
    $City $_POST['Contact_City'];
        
    $Province $_POST['Contact_County'];
        
    $Country $_POST['Contact_Country'];
        
    $Email $_POST['Contact_Email'];
        
        include(
    "connection.php");

        
    #create the sql query
        
    $sql "INSERT INTO users
        (Username, Password, FullName, Address1, Address2, City, Province, Country, Email)
        VALUES
        ('$Username', PASSWORD('$Password'), '$FullName', '$Address1', '$Address2', '$City', '$Province', '$Country', '$Email')"


        
    $sql2 "CREATE TABLE $Username (blobId int auto_increment not null, blobTitle varchar(50), blobData longblob,
                                            blobType varchar(50), primary key(blobId))"
    ;
        
    #execute the query
        
    $res mysql_query($sql$conn)
        or die (
    "Could not execute query: ".mysql_error());

        
    $res2 mysql_query($sql2$conn)
        or die (
    "Could not execute query: ".mysql_error());
    }
    ?>

    <HTML>
    <HEAD>
    <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
    <meta http-equiv="Content-Language" content="en-us">
    <TITLE>Secure Online Backup - Registration</TITLE>
    </HEAD>
    <BODY>
    <h1>Secure Online Backup User Registration</h1>
    <!--<hr>
    <p>You can automatically register yourself to be a user of Secure Online Backup by filling out and submitting this form. Only registered users are allowed into [Name of your sub site]. Choose a username for yourself (such as your last name) and make sure this username contains no spaces. Also create a private password. Together these will be your &quot;key&quot; into Secure Online Backup from now on. This information will be kept in a registration database that is accessible only to the webmaster, not to ordinary users.</p>
    <p>One of the main benefits of having a restricted access Web site like [Name of your sub site] is that authorized users don't have to keep typing their names into form fields, such as when submitting an article to a discussion group, because the web server already knows who they are. Similarly, other users can be reasonably sure that you really sent the articles and postings attributed to you, and that someone else didn't pretend to be you when posting. </p>
    <p>After you are successfully registered, your web browser will ask you to type in your username and password the first time you try to access [Name of your sub site]. The browser will remember this information for as long as it continues to run, so you can access any document in [Name of your sub site] without being asked for it again.</p>
    <hr>-->
    <P>
    <i>Please fill in the details below to register for the website</i></P>
    <FORM METHOD="POST" ACTION="<? echo $_SERVER["PHP_SELF"];?>">
    --><OL>
    <LI>
    <P>
    Please provide your account information:</P>
    <TABLE>
    <TR>
    <TD ALIGN="right">
    <EM>User Name*</EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Account_Username" value = "<?$Username?>" SIZE=16 MAXLENGTH=16>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>Password*</EM></TD>
    <TD>
    <INPUT TYPE=PASSWORD NAME="Account_Password" value = "<?$Password?>" SIZE=16 MAXLENGTH=16>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>Confirm Password*</EM></TD>
    <TD>
    <INPUT TYPE=PASSWORD NAME="Account_PasswordConfirm" value = "<?$ConfirmP?>" SIZE=16 MAXLENGTH=16>
    </TD>
    </TR>
    </TABLE>
    <p>&nbsp;<LI>
    <P>
    Please provide the following contact information:</P>
    <TABLE>
    <TR>
    <TD ALIGN="right">
    <EM>Name*</EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Contact_FullName" value = "" value = "<?$FullName?>" SIZE=35>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>Address Line 1</EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Contact_StreetAddress" value = "<?$Address1?>" SIZE=35>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>Address Line 2 </EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Contact_Address2" value = "<?$Address2?>" SIZE=35>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>City</EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Contact_City" value = "<?$City?>" SIZE=35>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>State/County</EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Contact_County" value = "<?$Province?>" SIZE=35>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>Country</EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Contact_Country" value = "<?$Country?>" SIZE=14>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="right">
    <EM>E-mail*</EM></TD>
    <TD>
    <INPUT TYPE=TEXT NAME="Contact_Email" value = "<?$Email?>" SIZE=25>
    </TD>
    </TR>
    </TABLE>
    <p>*Fields must be completed</OL>
    <INPUT TYPE=SUBMIT VALUE="Submit Form"> 
    <INPUT TYPE=RESET VALUE="Reset Form">
    </FORM>
    </BODY>
    </HTML>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    There are a few methods to do this.
    One of the more common is the use of sessions, which are (generally) pretty painless to set up, depending on your configurations.
    However, since you are accessing the same page (as in you are sending it back to itself), the form will be easy to repopulate.

    The only problem is that this:
    <?$Username?>
    for instance is not defined. This is because if one of the fields is not set, it will not create a variable under that name. For this, I would instead use $_REQUEST['Username'] as your request method. This also allows you to prefill out sections of the form through the querystring if you would like. The downside: you need to initialize your variables or supress the warnings you might receive.
    Oh, and $Username I don't believe outputs in that manner. I'm not 100% sure on that as I've used templates for so many years, but I believe it needs to be like so:
    <?php echo $varname;?>
    or
    <?=$varname;?>
    (php I think can go into that one, so if your shorttags are disabled it should still be workable)

    Hope that helps you!
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by Fou-Lu View Post
    $_REQUEST['Username'] as your request method
    You should use $_POST, not $_REQUEST.
    Quote Originally Posted by Fou-Lu View Post
    Oh, and $Username I don't believe outputs in that manner. I'm not 100% sure on that as I've used templates for so many years, but I believe it needs to be like so:
    <?php echo $varname;?>
    or
    <?=$varname;?>
    Correct.


  •  

    Posting Permissions

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