以下脚本通过其唯一标记在数据库中查询客户。然后它再次查询数据库以检查“account_modules”表中是否有一行。如果没有,则创建一行并将“援助”列设置为客户的唯一ID。
我将“clientid”变量设置为0.在代码下方回显值。感谢您的帮助!
<?php
//Required file for database config
require_once('../includes/config.php');
//Set the GLOBAL GET to variable
$token = htmlspecialchars($_GET['token']);
//Set the search query with unbinded values
$search = $connection->prepare("SELECT id, client, email, plan, uniqueval FROM account WHERE uniqueval = ?");
//Bind variable to SELECT query
$search->bind_param("s", $token);
//Execute query through IF statement
if ($search->execute()) {
//Bind the results to their variables through the if statement
if ($search->bind_result($clientid, $business, $email, $plan, $newtoken)) {
echo $token . "<br />" . $clientid . "<br />" . $business . "<br />" . $email . "<br />" . $plan . "<br />" . $newtoken;
//Close this database query
if ($search->close()) {
//Set the query string to search unbinded perameter
$valconfig = $connection->prepare("SELECT aid FROM account_modules WHERE aid = ?");
//Set the perameter 'WHERE aid = ?' to the query
$valconfig->bind_param("s", $clientid);
//Execute the query through MySQLi
$valconfig->execute();
//Stores the number for counting
$valconfig->store_result();
//Count the number of bulletins today
$unique_count = $valconfig->num_rows;
//Close the session with the results to username check
$valconfig->close();
if ($unique_count == 0) {
//Set the query string to search unbinded perameter
$insert = $connection->prepare("INSERT INTO account_modules (aid) VALUES (?)");
//Set the perameter 'VALUES = (?)' to the query
$insert->bind_param("s", $clientid);
if ($insert->execute()) {
$created = "config";
}
}
}
}
}
?>
Echod值
74b450bf7b42a3499dc4a8f9b5a69cca
0
[blank]
[blank]
[blank]
[blank]