我一直在与 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/