Location: PHPKode > projects > WaveWatcher > wavewatcher3/html/register.php
<?
	
	session_start();
	
	// Include class User
	require_once("../classes/user.php");

	// No errors at start
	$err = false;

	if ($HTTP_POST_VARS)
	{
		$username = $HTTP_POST_VARS["username"];
		$password = $HTTP_POST_VARS["password1"];
		$email = $HTTP_POST_VARS["email"];
		$company = $HTTP_POST_VARS["company"];
		$location = $HTTP_POST_VARS["location"];
		$phone = $HTTP_POST_VARS["phone"];
	
		$user = new User();
		
		if ($user->SetUserDetails($username, $password, $company, $email, $location, $phone) > 0)
		{
			// Registrering ok... forts├Ątt till loginrutan.
			header("Location: index.php");
		}
		else
		{
			$err = true;
		}
		
	}

?>

<html>
	<head>
		<title>Wavewatcher Registration</title>
		<script>
			function CheckForm()
			{
				if (navigator.appName != "Netscape")
				{
					// Check form
					var strMsg = "";

					// 1. Name must not be empty!
					if (document.forms("register").item("username").value == "")
						strMsg += "You must enter an username!\n";

					// 2. Password must not be empty
					if (document.forms("register").item("password1").value == "")
						strMsg += "You must enter a password\n";
					

					// 3. Password and the confirmed password must be equal
					if (document.forms("register").item("password1").value != document.forms("register").item("password2").value)
						strMsg += "Please check your password!\n";

					// 4. Email must not be empty!
					if (document.forms("register").item("email").value == "")
						strMsg += "You must enter an email address!\n";

					// If errors, show them, else register user!
					if (strMsg != "")
						alert(strMsg);
					else
						document.register.submit();
				}
				else
				{
					// Check form
					var strMsg = "";

					// 1. Name must not be empty!
					if (document.register.username.value == "")
						strMsg += "You must enter an username!\n";

					// 2. Password must not be empty
					if (document.register.password1.value == "")
						strMsg += "You must enter a password\n";

					// 3. Password and the confirmed password must be equal
					if (document.register.password1.value != document.register.password2.value)
						strMsg += "Please check your password!\n";

					// 4. Email must not be empty!
					if (document.register.email.value == "")
						strMsg += "You must enter an email address!\n";

					// If errors, show them, else register user!
					if (strMsg != "")
						alert(strMsg);
					else
						document.register.submit();

				}
			}
		</script>
		<link href="css/style1.css" rel="styleSheet" type="text/css">
	</head>

	<body bgcolor="#ffffff">

	<form name="register" method="post">
	
	<table width = "50%" height="80%" align="center" border="0">
		<tr>
			<td>
				<!-- background table -->
				<table width="350" align="center" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
					<tr>
						<td>
							<!-- gui table -->
							<table width="350" border="0" cellspacing="1" cellpadding="2">
								
								<!-- title row -->
								<tr>
									<td bgcolor="#515173">
										<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b>Wavewatcher registration...</b></font>
									</td>
								</tr>
							
								<!-- message row -->
								<? 
								if ($err)
								{ 
								?>

								<tr>
									<td bgcolor="#FC4848">
										<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
											Registration failed. 
										</font>
									</td>
								</tr>

								<?	
								}
								else
								{
								?>
								<tr>
									<td bgcolor="#c0c0c0">
										<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
											To use wavewatcher you must register. Please fill in the form below, * means must!
										</font>
									</td>
								</tr>
								<?
								}
								?>
								<!-- username and password row -->
								<tr bgcolor="#fcfcfc">
									<td>
										<table width="100%" border="0" cellspacing="0" cellpadding="2">
											<tr>
												<td width="150" align="right">
													<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">Username (*): </font>
												</td>
												<td width="200">
													<input name="username" type="text" size="25">
												</td>
											</tr>
											<tr>
												<td width="150" align="right">
													<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">Password (*): </font>
												</td>
												<td width="200">
													<input name="password1" type="Password" size="25">
												</td>
											</tr>
											<tr>
												<td width="150" align="right">
													<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">Confirm password (*): </font>
												</td>
												<td width="200">
													<input name="password2" type="Password" size="25">
												</td>
											</tr>
											<tr>
												<td width="150" align="right">
													<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">Email (*): </font>
												</td>
												<td width="200">
													<input name="email" type="text" size="25">
												</td>
											</tr>
											<tr>
												<td width="150" align="right">
													<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">Company: </font>
												</td>
												<td width="200">
													<input name="company" type="text" size="25">
												</td>
											</tr>
											<tr>
												<td width="150" align="right">
													<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">Location: </font>
												</td>
												<td width="200">
													<input name="location" type="text" size="25">
												</td>
											</tr>
											<tr>
												<td width="150" align="right">
													<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">Phone: </font>
												</td>
												<td width="200">
													<input name="phone" type="text" size="25">
												</td>
											</tr>

										</table>
									</td>
								</tr>

								<!-- Submit -->
								<tr bgcolor="#fcfcfc">
									<td align="center">
										<input name="register" type="button" value="Register" onClick="javascript:CheckForm();">
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>

	</form>

	</body>
<html>
Return current item: WaveWatcher