php - 如果我的 MYSQL 数据库中有特定的 VIN,如何执行操作?

标签 php mysql

我一直在与 Autocheck 合作,但他对 PHP 完全没有了解。我创建了一个页面,当客户单击链接时,我必须将其发送到页面。显示的页面必须显示自动检查车辆历史报告。

我已经创建了页面,并且链接完全按照我想要的方式工作。我要做的就是在“自动检查”页面上进行设置,以便车辆历史记录报告仅显示 VIN 号码是否在我的数据库中。如果它不在我的数据库中,我可以显示错误消息。

我的页面当前拥有的内容如下:

<?php
session_start();

$post_data = array();
$post_data['VIN'] = $_GET['vin'];
$post_data['CID'] = 'CID';
$post_data['PWD'] = 'PASSWORD';
$post_data['SID'] = 'SID';
//build the post string
foreach($post_data AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}
// strip off trailing ampersand
$poststring = substr($poststring, 0, -1);
// create a new CURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, 
"https://www.autocheck.com/DealerWebLink.jsp");
curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring);
// grab URL and pass it to the browser
curl_exec($ch);
// close CURL resource, and free up system resources
curl_close($ch);
?>

最后,我的 VIN 号码位于数据库的以下行中:

post_meta['vin-number']

如果可以提供任何帮助,我们将不胜感激!

最佳答案

您需要在继续之前添加 VIN 检查。

这只是一个指示,因为代码将取决于您的数据库是什么、它的组织方式、访问方式等等。您将需要 $conn 成为与数据库等的有效 PDO 连接:

$post_data['VIN'] = $_GET['vin'];

$query = $conn->prepare('SELECT * FROM whateverDb.whateverTable WHERE vinColumn = :vin');
$query->bindValue(':vin', $post_data['VIN']);
$query->execute();
$rows = $query->fetchAll(PDO::FETCH_ASSOC);

...now inspect rows (possibly empty if no VIN in DB).

关于php - 如果我的 MYSQL 数据库中有特定的 VIN,如何执行操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44265314/

相关文章:

php - 将属性添加到 PHP soapCall 中的实际功能标记

php - phpMyAdmin 的 20,000 行限制的修复或迁移是什么?有什么真正不稳定的地方吗?

php - 描述中给出的代码在Windows系统中是否可执行?

mysql - 宏后的 MS Access 无法在链接表中插入新创建的记录

不使用 having 的 mysql 计数

mysql - 如何将字符串转换为不同的子字符串并将其放入变量中?

javascript - MySQL 数据库包含编码和未编码的引号,它破坏了 javascript

php - 通过 htaccess 重定向/index.php?country=a 到/a/

php - 如何用 <br/> 替换换行符或\r\n?

java - Java中,连接mysql,Class.forName是什么意思?