Thank you for your assistance!
My purpose is to search waybill number in (new page, i.e. page 1) and using sidebox. I've installed ty tracker, so I can input carrier waybill number to the relative order. I would like to search the order status result just using that waybill number and no need login.
By now, I've embedded the following code to define_page_1:
Code:
<?php
mysql_connect("localhost","root","") or die("could not connect");
mysql_select_db ("testsite01") or die ("could not find db!");
mysql_query("SET NAMES 'UTF8'");
?>
<?php
$output = '';
$output2 ='';
//collect
if (!empty($_POST['p1_wbsearch'])){
$wbsearchq = $_POST['p1_wbsearch'];
$wbsearchq = preg_replace("#[^0-9a-z]#i","",$wbsearchq);
$query = mysql_query("SELECT * FROM orders_status_history WHERE orders_status_history.track_id3 = '$wbsearchq' ")
or die("Cannot access database!");
$count = mysql_num_rows($query);
if ($count == 0 ){
$output = 'Waybill number '.$wbsearchq.'not found!';
}else{
while ($row = mysql_fetch_array($query)) {
$order_id = $row['orders_id'];
$date = $row['date_added'];
$output.='<h3><div>Waybill number:'.$wbsearchq.'tracking result:</div></h3>';
}
$query2 = mysql_query("SELECT * FROM orders_status_history inner join orders_status on orders_status_history.orders_status_id=orders_status.orders_status_id AND (orders_status.language_id=3) AND (orders_status_history.orders_id=38) ORDER BY date_added DESC")or die("Cannot access database!");
$count2 = mysql_num_rows($query2);
if ($count2 == 0 ){
$output2 = 'No record found!';
}else{
while ($row2 = mysql_fetch_array($query2)) {
$date = $row2['date_added'];
$createDate = new DateTime($date);
$stripDate = $createDate->format('Y-m-d');
$status = $row2['orders_status_name'];
$comments = $row2['comments'];
$output2.='<div>'.$stripDate.':  '.$status.', '.$comments.'</div>';
}
}
}
}
?>
<form action="index.php?main_page=page_1" method="post" >
<input type="text" name="p1_wbsearch" placeholder="Search for waybill no..." />
<input type="submit" value=">>" />
</form>
<?php
print("$output");
print ("$output2");
?>
And I create a php file by using the above code and place it at root directory. I just change the input text name "p1_wbsearch" to "wbsearch" and form action move to submit. Then when I submit data, the side box will not display the result at the same time.
Code:
<form action="" method="post" >
<input type="text" name="wbsearch" placeholder="Search for waybill no..." />
<input type="submit" value=">>" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"/>
</form>
Then I 'require' this php file in includes/modules/sideboxes/mytemplate/blank_sidebox.php
Below please find the images
Even I can call the data from database, I do know there is security problem as I put the id,password,database name in a page. But I really don't know how to make it to just load the login information in config.php.
Could you please tell me how to fix it?
Thank you for your help!
Bookmarks