...

View Full Version : Registration page



Marcus Maximus
03-12-2007, 10:41 PM
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


<?
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>

Fou-Lu
03-13-2007, 02:03 AM
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!

Inigoesdr
03-13-2007, 06:35 AM
$_REQUEST['Username'] as your request method
You should use $_POST, not $_REQUEST.

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum