Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php
  2. $error=array();
  3.  
  4. function register($username,$password,$confirm_password,$email,$birth){
  5. global $connection;
  6. global $error ;
  7. $add=$connection->query("select username,email from user where username = '$username' OR email = '$email' ");
  8. $check= $add->FETCH(PDO::FETCH_ASSOC);
  9.  
  10. if(isset($_POST['register'])){
  11. if($username == $check['username']){
  12. $error['username'] ="this username already exists";
  13. }elseif($username == $check['email']){
  14. $error['email'] = "this username already exists";
  15. print_r($error);
  16. }else{
  17. $add=$connection->prepare("insert into user (id,username,password,email,birth) values(NULL,:username,:password,:email,:birth) ");
  18. $add->execute(array(':username'=>$username,':password'=>$password ,':email'=>$email,':birth'=>$birth));
  19. if(isset($add)){
  20. echo ' has been registerd ';
  21. }
  22. }
  23. }
  24.  
  25. return $error;
  26. }
  27.  
  28. function error_function($error=array()){
  29. foreach($error as $key => $value ){
  30. echo "$value";
  31. }
  32. }
  33. error_function($error);
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement