我想從一個特定的行或基於id_code
從people
表中獲取電子郵件...也就是說,如果我輸入一個id_code = 456
,如果id代碼存在必須檢索該特定id_code
的電子郵件,並生成令牌號並將令牌號插入到人員表中。在令牌生成並插入後,必須使用令牌和ID發送URL鏈接。如何從表中使用php和mysql獲取數據
我該怎麼做,因爲我是初學者,有人能告訴我我哪裏出錯了嗎?
這裏是我做過什麼至今:
<?php
error_reporting(1);
session_start();
include 'includes/db.php';
include 'includes/token.php';
//global
$id_code = strtoupper(trim($_POST['id_code']));
if ($_POST["Submit"] == "Submit") {
$sql = "SELECT * FROM people WHERE id_code = :id_code";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':id_code', $id_code);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
if (!empty($_POST['id_code'])) {
$sql = "SELECT email FROM people WHERE id_code = $id_code";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':id_code', $id_code);
$stmt->execute();
$result2 = $stmt->fetch(PDO::FETCH_ASSOC);
} else {
//echo "<br/>Validated: FALSE<br/>"; die();
echo 'You are not Registered..Please Contact support';
}
}
?>
表中的id_code是什麼?該人的ID或消息的ID? –