我有一个包含两种形式的网页。然后我有一个单独的 .php 文件,其中包含我希望在每个提交时发生的代码。
第一个表单是搜索表单,该操作在以下 php 文件上执行。
<?php
include newCustomer.php;
connect('final');//connect to DB
$query = $_POST['searchDB'];
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
$data = mysql_query("SELECT * FROM customer WHERE First_Name LIKE '$query'") ;//query the DB with search field in colleumn selected//
//$data = mysql_query("SELECT * FROM customer INNER JOIN address ON customer.ID = address.Customer_ID LEFT OUTER JOIN sites ON address.ID = sites.address_ID WHERE upper(customer.$field) LIKE'%$query%'") ;
if($data === FALSE) {
$error = 'Query error:'.mysql_error();
echo $error;
}
else
{
$test = array();
$colNames = array();
while($results = mysql_fetch_assoc($data)){// puts data from database into array, loops until no more
$test[] = $results;
}
$anymatches=mysql_num_rows($data); //checks if the querys returned any results
if ($anymatches != 0) {
$colNames = array_keys(reset($test));
}
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
}
header("location: newCustomer.php");
echo test;
die();
?>
我想在 newCustomer 页面上使用数组中包含的数据。但我无法让它出现,我尝试在 search.php 文件中的随机位置回显“测试”,但它不会出现在 newCustomer 页面上。
如何在两者之间传递信息?