Opinions? And yes, you can use this if you would like.
1. I know it doesn't REALLY register a user
2. I now know 'echo' is faster than 'print'. Stop bothering me about that! >.<
Register.html:
[lua]
<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>
[/lua]
handle_reg.php:
[lua]
<html>
<title>Registration</title>
<style type="text/css" media="screen">
.error { color: red; }
</style>
<h1>Registration Results</h1>
<?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 and 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;
}
//Vailidate year
if ( is_numeric($_POST['year']) AND (strlen($_POST['year']) == 4) ) {
//check that they were born before 2009
if ($_POST['year'] >= 2009) {
print '<p class="error"> Either you come from the future, or you entered your birthdate wrong!</p>';
} else {
$birthday .= $_POST['year'];
}
} else {
print '<p class="error">Please enter your birthdate as four digits.</p>';
$okay = FALSE;
}
$birthday = "";
if (is_numeric($_POST['month'])) {
$birthday = $_POST['month'] . '-';
} else {
print '<p class="error">Please select the month you were born</p>';
$okay = FALSE;
}
if (is_numeric($_POST['day'])) {
$birthday .= $_POST['day'] . '-';
} else {
print '<p class="error">Please select the day you were born</p>';
$okay = FALSE;
//If there were no errors, This is what comes up.
if ($okay) {
print '<p>You have been succsessfully registered! (but not really lol).</p>;
}
?>
</body>
</html>
[/lua]
I forgot to mention:
I know I need work on my CSS and HTML. I can't find anything to learn from that's good enough.
1. I know it doesn't REALLY register a user
2. I now know 'echo' is faster than 'print'. Stop bothering me about that! >.<
Register.html:
[lua]
<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>
[/lua]
handle_reg.php:
[lua]
<html>
<title>Registration</title>
<style type="text/css" media="screen">
.error { color: red; }
</style>
<h1>Registration Results</h1>
<?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 and 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;
}
//Vailidate year
if ( is_numeric($_POST['year']) AND (strlen($_POST['year']) == 4) ) {
//check that they were born before 2009
if ($_POST['year'] >= 2009) {
print '<p class="error"> Either you come from the future, or you entered your birthdate wrong!</p>';
} else {
$birthday .= $_POST['year'];
}
} else {
print '<p class="error">Please enter your birthdate as four digits.</p>';
$okay = FALSE;
}
$birthday = "";
if (is_numeric($_POST['month'])) {
$birthday = $_POST['month'] . '-';
} else {
print '<p class="error">Please select the month you were born</p>';
$okay = FALSE;
}
if (is_numeric($_POST['day'])) {
$birthday .= $_POST['day'] . '-';
} else {
print '<p class="error">Please select the day you were born</p>';
$okay = FALSE;
//If there were no errors, This is what comes up.
if ($okay) {
print '<p>You have been succsessfully registered! (but not really lol).</p>;
}
?>
</body>
</html>
[/lua]
I forgot to mention:
I know I need work on my CSS and HTML. I can't find anything to learn from that's good enough.