PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/registration.php

https://github.com/deviltry/qmigo
PHP | 494 lines | 307 code | 95 blank | 92 comment | 38 complexity | 14feaafaa3280a29ea0fb09adf717249 MD5 | raw file
  1. <?php
  2. #########################################################
  3. # Vendor Registration - Signup
  4. #########################################################
  5. $scriptName = $_SERVER['PHP_SELF'];
  6. $pageTitle = "QMIGO - Vendor Registration";
  7. # Make sure we display errors to the browser
  8. error_reporting(E_ALL ^ E_NOTICE);
  9. ini_set('display_errors', 1);
  10. # Get our DB info
  11. require "info.php";
  12. #########################################################
  13. # Connect to the database.
  14. #########################################################
  15. $connection = mysql_connect($mySqlHostname, $mySqlUsername, $mySqlPassword);
  16. if (!$connection)
  17. die("Error " . mysql_errno() . " : " . mysql_error());
  18. # Select the DB
  19. $db_selected = mysql_select_db($mySqlDatabase, $connection);
  20. if (!$db_selected)
  21. die("Error " . mysql_errno() . " : " . mysql_error());
  22. #########################################################
  23. # Initialize a new session or obtain old one if possible
  24. #########################################################
  25. require "info_session.php";
  26. session_name($mySessionName);
  27. session_start();
  28. #########################################################
  29. # Go to login page if not logged in
  30. #########################################################
  31. #if ($_SESSION["logged-in"]!=1 || $_SESSION["userid"]<1)
  32. #{ header("Location: socialdrinkster-login.php?err=notloggedin");
  33. # exit;
  34. #}
  35. # Get our site info
  36. require "siteinfo.php";
  37. #########################################################
  38. # Write the header
  39. #########################################################
  40. include "header.php";
  41. # Submit widget
  42. $submitVenue = "DataAction";
  43. ### New site suhmission widgets ###
  44. $textFirstName = "firstname";
  45. $textFirstNameValue = $_POST[$textFirstName]; # The value of f.name widget
  46. $textLastName = "lastname";
  47. $textLastNameValue = $_POST[$textLastName]; # The value of l.name widget
  48. $textEmailName = "email";
  49. $textEmailValue = $_POST[$textEmailName];
  50. if (empty($textEmailValue)) $textEmailValue = "email address"; # Initialize if blank
  51. // Saves stuff into session
  52. //$_SESSION['email'] = $textEmailValue;
  53. $textPasswordName = "password";
  54. $textPasswordValue = $_POST[$textPasswordName]; # The value of password widget
  55. $textVenueName = "venue";
  56. $textVenueValue= $_POST[$textVenueName]; # The value of venue name widget
  57. $textVenueStreetAddressName = "streetaddress";
  58. $textVenueStreetAddressValue= $_POST[$textVenueStreetAddressName]; # The value of venue street widget
  59. $textVenueCityName = "city";
  60. $textVenueCityValue= $_POST[$textVenueCityName]; # The value of venue city name widget
  61. $textVenueStateName = "state";
  62. $textVenueStateValue= $_POST[$textVenueCityName]; # The value of venue state widget
  63. $textVenueZipcodeName = "zipcode";
  64. $textVenueZipCodeValue = $_POST[$textVenueZipcodeName]; # The value of venue zipcode widget
  65. $textVenuePhoneName = "phone";
  66. $textVenuePhoneValue= $_POST[$textVenuePhoneName]; # The value of phone widget
  67. $submitNewVenueValue = "Submit New Venue"; # This is what it will say on our submit site button
  68. ### Status variables ###
  69. $statusMsg = " "; # Gives response back to user (i.e. "Thank you for your ...")
  70. $hasErrors = 0; # Keeps track of whether there are input errors
  71. #########################################################
  72. # New Member Submit
  73. #########################################################
  74. if ($_POST[$submitVenue]==$submitNewVenueValue)
  75. { # Someone submitted new member
  76. # Error Checking
  77. $noFirstName = 0; # Flag that is set if title widget was blank
  78. $noLastName = 0; # Flag that is set if title widget was blank
  79. $noEmail = 0; # Flag that is set if url widget was blank
  80. // First Name
  81. $firstname = trim($textFirstNameValue);
  82. if (empty($firstname))
  83. { # If blank, set general error flag, name error flag, and general error message
  84. $hasErrors = 1;
  85. $noFirstName = 1;
  86. $statusMsg = "There were errors in your site submission - fname.";
  87. }
  88. // Last Name
  89. $lastname= trim($textLastNameValue);
  90. if (empty($lastname))
  91. { # If blank, set general error flag, name error flag, and general error message
  92. $hasErrors = 1;
  93. $noLastName= 1;
  94. $statusMsg = "There were errors in your site submission - lastname";
  95. }
  96. // Email
  97. $vendor_email = trim($textEmailValue);
  98. if (empty($vendor_email))
  99. { # If blank, set general error flag, name error flag, and general error message
  100. $hasErrors = 1;
  101. $noEmail = 1;
  102. $statusMsg = "There were errors in your site submission - emailvalue";
  103. }
  104. // Password
  105. $password = trim($textPasswordValue);
  106. if (empty($password))
  107. { # If blank, set general error flag, name error flag, and general error message
  108. $hasErrors = 1;
  109. $noPassword = 1;
  110. $statusMsg = "There were errors in your site submission - pw";
  111. }
  112. // Venue
  113. $venue = trim($textVenueValue);
  114. if (empty($venue))
  115. { # If blank, set general error flag, name error flag, and general error message
  116. $hasErrors = 1;
  117. $noVenue = 1;
  118. $statusMsg = "There were errors in your site submission-venue";
  119. }
  120. // venue_streetaddress
  121. $venue_streetaddress = trim($textVenueStreetAddressValue);
  122. if (empty($venue_streetaddress))
  123. { # If blank, set general error flag, name error flag, and general error message
  124. $hasErrors = 1;
  125. $noVenueStreetAddress = 1;
  126. $statusMsg = "There were errors in your site submission-street";
  127. }
  128. // venue_city
  129. $venue_city = trim($textVenueCityValue);
  130. if (empty($venue_city))
  131. { # If blank, set general error flag, name error flag, and general error message
  132. $hasErrors = 1;
  133. $noVenueCity = 1;
  134. $statusMsg = "There were errors in your site submission-city";
  135. }
  136. // venue_state
  137. $venue_state = trim($textVenueStateValue);
  138. if (empty($venue_state))
  139. { # If blank, set general error flag, name error flag, and general error message
  140. $hasErrors = 1;
  141. $noVenueState = 1;
  142. $statusMsg = "There were errors in your site submission-venue";
  143. }
  144. // venue_zipcode
  145. $venue_zipcode = trim($textVenueZipCodeValue);
  146. if (empty($venue_zipcode))
  147. { # If blank, set general error flag, name error flag, and general error message
  148. $hasErrors = 1;
  149. $noVenueZipcode = 1;
  150. $statusMsg = "There were errors in your site submission-zip";
  151. }
  152. // venue_phone
  153. $venue_phone = trim($textVenuePhoneValue);
  154. if (empty($venue_phone))
  155. { # If blank, set general error flag, name error flag, and general error message
  156. $hasErrors = 1;
  157. $noVenuePhone = 1;
  158. $statusMsg = "There were errors in your site submission-phone";
  159. }
  160. # If we had no errors, we can put it in the database
  161. if (!$hasErrors)
  162. { # Replace any single quotes in our firstname
  163. $firstnameDB = str_replace("'", "''", $firstname);
  164. $lastnameDB = str_replace("'", "''", $lastname);
  165. $vendor_emailDB = str_replace("'", "''", $vendor_email);
  166. $passwordDB = str_replace("'", "''", $password);
  167. $venueDB = str_replace("'", "''", $venue);
  168. $venue_streetaddressDB = str_replace("'", "''", $venue_streetaddress);
  169. $venue_cityDB = str_replace("'", "''", $venue_city);
  170. $venue_stateDB = str_replace("'", "''", $venue_state);
  171. $venue_zipcodeDB = str_replace("'", "''", $venue_zipcode);
  172. $venue_phoneDB = str_replace("'", "''", $venue_phone);
  173. # Create the SQL query //
  174. $SqlStatement = "INSERT INTO qmigo_vendors (firstname,lastname, vendor_email, password, venue, venue_streetaddress, venue_city, venue_state, venue_zipcode, venue_phone)
  175. VALUES ('$firstnameDB','$lastnameDB','$vendor_emailDB','$passwordDB','$venueDB','$venue_streetaddressDB','$venue_cityDB','$venue_stateDB','$venue_zipcodeDB','$venue_phoneDB') ";
  176. //print "HELLO"; // troubleshooting
  177. # Run the query on the database through the connection
  178. $result = mysql_query($SqlStatement, $connection);
  179. if (!$result)
  180. die("Error " . mysql_errno() . " : " . mysql_error());
  181. $statusMsg = "Thank you for registration at QMIGO!";
  182. # Reset the text widgets to accept input once again for the next submission
  183. $textTitleValue = "";
  184. $textEmbedValue = "";
  185. $textEmailValue = "";
  186. $textPassWordValue = "";
  187. $textVenueValue = "";
  188. $textVenueStreetAddressValue = "";
  189. $textVenueCityValue = "";
  190. $textVenueStateValue = "";
  191. $textVenueZipCodeValue = "";
  192. $textVenuePhoneValue = "";
  193. }
  194. }
  195. ?>
  196. <?
  197. #########################################################
  198. # Submission Form: First Name
  199. #########################################################
  200. echo <<<END
  201. <p>
  202. <h1>
  203. Owner? Register below. </h1>
  204. <hr size=1 color="#000000">
  205. <table border=0 cellpadding=3 cellspacing=1">
  206. <tr bgcolor="$table_row_color">
  207. <td align="left">
  208. <form action="$scriptName" method="POST" enctype="application/x-www-form-urlencoded">
  209. <nobr>First Name:</nobr>
  210. </td>
  211. <td align="left">
  212. <input type="text" name="firstname" value="$textFirstNameValue" size="32" maxlength="255">
  213. END;
  214. # If we had a problem with the title, show error message here
  215. if ($hasErrors && $noFirstName)
  216. { print '<br><font color="#ff0000"><b>Please provide a first name</b></font>';
  217. }
  218. #########################################################
  219. # Submission Form: Last Name
  220. #########################################################
  221. echo <<<END
  222. </td>
  223. </tr>
  224. <tr bgcolor="$table_row_color">
  225. <td align="left">
  226. <nobr>
  227. Last Name:</nobr>
  228. </td>
  229. <td align="left">
  230. <input type="text" name="lastname" value="$textLastNameValue" size="32" maxlength="255">
  231. END;
  232. # If we had a problem with the title, show error message here
  233. if ($hasErrors && $noLastName)
  234. { print '<br><font color="#ff0000"><b>Please provide a last name</b></font>';
  235. }
  236. #########################################################
  237. # Submission Form: Email
  238. #########################################################
  239. echo <<<END
  240. </td>
  241. </tr>
  242. <tr bgcolor="$table_row_color">
  243. <td align="left">
  244. <nobr>
  245. Email:</nobr>
  246. </td>
  247. <td align="left">
  248. <input type="text" name="email" value="$textEmailValue" size="32" maxlength="255">
  249. END;
  250. # If we had a problem with the email, show error message here
  251. if ($hasErrors && $noEmail)
  252. { print '<br><font color="#ff0000"><b>Please provide an email</b></font>';
  253. }
  254. #########################################################
  255. # Submission Form: Password
  256. #########################################################
  257. echo <<<END
  258. </td>
  259. </tr>
  260. <tr bgcolor="$table_row_color">
  261. <td align="left">
  262. <nobr>
  263. Password:</nobr>
  264. </td>
  265. <td align="left">
  266. <input type="text" name="password" value="$textPasswordValue" size="32" maxlength="255">
  267. END;
  268. # If we had a problem with the title, show error message here
  269. if ($hasErrors && $noLastName)
  270. { print '<br><font color="#ff0000"><b>Please provide a password</b></font>';
  271. }
  272. #########################################################
  273. # Submission Form: Venue
  274. #########################################################
  275. echo <<<END
  276. </td>
  277. </tr>
  278. <tr bgcolor="$table_row_color">
  279. <td align="left">
  280. <nobr>
  281. Venue Name:</nobr>
  282. </td>
  283. <td align="left">
  284. <input type="text" name="venue" value="$textVenueValue" size="32" maxlength="255">
  285. END;
  286. # If we had a problem with the title, show error message here
  287. if ($hasErrors && $noVenue)
  288. { print '<br><font color="#ff0000"><b>Please provide a venue</b></font>';
  289. }
  290. #########################################################
  291. # Submission Form: Venue Street Address
  292. #########################################################
  293. echo <<<END
  294. </td>
  295. </tr>
  296. <tr bgcolor="$table_row_color">
  297. <td align="left">
  298. <nobr>
  299. Street Address:</nobr>
  300. </td>
  301. <td align="left">
  302. <input type="text" name="streetaddress" value="$textVenueStreetAddressValue" size="32" maxlength="255">
  303. END;
  304. # If we had a problem with the title, show error message here
  305. if ($hasErrors && $noVenue)
  306. { print '<br><font color="#ff0000"><b>Please provide a venue street address</b></font>';
  307. }
  308. #########################################################
  309. # Submission Form: Venue City
  310. #########################################################
  311. echo <<<END
  312. </td>
  313. </tr>
  314. <tr bgcolor="$table_row_color">
  315. <td align="left">
  316. <nobr>
  317. City:</nobr>
  318. </td>
  319. <td align="left">
  320. <input type="text" name="city" value="$textVenueCityValue" size="32" maxlength="255">
  321. END;
  322. # If we had a problem with the city, show error message here
  323. if ($hasErrors && $noVenueCity)
  324. { print '<br><font color="#ff0000"><b>Please provide a city</b></font>';
  325. }
  326. #########################################################
  327. # Submission Form: Venue State
  328. #########################################################
  329. echo <<<END
  330. </td>
  331. </tr>
  332. <tr bgcolor="$table_row_color">
  333. <td align="left">
  334. <nobr>
  335. State:</nobr>
  336. </td>
  337. <td align="left">
  338. <input type="text" name="state" value="$textVenueCityValue" size="32" maxlength="2">
  339. END;
  340. # If we had a problem with the city, show error message here
  341. if ($hasErrors && $noVenueState)
  342. { print '<br><font color="#ff0000"><b>Please provide a state</b></font>';
  343. }
  344. #########################################################
  345. # Submission Form: Venue Zipcode
  346. #########################################################
  347. echo <<<END
  348. </td>
  349. </tr>
  350. <tr bgcolor="$table_row_color">
  351. <td align="left">
  352. <nobr>
  353. Zipcode:</nobr>
  354. </td>
  355. <td align="left">
  356. <input type="text" name="zipcode" value="$textVenueZipCodeValue" size="32" maxlength="5">
  357. END;
  358. # If we had a problem with the city, show error message here
  359. if ($hasErrors && $noVenueState)
  360. { print '<br><font color="#ff0000"><b>Please provide a zipcode</b></font>';
  361. }
  362. #########################################################
  363. # Submission Form: Venue Phone
  364. #########################################################
  365. echo <<<END
  366. </td>
  367. </tr>
  368. <tr bgcolor="$table_row_color">
  369. <td align="left">
  370. <nobr>
  371. Phone:</nobr>
  372. </td>
  373. <td align="left">
  374. <input type="text" name="phone" value="$textVenuePhoneValue" size="32" maxlength="10">
  375. END;
  376. # If we had a problem with the city, show error message here
  377. if ($hasErrors && $noVenuePhone)
  378. { print '<br><font color="#ff0000"><b>Please provide a telephone number with no dashes</b></font>';
  379. }
  380. # Now finish our table, put in our submit widget and end the form
  381. echo <<<END
  382. </td>
  383. </tr>
  384. <tr><td height="5" colspan="2"></td></tr>
  385. <tr>
  386. <td></td>
  387. <td align="left" valign="top">
  388. <input type="submit" name="$submitVenue" value="$submitNewVenueValue"></td></tr>
  389. </table></form>
  390. END;
  391. # If we put anything in the general status message, then print it
  392. if (!empty($statusMsg))
  393. { print '<font color="#990000"><b>'.$statusMsg.'</b></font> <p>';
  394. }
  395. #########################################################
  396. # Write end HTML here
  397. #########################################################
  398. include "footer.php";
  399. ?>