我之前的SQL SELECT
代码处理了这个 AJAX 请求,但我想将它转换为 PDO 语句。
JavaScript
$.ajax({
type: "POST",
url: "ajax.php",
data: "mail="+ mail,
success: function(msg){
if(msg == 'mail already in use'){
....
ajax.php
$dsn = "mysql:host=localhost;dbname=vedic;charset=utf8";
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
$pdo = new PDO($dsn,'root','', $opt);
if(isset($_POST['mail'])){
$mail = $_POST['mail'];
$stm = $pdo->prepare("select id from members where email='$mail'");
$stm->execute(array($id));
$name = $stm->fetchColumn();
现在怎么办?如何获得可以在 AJAX 中使用的结果?