Guest User

Untitled

a guest
Jul 21st, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. <?php
  2. include('connect.php');
  3. if(isset($_REQUEST['Register']))
  4. {
  5.  
  6. $error='';//initialize $error to blank
  7. if(trim($_POST[userid])==''){
  8. $error.="Please enter a username!<br />"; //concatenate the $error Message with a line break
  9. }
  10. if(trim($_POST[password])==''){
  11. $error.="Please Enter password! <br />";//concatenate more to $error
  12. }
  13. if(trim($_POST[email])=='')
  14. {
  15. $error.="Please Enter email address !<br />";
  16. }
  17. else
  18. {
  19. if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST[email])) {
  20. $error="The e-mail you entered was not in the proper format!";
  21.  
  22. }
  23. }
  24. if(trim($_POST[regAs])=='NULL')
  25. {
  26. $error.="Please select Register As !<br />";
  27. }
  28.  
  29. if($error!='')
  30. {
  31. echo "<span style=color:red>$error</span>";
  32. //Hmmmm no text is in $error so do something else, the page has verified and the email was valid
  33. // so uncomment the line below to send the user to your own success page or wherever (swap
  34. //yourpage.php with your files location).
  35. //echo "script type="text/javascript">window.location=yourpage.php"<script>";
  36. }
  37. else
  38. {
  39. $userid=$_REQUEST['userid'];
  40. $name=$_REQUEST['name'];
  41. $password=$_REQUEST['password'];
  42. $repassword=$_REQUEST['repassword'];
  43. $email=$_REQUEST['email'];
  44. $regAs=$_REQUEST['regAs'];
  45. if($password!=$repassword)
  46. {
  47. echo "<script>alert('both are diferent password')</script>";
  48. }
  49. else
  50. {
  51.  
  52. mysql_query("insert into login(userid,name,password,email,regAs) values('$userid','$name','$password','$email','$regAs')");
  53. }
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. }
  66. ?>
  67. <html>
  68. <head></head>
  69. <body>
  70. <form action="" method="post" name="f">
  71. <table align="center">
  72. <tr>
  73. <td>User ID :</td><td>
  74. <input type="text" name="userid" value=""></td>
  75. </tr>
  76. <tr>
  77. <td>Name :</td><td>
  78. <input type="text" name="name" value=""></td>
  79. </tr>
  80. <tr>
  81. <td>Password : </td>
  82. <td><input type="password" name="password" value=""></td>
  83. </tr>
  84. <tr>
  85. <td>Re-Enter Password : </td>
  86. <td><input type="password" name="repassword" value=""></td>
  87. </tr>
  88. <tr>
  89. <td>Email id :</td><td>
  90. <input type="text" name="email" value=""></td>
  91. </tr>
  92. <tr>
  93. <td>Register As :</td><td>
  94. <select id="regAs" name="regAs">
  95. <option value="NULL">SELECT</option>
  96. <option value="Artist">Artist</option>
  97. <option value="Buyer">Buyer</option>
  98. </select></td>
  99. </tr>
  100. <tr>
  101. <td></td>
  102. <td><input type="submit" name="Register" value="Register"</td></tr>
  103. </table>
  104. </form>
  105.  
  106. </body>
  107. </html>
  108.  
  109. <?php
  110. include('connect.php');
  111. if(isset($_REQUEST['Register'])) {
  112. $errors = array(
  113. 'email' => '',
  114. 'username' => '',
  115. //etc...
  116. );
  117.  
  118. if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST[email])) {
  119. $error['email'] = "The e-mail you entered was not in the proper format!";
  120. }
  121. }
  122. ?>
  123.  
  124. <tr>
  125. <td>Email id :</td>
  126. <td>
  127. <input type="text" name="email" value="">
  128. <?php echo $error['email']; ?>
  129. </td>
  130. </tr>
  131.  
  132. // Might as well define them all so we don't have to use isset() later
  133. // This isn't necessary, it just makes the echo logic easier
  134. foreach ($_POST as $k => $v) {
  135. $errors[$k] = array(); // No error yet
  136. }
  137.  
  138. if ( ! valid_email($_POST['email'])) {
  139. // Add an error to the array
  140. $errors['email'][] = 'The email address is not valid.';
  141. }
  142.  
  143. <tr>
  144. <td>Email id :</td>
  145. <td>
  146. <input type="text" name="email" value="">
  147. <?php echo implode(', ', $errors['email']); ?>
  148. </td>
  149. </tr>
Add Comment
Please, Sign In to add comment