Guest User

php encoded to json parse error

a guest
Apr 16th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.93 KB | None | 0 0
  1. <?php
  2. require_once '../../dbconfig.php';
  3. require_once '../mail/send_mail.php';
  4.  
  5. $result=[];
  6.  
  7. if(empty($_POST['verify_id']) && empty($_POST['code']))
  8. {
  9.  $result['success']=false;
  10.  $result['error_msg']="codici non ricevuti";
  11.  //$user->redirect('index.php');
  12. }
  13.  
  14. if(isset($_POST['verify_id']) && isset($_POST['code']))
  15. {
  16.  $id = base64_decode($_POST['verify_id']);
  17.  $code = $_POST['code'];
  18.  
  19.  $statusY = "Y";
  20.  $statusN = "N";
  21.  
  22.  $stmt = $db_con->prepare("SELECT user_id,userStatus FROM tbl_users WHERE user_id=:uID AND tokenCode=:code LIMIT 1");
  23.  $stmt->execute(array(":uID"=>$id,":code"=>$code));
  24.  $row=$stmt->fetch(PDO::FETCH_ASSOC);
  25.  if($stmt->rowCount() > 0)
  26.  {
  27.   $result["success"]=true;
  28.   if($row['userStatus']==$statusN)
  29.   {
  30.    $stmt = $db_con->prepare("UPDATE tbl_users SET userStatus=:status WHERE user_id=:uID");
  31.    $stmt->bindparam(":status",$statusY);
  32.    $stmt->bindparam(":uID",$id);
  33.    $stmt->execute();
  34.    $msg = "
  35.             <div class='alert alert-success'>
  36.       <button class='close' data-dismiss='alert'>&times;</button>
  37.       <strong>WoW !</strong>  Il vostro account è attivo : <a href='../../index.html'>Login here</a>
  38.          </div>
  39.          ";
  40.     $result['success_msg']=$msg;
  41.   }
  42.   else
  43.   {
  44.      $result['success']=false;
  45.    $msg = "
  46.             <div class='alert alert-error'>
  47.       <button class='close' data-dismiss='alert'>&times;</button>
  48.       <strong>sorry !</strong>  Il vostro account è già attivo : <a href='../../index.html'>Login here</a>
  49.          </div>
  50.          ";
  51.     $result['error_msg']=$msg;
  52.   }
  53.  }
  54.  else
  55.  {
  56.      $result['success']=false;
  57.   $msg = "
  58.         <div class='alert alert-error'>
  59.      <button class='close' data-dismiss='alert'>&times;</button>
  60.      <strong>sorry !</strong>  Account non trovato : <a href='../../subscribe.html'>Signup here</a>
  61.      </div>
  62.      ";
  63.       $result['id']=$id;
  64.     $result['error_msg']=$msg;  
  65.  }
  66. }
  67. echo json_encode($result);
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment