插入前检查值

时间:2016-11-18 15:06:46

标签: php

我试图在插入表格之前弄清楚如何检查值,我的代码目前看起来像这样:

try {
     $stmt = $dbh->prepare("INSERT INTO test (firstname, lastname, email) VALUES (:firstname, :lastname, :email)");
     $stmt->bindValue(':firstname', $first_name, PDO::PARAM_STR);
     $stmt->bindValue(':lastname', $last_name, PDO::PARAM_STR);
     $stmt->bindValue(':email', $email_address, PDO::PARAM_STR);
     $stmt->execute();
        echo 'New record created successfully';
     } catch (PDOException $e) {
            echo $smtp . "<br/> " . $e->getMessage();
        }

0 个答案:

没有答案