查询不在PostgreSQL数据库上工作

I have a query where I check if a user it's already stored on the database, but the problem it's that it's perfectly working on MYSQL but not on PostgreSQL where I need it..what can I do? The steps are: user register for an account. If it already exists in the database it returns an message, if no, send an email where he needs to confirm the registration. The confirmation doesn't work(the adress where the user can enter and activate his account). This is the confirmation code(email_verification.php):

<?php
ob_start();
 $success = false;
// Errors reporting, used if needed
error_reporting(E_ALL);
ini_set('display_errors', 'on');

// General configuration like base, used if needed
include_once ('include/config.inc.php');

// Mail functions
include_once ('include/mail.functions.php');

// Start session if needed
session_start();

// DBConn
include_once ('class/DB/DBConn.includeall.php');
$db = new DBConn(NULL);

// Includere clasa login
require_once ('class/class_login.php');

// Set up current language
$lang = "ro";
$_SESSION[PRE.'lang'] = $lang;
$message = '';

if(isset($_GET['cod_activare']))
{
 $query = "
  SELECT * FROM tregister
  WHERE cod_activare = :cod_activare
 ";
 $statement = $connect->prepare($query);
 $statement->execute(
  array(
   ':cod_activare'   => $_GET['cod_activare']
  )
 );
 $no_of_row = $statement->rowCount();

 if($no_of_row > 0)
 {
  $result = $statement->fetchAll();
  foreach($result as $row)
  {
   if($row['email_status'] == '0')
   {
    $update_query = "
    UPDATE tregister
    SET email_status = '1'
    WHERE id = '".$row['id']."'
    ";
    $statement = $connect->prepare($update_query);
    $statement->execute();
    $sub_result = $statement->fetchAll();
    if(isset($sub_result))
    {
     $message = '<label class="text-success">Email verificat cu success! <br />Poti efectua checkin-ul aici - <a href="login.php">Efectueaza check-in</a></label>';
    }
   }
   else
   {
    $message = '<label class="text-info">Adresa de mail deja verificata</label>';
   }
  }
 }
 else
 {
  $message = '<label class="text-danger">Link invalid</label>';
 }
}

?>
<!DOCTYPE html>
<html>
 <head>
  <title>Hotel Amethyst</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 </head>
 <body>
   <h3><?php echo $message; ?></h3>
  </div>
 </body>

</html>
<?php
ob_end_flush();
?>

And here it's the register.php:

<?php
    ob_start();
     $success = false;
    // Errors reporting, used if needed
    error_reporting(E_ALL);
    ini_set('display_errors', 'on');

    // General configuration like base, used if needed
    include_once ('include/config.inc.php');

    // Mail functions
    include_once ('include/mail.functions.php');

    // Start session if needed
    session_start();

    // DBConn
    include_once ('class/DB/DBConn.includeall.php');
    $db = new DBConn(NULL);

    // Includere clasa login
    require_once ('class/class_login.php');

    // Set up current language
    $lang = "ro";
    $_SESSION[PRE.'lang'] = $lang;

    $access = 0;

    // Check if the cookie for "remember me" exists
    if(isset($cookie_name))
    {
        if(isset($_COOKIE[$cookie_name]))
        {
            parse_str($_COOKIE[$cookie_name]);

            $login = new Login($db);
            if ($login->_checkLogin($usr, $hash) == true)
            {
                $access = 1;
            }

        }
    }


    $user = (isset($_POST['user']) && !empty($_POST['user'])) ? $_POST['user'] : "" ;
    $email = (isset($_POST['email']) && !empty($_POST['email'])) ? $_POST['email'] : "" ;
    $cod_activare = md5(rand());
    $email_status=0;
    $db = pg_connect("host=local port=5432 dbname=login_robinson user=robinson password=123");
    $query = "INSERT INTO tregister(nume,email,cod_activare,email_status) VALUES ('$user','$email','$cod_activare','$email_status')";
    $result = pg_query($query);
    if(isset($_POST['submit'])){
        $base_url = "http://local/login-robinson/www/";
        $mail_body = "
        Buna ziua ".$_POST['user'].",

        Multumim pentru inregistrare. Te rog deschide acest link pentru a incepe procesul de check-in - ".$base_url."email_verification.php?activation_code=".$cod_activare."
    Cu stima,
Hotel Amethyst
        ";
     $from = 'Activare rezervare';
     $subject = 'De pe site';
        if (mail ($email, $subject, $mail_body, $from)){
            echo "<script>
     alert('Utilizator inregistrat cu success! Te rog verifica adresa de mail!');
     window.location.href='login.php';
     </script>";
        }
        else{
            echo "<script>
     alert('S-a produs o eroare! Te rog mai verifica odata formularul!');
     </script>";
        }
        if($user !=''&& $email !='')
        {
            $success=true;
        }

    }

?>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

    <head>
        <!-- <base href="http://dev.incorom.local/ticketing/www/login.php" /> -->
        <title>Inregistrare</title>
        <?php
            include('include/links.php');
            include('include/scripts.php');
        ?>

    </head>

    <body style="display: block !important;" ng-cloak="" ng-class="{ 'layout-fixed' : app.layout.isFixed, 'layout-boxed' : app.layout.isBoxed, 'layout-dock' : app.layout.isDocked, 'layout-material': app.layout.isMaterial, 'aside-offscreen' : app.sidebar.isOffscreen, 'aside-mini' : app.sidebar.isMini, 'aside-right' : app.sidebar.isRight, 'footer-hidden': app.footer.hidden, 'in-app': !$state.includes('page')}">

        <div class="animated fadeOutZoom">
            <div class="container container-sm animated fadeInDown">
                <div class="center-block mt-xl">
                    <img src="images/logo_iconlab.png" alt="Image" class="center-block img-rounded">
                    <div class="panel">
                        <div class="panel-body">
                            <p class="pv text-bold">Date de inregistrare rezervare</p>
                            <form class="mb-lg" method="post" action="register.php" id="form">

                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group has-feedback mb">
                                        <input type="text" placeholder="Nume" autocomplete="off" class="form-control" name="user" id="user" required /><span class="fa fa-envelope form-control-feedback text-muted"/></span>
                                    </div><br>
                                    <div class="form-group has-feedback mb">
                                        <input type="email" placeholder="Adresa de mail" autocomplete="off" class="form-control" name="email" id="email" required /><span class="fa fa-envelope form-control-feedback text-muted"/></span>
                                    </div><br>
                                </div>
                                <div class="col-md-12">
                                    <button type="submit" class="btn btn-block btn-info btnblue mb" name="submit">Inregistrare</button>
                                </div>
                            </div>
                            <div id="main_area" class="row-fluid">
                            </form>

                    </div>
                </div>
            </div>
        </div>
    </body>

</html>
<?php
ob_end_flush();
?>

The registration works OK but I can register the same email for an infinite number of times.