Advertisement
Guest User

LCform

a guest
Feb 23rd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.30 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>Assignment 4 Form Index </title>
  5. <style>
  6. body{
  7. font-family:"Gill Sans", "Gill Sans MT", Calibri, sans-serif;
  8. text-align:center;
  9. background-color: #ccc;
  10. color:#133926;
  11. vertical-align:middle;
  12. }
  13. form{
  14. margin-bottom:25px;
  15. width:40%;
  16. margin-right:auto;
  17. margin-left:auto;}
  18. input,select,textarea{
  19. margin-bottom:15px;
  20. padding:12px 20px;}
  21. .warning{
  22. color:red;
  23. font-style:bold;
  24. margin-bottom:2px;}
  25. p{
  26. font-weight:550;
  27. font-size:18px;
  28. margin-bottom:2px;
  29. margin-top:1px;}
  30. h2{
  31. margin-bottom:10px;}
  32. input[type=submit]{
  33. padding:12px 15px;
  34. background-color:#003333;
  35. color:#b3e6cc;
  36. -webkit-box-sizing: border-box;
  37. -moz-box-sizing: border-box;
  38. box-sizing: border-box;
  39. }
  40. input[type=submit]:hover{
  41. background-color: #b3e6cc;
  42. color:#003333;
  43. -webkit-box-sizing: border-box;
  44. -moz-box-sizing: border-box;
  45. box-sizing: border-box;
  46. }
  47. </style>
  48. </head>
  49. <body>
  50. <?php include("includes/header.php") ?>
  51. <h2>User Sign Up</h2>
  52. <!--create form-->
  53. <form action="<?php
  54. //telling the form how to handle submission; if name, email, comments, radio button, and select are filled in, it redirects to confirm page
  55. if (($_POST['firstname'] != NULL) && ($_POST['lastname'] != NULL) && ($_POST['username'] != NULL)
  56. && ($_POST['email'] != NULL) && ($_POST['comments'] != NULL) && ($_POST['orientation'] != NULL) && ($_POST['month'] != NULL) && ($_POST['day'] != NULL) && ($_POST['year'] != NULL))
  57. {
  58. echo "confirm.php";
  59. $_POST['submit'] == "true";
  60. } else {
  61. echo "index.php";
  62. }?>" method="POST" id="event">
  63.  
  64.  
  65. <?php
  66. //checking if first name is entered
  67. if (!isset($_POST['firstname'])) {
  68. echo "";
  69. } elseif ($_POST['firstname'] == "") {
  70. echo "<span class=\"warning\"> Please enter your first name!</span><br>";
  71. }
  72. ?>
  73. <label><p>First Name: </p><input type="text" name="firstname" size="20" maxlength="25" value="
  74. <?php if (isset($_POST['firstname'])){ //making sticky forms
  75. echo $_POST['firstname'];
  76. }?>" /> </label> <br/>
  77.  
  78.  
  79. <?php
  80. //checking if last name is entered
  81. if (!isset($_POST['lastname'])) {
  82. echo "";
  83. } elseif ($_POST['lastname'] == "") {
  84. echo "<span class='warning'> Please enter your last name!</span><br>";
  85. }
  86. ?>
  87. <label><p>Last Name:</p> <input type="text" name="lastname" size="20" maxlength="25" value="
  88. <?php if (isset($_POST['lastname'])){
  89. echo $_POST['lastname'];
  90. }?>"/></label> <br/>
  91.  
  92.  
  93. <!--Email Input-->
  94. <?php
  95. //checking if email is entered
  96. if (!isset($_POST['email'])) {
  97. echo "";
  98. } elseif ($_POST['email'] == "") {
  99. echo "<span class='warning'> Please enter your email address!</span><br>";
  100. }
  101. ?>
  102. <label><p>Email:</p><input type="text" name="email" size="20" maxlength="40" value="
  103. <?php if (isset($_POST['email'])){
  104. echo $_POST['email'];
  105. }?>" /> </label><br/>
  106.  
  107.  
  108. <!--Username Input-->
  109. <?php
  110. //checking if username is entered
  111. if (!isset($_POST['username'])) {
  112. echo "";
  113. } elseif ($_POST['username'] == "") {
  114. echo "<span class='warning'>Please enter a username!</span><br>";
  115. }
  116. ?>
  117. <label><p>Username:</p> <input type="text" name="username" size="20" maxlength="25" value="
  118. <?php if (isset($_POST['username'])){
  119. echo $_POST['username'];
  120. }
  121. ?>"/></label> <br/>
  122.  
  123.  
  124. <!--Password Input-->
  125. <?php
  126. //checking for a user password
  127. if (!isset($_POST['password'])) {
  128. echo "";
  129. } elseif ($_POST['password'] == "") {
  130. echo "<span class='warning'> Please enter a password!</span><br>";
  131. }
  132. ?>
  133. <label><p>Password:</p> <input type="password" name="password" size="20" maxlength="40" value="
  134. <?php if (isset($_POST['password'])){
  135. echo $_POST['password'];
  136. }?>" /></label><br/>
  137.  
  138.  
  139. <!--Arrays For Dropdowns-->
  140. <?php if (((isset($_POST['month'])) && ($_POST['month'] == "Month")) || ((isset($_POST['day'])) && ($_POST['day'] = "Day")) || ((isset($_POST['year'])) && ($_POST['year'] == "Year"))) {
  141. echo "<span class='warning'>Please enter your birthday!</span>";
  142. }?>
  143. <p>Date of Birth: </p>
  144. <?php
  145. //declaring month arrays for the select menu
  146. $months = array ('Jan', 'Feb', 'March', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
  147.  
  148. //using months array
  149. echo 'Month: <select name="month">';
  150. echo '<option value="">Month</option>';
  151. foreach ($months as $key => $mon) {
  152. if ($_POST['month'] == $mon){
  153. $isselected = "selected";
  154. } else {
  155. $isselected = "";
  156. }
  157. echo "<option value=\"$mon\" $isselected>$mon"."</option>\n";
  158. }
  159. echo '</select>';
  160. ?>
  161.  
  162.  
  163. <?php
  164. //day array
  165. $days = range(1,31);
  166. echo 'Day: <select name="day">';
  167. echo '<option value="">Day</option>';
  168. foreach ($days as $day) {
  169. if ($_POST['day'] == $day) {
  170. $isselected = "selected";
  171. } else {
  172. $isselected = "";
  173. }
  174. echo "<option value=\"$day\" $isselected>$day"."</option>\n";
  175. }
  176. echo '</select>';
  177. ?>
  178.  
  179. <?php
  180. //year array
  181. $years = range(1950,2018);
  182.  
  183. echo 'Year: <select name="year">';
  184. echo '<option value="">Year</option>';
  185. foreach ($years as $year) {
  186. if ($_POST['year'] == $year) {
  187. $isselected = "selected";
  188. } else {
  189. $isselected = "";
  190. }
  191. echo "<option value=\"$year\" $isselected>$year"."</option>\n";
  192. }
  193. echo '</select>';
  194. ?>
  195.  
  196. <!--start of 3 radio buttons-->
  197. <?php //checking if radio buttons are selected
  198. $orientation = $_POST['orientation'];
  199. if (!isset($_POST['orientation'])) {
  200. echo "";
  201. } elseif (($orientation != 'lesbian') && ($orientation != 'bisexual') && ($orientation != 'queer')) {
  202. echo "<span class='warning'> Please enter your sexual orientation! </span><br>";
  203. }
  204. ?>
  205. <p>Sexual Orientation: </p>
  206. <label><input type="radio" name="orientation" value="lesbian" <?php if (($_POST['orientation'])=="lesbian") echo 'checked="checked"';?>/>Lesbian</label>
  207. <label> <input type="radio" name="orientation" value="bisexual" <?php if (($_POST['orientation'])=="bisexual") echo 'checked="checked"';?>/>Bisexual </label>
  208. <label><input type="radio" name="orientation" value="queer" <?php if (($_POST['orientation'])=="queer") echo 'checked="checked"';?>/>Queer</label><br/>
  209.  
  210. <!--start of text area-->
  211. <?php if (!isset($_POST['comments'])) {
  212. echo "";
  213. } elseif ($_POST['comments'] == "") {
  214. echo "<span class='warning'> Please tell us how you heard about us! </span><br>";
  215. }
  216. ?>
  217. <p>How did you hear about LezConnect: </p><textarea name="comments" cols="30" rows="3">
  218. <?php if (isset($_POST['comments'])){
  219. echo $_POST['comments'];
  220. }
  221. ?>
  222. </textarea><br/>
  223.  
  224. <!--start of 3 checkboxes-->
  225. <label><input type="checkbox" name="news" value="" <?php if (isset($_POST['news'])) echo "checked"; ?>/>Would you like to receive news from us?</label><br>
  226. <label><input type="checkbox" name="age" value="" <?php if (isset($_POST['age'])) echo "checked"; ?> />Are you at least 18 years old?</label><br>
  227. <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>
  228.  
  229.  
  230. <?php
  231. //checking that all fields aren't null before double submit javascript voodoo
  232. if ( ($_POST['firstname'] != NULL) && ($_POST['lastname'] != NULL) && ($_POST['username'] != NULL)
  233. && ($_POST['email'] != NULL) && ($_POST['comments'] != NULL) && ($_POST['orientation'] != NULL) && ($_POST['month'] != NULL) && ($_POST['day'] != NULL) && ($_POST['year'] != NULL))
  234. {
  235. echo "<script>document.getElementById('event').submit()</script>";
  236. }
  237. ?>
  238. <input type="submit" value="Sign up!" />
  239.  
  240.  
  241. </form>
  242.  
  243. <?php include("includes/footer.php") ?>
  244. </body>
  245. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement