Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. <?php
  2. echo $core->buildFormJS('changeHabbo');
  3. }
  4. elseif( $id == 'email' ) {
  5. ?>
  6. <form action="" method="post" id="changeEmail">
  7.  
  8. <div class="box">
  9.  
  10. <div class="square title">
  11. <strong>Change email</strong>
  12. </div>
  13.  
  14. <?php
  15.  
  16. if( $_POST['submit'] ) {
  17.  
  18. try {
  19.  
  20. $email = $core->clean( $_POST['email'] );
  21.  
  22. if( !$email ) {
  23.  
  24. throw new Exception( "All fields are required." );
  25.  
  26. }
  27. elseif( !preg_match("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$^", $email) ) {
  28.  
  29. throw new Exception( "That's an invalid email address." );
  30.  
  31. }
  32. else {
  33.  
  34. $db->query( "UPDATE users SET email = '{$email}' WHERE id = '{$user->data['id']}'" );
  35.  
  36. echo "<div class=\"square good\">";
  37. echo "<strong>Success</strong>";
  38. echo "<br />";
  39. echo "Email successfully changed!";
  40. echo "</div>";
  41. echo "<meta http-equiv='refresh' content='2;core.editSettings'";
  42.  
  43. }
  44.  
  45. }
  46. catch( Exception $e ) {
  47.  
  48. echo "<div class=\"square bad\">";
  49. echo "<strong>Error</strong>";
  50. echo "<br />";
  51. echo $e->getMessage();
  52. echo "</div>";
  53.  
  54. }
  55.  
  56. }
  57.  
  58. ?>
  59.  
  60. <table width="100%" cellpadding="3" cellspacing="0">
  61. <?php
  62.  
  63. echo $core->buildField( "text",
  64. "required validate-email",
  65. "email",
  66. "Email",
  67. "Your new email.",
  68. $user->data['email'] );
  69.  
  70. ?>
  71. </table>
  72.  
  73. </div>
  74.  
  75. <div class="box" align="right">
  76.  
  77. <input class="button" type="submit" name="submit" value="Submit" />
  78.  
  79. </div>
  80.  
  81. </form>
  82.  
  83. <?php
  84. echo $core->buildFormJS('changeEmail');
  85. }
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement