You are on page 1of 7

Neil Alstom B.

Bautista
BSIT-3D

<html>
<style>
table {
width:100%;
margin: 0px 0px 5px 0px;
}
table td {
border: 1px solid black;
padding: 8px 30px;
}
.tblinput {
text-align: left;
border: 1px solid black;
width: 90%;
}
.b1 {
border: 5px ridge black;
margin: 2% 25%;
padding: 1%;
}
span {
color: red;
}
.noticesuccess {
background-color: rgba(0,197,0,0.5);
width:100%;
}
.notice {
background-color: rgba(197,0,0,0.5);
width:100%;
}
</style>
<body>
<?php error_reporting (E_ALL ^ E_NOTICE);
$name = $age = $gender = $email = $terms = "";
if ($_SERVER['REQUEST_METHOD']=='POST'){
if (empty($_POST['name'])){
$nameErr="*Name is required.";
}
else{
$name=val($_POST['name']);
}

if (!is_numeric($_POST['age'])){
$ageErr="*Age is required and should be numeric";
}
if (empty($_POST['age']<= 120))
{
$ageErr="Out of Range.";
}
if (!empty($_POST['age']>=1) && !empty($_POST['age']<=13)){
$ageErr="*Sorry you are under-age. We recommend not to use this site for 13y/old and
below.";
}
if (!empty($_POST['age'])){
$age=val($_POST['age']);
}

if (empty($_POST['gender'])){
$genderErr="*Gender is required.";
}else{
$gender=val($_POST['gender']);
}
if (empty($_POST['email'])){
$emailErr="*Email is required.";
}
else{
$email=val($_POST['email']);
}

if (empty($_POST['terms'])){
$termsErr="*Agreement is required.";
}
elseif (!empty($_POST['terms']=='nope'))
{
$termsErr="*You must Agree to the terms and conditions.";
}else{
$terms=val($_POST['terms']);
}
}
function val($data){
$data=trim($data);
$data=stripslashes($data);
$data=htmlspecialchars($data);
return $data;
}

?>
<div class="b1">
<form method="POST" action = "<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
<b>REGISTER to Among US!</b>
<table cellspacing="0" border="collapse">
<tr>
<td> <b> Name: </b> </td>
<td colspan="2"><input class="tblinput" name="name" type="text" value="<?php echo
$name ?>"><br><span><?php echo
$nameErr; ?></span><br>
</td>
</tr>
<tr>
<td> <b> Age: </b> </td>
<td colspan="2"><input class="tblinput" name="age" type="text" value="<?php echo
$age ?>" ><br><span>
<?php echo $ageErr; ?></span><br>
</td>
</tr>
<tr>
<td> <b> Gender: </b> </td>
<td colspan="2">
<input name="gender" type="radio" <?php if (isset($_POST['gender']) &&
$_POST['gender']=="female")
echo "checked";?> value="female">Female
<input name="gender" type="radio" <?php if (isset($_POST['gender']) &&
$_POST['gender']=="male")
echo "checked";?> value="male" > Male <br><span><?php echo
$genderErr; ?></span><br>
</td>
</tr>
<tr>
<td> <b> Email: </b> </td>
<td colspan="2"><input class="tblinput" name="email" type="text" value="<?php echo
$email ?>" > <br><span><?php echo
$emailErr; ?></span><br>
</td>
</tr>

<tr>
<td colspan="2"> <b> Terms and Conditions: </b> <br>
By using the Site, you represent and warrant that: <br>
1. all registration information you submit will be true, accurate, current, and complete; <br>
2. you will maintain the accuracy of such information and promptly update such registration
information as necessary; <br>
3. you have the legal capacity and you agree to comply with these Terms and Conditions;<br>
4. you are not under the age of 14; <br>
<input name="terms" type="radio" <?php if (isset($_POST['terms']) &&
$_POST['terms']=="agree")
echo "checked";?> value="agree">I Agree. <br>
<input name="terms" type="radio" <?php if (isset($_POST['terms']) &&
$_POST['terms']=="nope")
echo "checked";?> value="nope" >I do not Agree. <br><span><?php echo
$termsErr; ?></span><br>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Register">
<?php

echo "<br>".$name."<br>";
echo $age."<br>";
echo $gender."<br>";
echo $email."<br>";
echo $terms;

if (!empty($_POST['name']) && !empty($_POST['age']) && !empty($_POST['gender']) && !


empty($_POST['email']) && !empty($_POST['terms'])) {
if ($terms=='agree' && $age>13 && $age<=120) {
echo "<br><div class='noticesuccess'><b>REGISTRATION WAS SUCCESSFUL.</b></div>";
}else{
echo "<br><div class='notice'> <b>Sorry, Registration was denied.</b></div>";
}
}
else {
echo "<br><div class='notice'> <b>All fields are required and must agree to terms and
conditions.</b></div>";
}
?>
</form>
</div>
</body>
</html>

You might also like