Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $error=array();
- function register($username,$password,$confirm_password,$email,$birth){
- global $connection;
- global $error ;
- $add=$connection->query("select username,email from user where username = '$username' OR email = '$email' ");
- $check= $add->FETCH(PDO::FETCH_ASSOC);
- if(isset($_POST['register'])){
- if($username == $check['username']){
- $error['username'] ="this username already exists";
- }elseif($username == $check['email']){
- $error['email'] = "this username already exists";
- print_r($error);
- }else{
- $add=$connection->prepare("insert into user (id,username,password,email,birth) values(NULL,:username,:password,:email,:birth) ");
- $add->execute(array(':username'=>$username,':password'=>$password ,':email'=>$email,':birth'=>$birth));
- if(isset($add)){
- echo ' has been registerd ';
- }
- }
- }
- return $error;
- }
- function error_function($error=array()){
- foreach($error as $key => $value ){
- echo "$value";
- }
- }
- error_function($error);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement