/padly/html/signup.php

https://github.com/dadepo/Padly · PHP · 148 lines · 81 code · 56 blank · 11 comment · 8 complexity · a3b1d648ef1bc46fe0e4021a1f6916be MD5 · raw file

  1. <?php
  2. ?>
  3. <div id="sulform">
  4. <link rel="stylesheet" type="text/css" href="padly/html/style/bootstrap.css" />
  5. <form method="post" action="<?php echo APP_PATH;?>/auth.php" class="form-stacked" id="pd_signupform">
  6. <fieldset>
  7. <div class="clearfix">
  8. <legend>Signup For Account</legend>
  9. <?php
  10. //first take care of the database
  11. //check if signup db exits
  12. $test = mysql_query("select * from sul_signup_profile");//which is faster? this or mysql_list_table function
  13. if (!$test)
  14. {
  15. //then create table
  16. //`uname` VARCHAR(45) NOT NULL,
  17. $tstring = '';
  18. while(current($sform))
  19. {
  20. $tstring = $tstring . "`" . str_replace(" ","_", key($sform))."` VARCHAR (255) ,";
  21. next($sform);
  22. }
  23. $r = mysql_query("CREATE TABLE `sul_signup_profile`(
  24. `uid` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,".$tstring."`profile` varchar(45), PRIMARY KEY (`uid`))");
  25. if(!$r)
  26. {
  27. die(mysql_error());
  28. }
  29. else
  30. {
  31. //now generate the HTML for the signup form
  32. include_once("signupform.php");
  33. }
  34. }
  35. else
  36. {
  37. //check if the number of fields specified in the config file is note same as in table
  38. if (mysql_num_fields($test) != (count($sform) + 2))
  39. {
  40. //backup present table and create another one
  41. if (mysql_query("select * from sul_signup_profile_backup"))
  42. {
  43. $r = mysql_query("drop table sul_signup_profile_backup");
  44. if(!$r)
  45. {
  46. echo mysql_error();
  47. echo '222';
  48. exit;
  49. }
  50. }
  51. $alter_string = "ALTER TABLE `sul_signup_profile` RENAME TO `sul_signup_profile_backup`;";
  52. $r = mysql_query($alter_string);
  53. if (!$r)
  54. {
  55. echo mysql_error();
  56. }
  57. else
  58. {
  59. //recreate table
  60. $tstring = '';
  61. while(current($sform))
  62. {
  63. $tstring = $tstring . "`" . str_replace(" ","_", key($sform))."` VARCHAR (255) ,";
  64. next($sform);
  65. }
  66. $r = mysql_query("CREATE TABLE `sul_signup_profile`(
  67. `uid` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,".$tstring."PRIMARY KEY (`uid`))");
  68. if(!$r)
  69. {
  70. die(mysql_error());
  71. }
  72. else
  73. {
  74. //
  75. //now generate the HTML for the signup form
  76. include_once("signupform.php");
  77. //
  78. }
  79. }
  80. }
  81. else
  82. {
  83. include_once("signupform.php");
  84. }
  85. }
  86. ?>
  87. <br/><br/>
  88. <input type="submit" value="Create An Account" class="btn primary" />
  89. </div> <!-- /clearfix -->
  90. </fieldset>
  91. </form>
  92. </div>