PHP: Register Code! (My version)
#1
A simple register code without a connection from the database. Took FOREVER! This kinda stumped me on where to start...

<html>
<title>Registration</title>

<style type="text/css" media="screen">
.error { color: red; }
</style>

<h2>Registration Results</h2>

<?php
$okay = TRUE;

//Validate color
if ($_POST['color'] == 'red') {
print '<p style="color:red;">Red is your favorite color.</p>';
} elseif ($_POST['color'] == 'yellow') {
print '<p style="color:yellow;">Yellow is your favorite color.</p>';
} elseif ($_POST['color'] =='blue') {
print '<p style="color:blue;">Your favorite color is blue.</p>';
} elseif ($_POST['color'] =='green') {
print '<p style="color:green;">Your favorite color is green.</p>';
} elseif ($_POST['color'] =='purple') {
print '<p style="color:purple;">Your favorite color is purple.</p>';
} elseif ($_POST['color'] =='gray/white') {
print '<p style="color:gray;">Your favorite colors is gray/white</p>';
} else {
print '<p class="error">Please select your favorite color.</p>';
$okay = FALSE;
}


print '<p>You have entered your birthday as $birthday</p>';

//validate email address
if (empty($_POST['emial'])) {
print '<p class="error">Oops! Your forgot your email!</p>';
$okay = FALSE;
}

//error on password
if (empty($_POST['password'])) {
print '<p class="error">Oops! Your forgot your password!</p>';
$okay = FALSE;
}

if ($_POST['password'] != $_POST['confirm']) {
print '<p class="error">Your passwords do not match!</p>';
$okay = FALSE;
}

Here is the HTML/Form part:

<html>
<title>Register!</title>
<body>
<div><p>Please fill out this form to register:</div></p>
<form action="handle_reg.php" mehtod="post">

<p>Email: <input type="text" name="email" size="30" /></p>
<p>Password: <input type="password" name="password" size="30" /></p>
<p>Comfirm Password: <input type="password" name="confirm" size="20" /></p>

<p>Date Of Birth:
<select name="month">
<option value="">Month</option>
<option value="1">January</option>
<option value="2">Febuary</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>

<?php
for ($d = 1; $d <= 31; $d++) {
print "<option value=\"$d\">$d</option>\n";
}
?>

<input type="text" name="year" value="YYYY" size="4" /></p>

<p>Favorit Color:
<select name="color">
<option value="">Pick one</option>
<option value="yellow">Yellow</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value="purple">Purple</option>
<option value="gray/white">Gray/White</option>
</select></p>

<input type="submit" name="submit" value="Register" />

</form>
</div>
</body>
</html>
[Image: chaosthegreat.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)