Untitled


SUBMITTED BY: Guest

DATE: May 19, 2013, 3:53 a.m.

FORMAT: PHP

SIZE: 4.8 kB

HITS: 1950

  1. <?php // signup
  2. include("../bin/function.php");
  3. session_start();
  4. if (!isset($_POST['submitok'])):
  5. // Display the user signup form
  6. ?>
  7. <form style="width:200px" method="post" action="<?php $_SERVER['PHP_SELF']?>">
  8. <label for="username"><?php echo _("Username:"); ?></label>
  9. <input name="username"></input>
  10. <label for="firstname"><?php echo _("First name:"); ?></label>
  11. <input name="firstname"></input>
  12. <label for="lastname"><?php echo _("Last name:"); ?></label>
  13. <input name="lastname"></input>
  14. <label for="email"><?php echo _("Email:"); ?></label>
  15. <input name="email"></input>
  16. <label for="newsletter"><?php echo _("Subscribe to newsletter:"); ?></label>
  17. <input type="checkbox" name="newsletter" checked="yes"/>
  18. <img src="../bin/captcha.php"></img>
  19. <input name="captcha"></input>
  20. <input type="submit" name="submitok" value="<?php echo _("register");?>" />
  21. <?php echo $_SESSION["security_code"];?>
  22. </form>
  23. <?php
  24. else:
  25. session_start();
  26. ?>
  27. <script type="text/javascript">
  28. alert('<?php echo $_SESSION["security_code"];?>');
  29. </script>
  30. <?php
  31. // Process signup submission
  32. /*
  33. dbConnect();
  34. if ($_POST['username']=='' or $_POST['firstname']==''
  35. or $_POST['lastname']=='' or $_POST['email'] == '') {
  36. error('One or more required fields were left blank.<br /><br />'.
  37. 'Please fill them in and try again.');
  38. }
  39. // Check for existing user with the new id
  40. $sql = "SELECT COUNT(*) FROM user WHERE username = '$_POST[username]'";
  41. $result = mysql_query($sql);
  42. if (!$result) {
  43. error('A database error occurred in processing your '.
  44. 'submission.<br />If this error persists, please '.
  45. 'contact you@example.com.');
  46. }
  47. if (mysql_result($result,0,0)>0) {
  48. error('A user already exists with your chosen userid.<br />'.
  49. 'Please try another.');
  50. }
  51. $newsletter = ($_POST[newsletter] == "on" ? 1 : 0);
  52. $newpass = generatePassword();
  53. $newpassMd = md5($newpass);
  54. $sql = "INSERT INTO user SET
  55. username = '$_POST[username]',
  56. password = PASSWORD('$newpassMd'),
  57. firstname = '$_POST[firstname]',
  58. lastname = '$_POST[lastname]',
  59. email = '$_POST[email]',
  60. newsletter = '$newsletter'";
  61. if (!mysql_query($sql))
  62. error('A database error occurred in processing your '.
  63. 'submission.<br/>If this error persists, please '.
  64. 'contact you@example.com.<br/>' . mysql_error());
  65. // Email the new password to the person.
  66. $message = "G'Day!
  67. Your personal account for the Project Web Site
  68. has been created! To log in, proceed to the
  69. following address:
  70. http://www.example.com/
  71. Your personal login ID and password are as
  72. follows:
  73. username: $_POST[username]
  74. password: $newpass
  75. You aren't stuck with this password! Your can
  76. change it at any time after you have logged in.
  77. If you have any problems, feel free to contact me at
  78. <you@example.com>.
  79. -Your Name
  80. Your Site Webmaster
  81. ";
  82. echo $message;
  83. ?>
  84. <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
  85. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  86. <html xmlns="http://www.w3.org/1999/xhtml">
  87. <head>
  88. <title> Registration Complete </title>
  89. <meta http-equiv="Content-Type"
  90. content="text/html; charset=iso-8859-1" />
  91. </head>
  92. <body>
  93. <p><strong>User registration successful!</strong></p>
  94. <p>Your userid and password have been emailed to
  95. <strong><?php $_POST['email']?></strong>, the email address
  96. you just provided in your registration form. To log in,
  97. click <a href="index.php">here</a> to return to the login
  98. page, and enter your new personal userid and password.</p>
  99. </body>
  100. </html>
  101. <?php
  102. */
  103. endif;
  104. ?>

comments powered by Disqus