Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Assignment 4 Form Index </title>
- <style>
- body{
- font-family:"Gill Sans", "Gill Sans MT", Calibri, sans-serif;
- text-align:center;
- background-color: #ccc;
- color:#133926;
- vertical-align:middle;
- }
- form{
- margin-bottom:25px;
- width:40%;
- margin-right:auto;
- margin-left:auto;}
- input,select,textarea{
- margin-bottom:15px;
- padding:12px 20px;}
- .warning{
- color:red;
- font-style:bold;
- margin-bottom:2px;}
- p{
- font-weight:550;
- font-size:18px;
- margin-bottom:2px;
- margin-top:1px;}
- h2{
- margin-bottom:10px;}
- input[type=submit]{
- padding:12px 15px;
- background-color:#003333;
- color:#b3e6cc;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- }
- input[type=submit]:hover{
- background-color: #b3e6cc;
- color:#003333;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- }
- </style>
- </head>
- <body>
- <?php include("includes/header.php") ?>
- <h2>User Sign Up</h2>
- <!--create form-->
- <form action="<?php
- //telling the form how to handle submission; if name, email, comments, radio button, and select are filled in, it redirects to confirm page
- if (($_POST['firstname'] != NULL) && ($_POST['lastname'] != NULL) && ($_POST['username'] != NULL)
- && ($_POST['email'] != NULL) && ($_POST['comments'] != NULL) && ($_POST['orientation'] != NULL) && ($_POST['month'] != NULL) && ($_POST['day'] != NULL) && ($_POST['year'] != NULL))
- {
- echo "confirm.php";
- $_POST['submit'] == "true";
- } else {
- echo "index.php";
- }?>" method="POST" id="event">
- <?php
- //checking if first name is entered
- if (!isset($_POST['firstname'])) {
- echo "";
- } elseif ($_POST['firstname'] == "") {
- echo "<span class=\"warning\"> Please enter your first name!</span><br>";
- }
- ?>
- <label><p>First Name: </p><input type="text" name="firstname" size="20" maxlength="25" value="
- <?php if (isset($_POST['firstname'])){ //making sticky forms
- echo $_POST['firstname'];
- }?>" /> </label> <br/>
- <?php
- //checking if last name is entered
- if (!isset($_POST['lastname'])) {
- echo "";
- } elseif ($_POST['lastname'] == "") {
- echo "<span class='warning'> Please enter your last name!</span><br>";
- }
- ?>
- <label><p>Last Name:</p> <input type="text" name="lastname" size="20" maxlength="25" value="
- <?php if (isset($_POST['lastname'])){
- echo $_POST['lastname'];
- }?>"/></label> <br/>
- <!--Email Input-->
- <?php
- //checking if email is entered
- if (!isset($_POST['email'])) {
- echo "";
- } elseif ($_POST['email'] == "") {
- echo "<span class='warning'> Please enter your email address!</span><br>";
- }
- ?>
- <label><p>Email:</p><input type="text" name="email" size="20" maxlength="40" value="
- <?php if (isset($_POST['email'])){
- echo $_POST['email'];
- }?>" /> </label><br/>
- <!--Username Input-->
- <?php
- //checking if username is entered
- if (!isset($_POST['username'])) {
- echo "";
- } elseif ($_POST['username'] == "") {
- echo "<span class='warning'>Please enter a username!</span><br>";
- }
- ?>
- <label><p>Username:</p> <input type="text" name="username" size="20" maxlength="25" value="
- <?php if (isset($_POST['username'])){
- echo $_POST['username'];
- }
- ?>"/></label> <br/>
- <!--Password Input-->
- <?php
- //checking for a user password
- if (!isset($_POST['password'])) {
- echo "";
- } elseif ($_POST['password'] == "") {
- echo "<span class='warning'> Please enter a password!</span><br>";
- }
- ?>
- <label><p>Password:</p> <input type="password" name="password" size="20" maxlength="40" value="
- <?php if (isset($_POST['password'])){
- echo $_POST['password'];
- }?>" /></label><br/>
- <!--Arrays For Dropdowns-->
- <?php if (((isset($_POST['month'])) && ($_POST['month'] == "Month")) || ((isset($_POST['day'])) && ($_POST['day'] = "Day")) || ((isset($_POST['year'])) && ($_POST['year'] == "Year"))) {
- echo "<span class='warning'>Please enter your birthday!</span>";
- }?>
- <p>Date of Birth: </p>
- <?php
- //declaring month arrays for the select menu
- $months = array ('Jan', 'Feb', 'March', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
- //using months array
- echo 'Month: <select name="month">';
- echo '<option value="">Month</option>';
- foreach ($months as $key => $mon) {
- if ($_POST['month'] == $mon){
- $isselected = "selected";
- } else {
- $isselected = "";
- }
- echo "<option value=\"$mon\" $isselected>$mon"."</option>\n";
- }
- echo '</select>';
- ?>
- <?php
- //day array
- $days = range(1,31);
- echo 'Day: <select name="day">';
- echo '<option value="">Day</option>';
- foreach ($days as $day) {
- if ($_POST['day'] == $day) {
- $isselected = "selected";
- } else {
- $isselected = "";
- }
- echo "<option value=\"$day\" $isselected>$day"."</option>\n";
- }
- echo '</select>';
- ?>
- <?php
- //year array
- $years = range(1950,2018);
- echo 'Year: <select name="year">';
- echo '<option value="">Year</option>';
- foreach ($years as $year) {
- if ($_POST['year'] == $year) {
- $isselected = "selected";
- } else {
- $isselected = "";
- }
- echo "<option value=\"$year\" $isselected>$year"."</option>\n";
- }
- echo '</select>';
- ?>
- <!--start of 3 radio buttons-->
- <?php //checking if radio buttons are selected
- $orientation = $_POST['orientation'];
- if (!isset($_POST['orientation'])) {
- echo "";
- } elseif (($orientation != 'lesbian') && ($orientation != 'bisexual') && ($orientation != 'queer')) {
- echo "<span class='warning'> Please enter your sexual orientation! </span><br>";
- }
- ?>
- <p>Sexual Orientation: </p>
- <label><input type="radio" name="orientation" value="lesbian" <?php if (($_POST['orientation'])=="lesbian") echo 'checked="checked"';?>/>Lesbian</label>
- <label> <input type="radio" name="orientation" value="bisexual" <?php if (($_POST['orientation'])=="bisexual") echo 'checked="checked"';?>/>Bisexual </label>
- <label><input type="radio" name="orientation" value="queer" <?php if (($_POST['orientation'])=="queer") echo 'checked="checked"';?>/>Queer</label><br/>
- <!--start of text area-->
- <?php if (!isset($_POST['comments'])) {
- echo "";
- } elseif ($_POST['comments'] == "") {
- echo "<span class='warning'> Please tell us how you heard about us! </span><br>";
- }
- ?>
- <p>How did you hear about LezConnect: </p><textarea name="comments" cols="30" rows="3">
- <?php if (isset($_POST['comments'])){
- echo $_POST['comments'];
- }
- ?>
- </textarea><br/>
- <!--start of 3 checkboxes-->
- <label><input type="checkbox" name="news" value="" <?php if (isset($_POST['news'])) echo "checked"; ?>/>Would you like to receive news from us?</label><br>
- <label><input type="checkbox" name="age" value="" <?php if (isset($_POST['age'])) echo "checked"; ?> />Are you at least 18 years old?</label><br>
- <label><input type="checkbox" name="terms" value="" <?php if (isset($_POST['terms'])) echo "checked";?> />Check here if you agree to our terms of service</label> <br>
- <?php
- //checking that all fields aren't null before double submit javascript voodoo
- if ( ($_POST['firstname'] != NULL) && ($_POST['lastname'] != NULL) && ($_POST['username'] != NULL)
- && ($_POST['email'] != NULL) && ($_POST['comments'] != NULL) && ($_POST['orientation'] != NULL) && ($_POST['month'] != NULL) && ($_POST['day'] != NULL) && ($_POST['year'] != NULL))
- {
- echo "<script>document.getElementById('event').submit()</script>";
- }
- ?>
- <input type="submit" value="Sign up!" />
- </form>
- <?php include("includes/footer.php") ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement