I am pretty much at the beginner's level for PHP and cURL.
The issue is related to a php CronJob Script which fetches data from a phpmyadmin database relating to customer orders with a particular status (say "0", which means SMS not sent/or No Update Sent to Customer) and updating the shipping details.
Before adding the code to send SMS via API from my SMS Service Provider, the script was working fine which was being used to send emails, regarding shipping updates and following that, updating the database like Order Status and other necessary details to the customer as well as in the system.
The issue arises that if, suppose 100-150 results are fetched as
arrays with status='0' the loop only executes once and stops, whereas
before adding the SMS code, it used to run for n number rows
fetched with status='0'.
I've tried almost all the methods listed on StackOverflow, PHP Manuals, W3C as well as from the developer but still I'm unable to make it work successfully for all the results fetched.
Things I wan't -
1. Select data from a table where status='0'. **✓
2. Get details relating to the order using mysqli_fetch_array.✓
3. Send Email as per the format in the code.✓
4. Update Order History and Order Status.✓
5. Send an SMS using API as per the prescribed template. (⍻ Not Working)**
<?php
$con=mysqli_connect("localhost","admin","pass","database");//database connection
$get_email_contents = "SELECT * FROM `oc_shipping` WHERE `status`='0'";
date_default_timezone_set("Asia/Kolkata");
$date = date('Y-m-d');
if($data = mysqli_query($con,$get_email_contents))
{
while ($row=mysqli_fetch_array($data))
{
$order_id = $row['order_id'];
$tracking_no = $row['tracking_awb'];
$get_email = "SELECT * FROM `oc_order` WHERE `order_id`='$order_id'";
if($email_data = mysqli_query($con,$get_email))
{
while ($email_row=mysqli_fetch_array($email_data))
{
$email = str_replace(" ","",$email_row['email']);
$firstname = ucwords($email_row['firstname']);
$lastname = ucwords($email_row['lastname']);
$received_on = $email_row['date_added'];
$date_added = date("d M Y",strtotime($received_on));
$address_1 = $email_row['shipping_address_1'];
$address_2 = $email_row['shipping_address_2'];
$city = $email_row['shipping_city'];
$pincode = $email_row['shipping_postcode'];
$total = str_replace(".0000","",$email_row['total']);
$mobile = $email_row['telephone'];
$delivery_date = date('d-M-Y', strtotime($date. ' + 7 days'));
$track_url = "https://track.delhivery.com/p/".$tracking_no;
$text = "ABC.com
Hi ".$firstname.", Your Order ".$order_id." has been shipped via XYZ AWB #".$tracking_no.", which can be tracked on ".$track_url."
Expected delivery date is ".$delivery_date.". Please keep ready Rs.".$total."/- on the date of delivery.
Thank you for shopping on ABC.com";
echo "SMS Sent : ".$text."<br><br>";
$encode= rawurlencode($text);
//Just for my reference
$url= "login.smshub.com/api/mt/SendSMS?APIKey=****&senderid=ABCABC&channel=2&DCS=0&Route=1&Flashsms=0&Number=$mobile&Text=$encode";
$ch = curl_init("login.smshub.com/api/mt/SendSMS?APIKey=****&senderid=ABCABC&channel=2&DCS=0&Route=1&Flashsms=0&Number=$mobile&Text=$encode");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE);
$data = curl_exec($ch);
$json = json_decode($data);
$JobID = $json->{'JobId'};
$Error = $json->{'ErrorMessage'};
echo "Status : <strong>$JobID $Error </strong><br>";
//Email Receiver//
$to = "$email";
//From Header//
$header = "From: ABC.com<shipping#example.com>"."\r\n";
$header .= "MIME-Version: 1.0" . "\r\n";
$header .= "Content-type:text/html; charset=ISO-8859-1" . "\r\n";
// Subject //
$subject = "Your Order #$order_id has been Shipped";
// Message //
$message = "<html>
<head>
<title></title>
<link href='https://fonts.googleapis.com/css?family=Pacifico|Varela+Round' rel='stylesheet' />
</head>
<body>
<table align='center' cellpadding='1' style='background-color:#ffffff; border-color:#f3f3f3; border-radius:10px; border-size:1px; border-style:outset; max-width: 100%; width:100%; font-family: Helvetica,Arial,sans-serif; '>
<tbody>
<tr>
<td colspan='2' style='text-align:center'>
<p style='text-align:center'><a href='example.com' target='_blank'><img alt='abc.com' height='63' src='example.com/image/shipping/Logo.gif' width='250' /></a></p>
</td>
</tr>
<tr>
<td style='border-color:#f3f3f3; text-align:center; white-space:nowrap; width:50%'>
<p>Thank you for shopping on abc</p>
<h3 style='text-align:left;margin-left: 40px;'>Order Details</h3>
<table align='center' border='0' cellpadding='5' cellspacing='5' style='background-color:#f2f2f2; border-radius:5px; color:#333333; width:85%;'>
<tbody>
<tr>
<td>
<p style='text-align:left'>Order Number: <strong>$order_id</strong></p>
<p style='text-align:left'>Date Received: <strong>$date_added</strong></p>
<p style='text-align:left'>Name: <strong>$firstname $lastname</strong></p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan='2' style='border-color:#f3f3f3; text-align:center'> </td>
</tr>
<tr>
<td colspan='2' style='border-color:#f3f3f3; text-align:center'>
<h3 style='text-align:left;margin-left: 40px;'>Delivery Address</h3>
<table align='center' border='0' cellpadding='5' style='background-color:#f2f2f2; border-radius:5px; color:#333333; padding:7px; width:85%;'>
<tbody>
<tr>
<td>
<p style='text-align:left'><strong>$address_1</strong></p>
<p style='text-align:left'><strong>$address_2</strong></p>
<p style='text-align:left'><strong>$city - $pincode</strong></p>
<p style='text-align:left'><strong>Mobile No. $mobile</strong></p>
</td>
</tr>
</tbody>
</table>
<p> </p>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center'>
<p style='text-align:center'><img alt='Order Shipped' height='90' src='example.com/image/shipping/Shipping.jpg' width='410' /></p>
<p>Your order has been shipped from our warehouse.</p>
<p>Amount Payable</p>
<h2>Rs.<strong>$total</strong></h2>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center;'>
<table align='center' border='0' cellpadding='1' cellspacing='1' style='background-color:#000000; border-radius:5px; color:#ffffff; font-size:larger; font-weight:700; padding:10px 15px; text-align:center; text-decoration:none; width:85%;'>
<tbody>
<tr>
<td><a href='https://track.xyz.com/p/$tracking_no' target='_blank' style='padding:15px 25px; text-align:center; text-decoration:none; color:#FFF; text-decoration:none;'>TRACK PACKAGE</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center'>
<p><br />
</p>
</td>
</tr>
<tr>
<td colspan='2'>
<p style='text-align:center'><em><span style='font-size:12px'>Instructions</span></em></p>
<table align='center' border='0' cellspacing='5' style='background-color:#f2f2f2; border-radius:5px; color:#333333; width:85%;'>
<tbody>
<tr>
<td><span style='font-size:12px'>1.Please do not accept the package, if it is damaged / tampered before delivery.</span></td>
</tr>
<tr>
<td><span style='font-size:12px'>2.Your freebies (if any) shall be inside the package.</span></td>
</tr>
<tr>
<td><span style='font-size:12px'>3.Please mention remarks while signing for delivery, if you doubt that the package might be damaged or is suspicious.</span></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center'>
<p> </p>
<p><span style='font-size:12px; color:#a9a9a9;'>Note: We do not demand your bank or credit card details over phone. Please do not divulge these details to fraudsters claiming to be calling on behalf of abc. </span></p>
<p> </p>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center'>
<p>Contact Us</p>
<p><strong><a href='mailto:help#abc.com?subject=Regarding%20Order%20ID%20$order_id' style='text-decoration:none; color:#000;'>help#example.com</a></strong></p>
<p><span style='font-size:10px; color:#a9a9a9;'>Do not reply to this email, this is an automated email sent to $email.</p>
</td>
</tr>
</tbody>
</table>
</body>
</html> \r\n";
//Send Mail//
$mail_send = mail($to,$subject,$message,$header);
if($mail_send)
{
$con=mysqli_connect("localhost","admin","pass","database");//database connection
$delete = "UPDATE `oc_ship` SET `status`='1' WHERE `order_id`='$order_id'";
if($deleted = mysqli_query($con,$delete))
{
$update_comment = mysqli_real_escape_string($con,"<p>Your order has been shipped via XYZ AWB #<b>$tracking_no</b>.</p> <p><a href='track.xyz.com/p/$tracking_no' target='_blank'>Click here to track your order</a></p>");
$date_time = date('Y-m-d H:i:s');
$order_history = "INSERT INTO `oc_order_hist`(`order_id`,`order_status_id`,`notify`,`comment`,`date_added`) VALUES ('$order_id','3','1','$update_comment','$date_time')";
if($order_history_update = mysqli_query($con,$order_history))
{
$order_status = "UPDATE `oc_order` SET `order_status_id`='3' WHERE `order_id`='$order_id'";
if($order_status_update = mysqli_query($con,$order_status))
{
echo "<br><strong>Shipping Updated successfully for Order ID $order_id</strong><br>";
}
}
}
}
}
}
}
}
?>
Since the script worked as expected until you added the SMS-sending code, that would imply that there's a problem with the new code.
Extract the SMS-sending code into a file on its own and test that, perhaps from the command line. Don't forget to check for cURL-specific errors (network errors, SSL error, etc.) with curl_error() and curl_errno(), like this:
$data = curl_exec($ch);
if (curl_errno($ch) > 0) {
print 'There was a cURL error: ' . $curl_error($ch);
}
Check the PHP and server logs also for error messages.
Related
I have a page that is generated using data from a database into a table format.
Each result of a student is displayed on a page so that when printed on a printer, each result is printed on a page. I need now to generate a pdf for each student. How can I add code to generate the pdf, using the name of the student?
Thanks in advance.
<body>
<?php
$grade=7;
require 'GetStudentNames.php';
while ($row1 = $result1->fetch_assoc()) { ?>
<P style="page-break-before: always">
<table margin-top="70px" width="100%">
<tr>
<td rowspan="2"><img src="logo.PNG" alt="logo"></td>
<td style="text-align:center" rowspan="1">
<h2>xyz School</h2>
</td>
<tr>
<td rowspan="1" style="text-align: center; ">
<h3 style="text-decoration: underline ;text-align:center">Student Report Sheet - First Term 2021</h3>
</td>
</tr>
</table>
<?php echo '<br><table width="100%"><th width="50%">Student Name: '.#$row1["name"].' '.#$row1["firstname"].'</th>';
echo '</td>';
require 'db.php';
$sql = "select subject from results where SN = '".#$row1["sn"]."' order by listorder";
$result = $conn->query($sql);
$count=1;
while ($row = $result->fetch_assoc()) {
echo '<tr class="oneSubj"><td class="oneSubj">'. $count.'. '.#$row["subject"].'</td>
</tr>';
$count++;
}?>
</table>
<br>
<table style="width: 100%">
<th style="width:25%">Absences..................</th>
<br>
<h5 style="text-decoration: underline ;text-align:center">Special Mention</h5>
</table>
<?php }?>
</body>
This question already has answers here:
How do you make sure email you send programmatically is not automatically marked as spam?
(24 answers)
Closed 6 years ago.
This is my first post. Yeah!
I got a problem with my contact form. it sends the email to my spambox.
How to avoid the spambox using php mail() function?
I already search on stackoverflow and serverfault but i can't seem to find the right solution....
This is the code that i am using.
<?php
if (isset($_POST['email'])
&& isset($_POST['name'])
&& isset($_POST['message'])
) {
$admin_email = "info#mywebsite.nl";
$name = htmlspecialchars($_POST['name']);
$phone = htmlspecialchars($_POST['phone']);
$email = htmlspecialchars($_POST['email']);
$subject = "Contact";
$comment = nl2br(htmlspecialchars($_POST['message']));
$to = $admin_email;
$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "Return-Path: The Sender <" . $admin_email . ">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$message .= "<html>
<body style='margin: 0; padding: 0; font-family: Roboto Slab;'>
<table cellpadding='0' cellspacing='0' width='100%'>
<tr>
<td>
<table style='border: 1px solid #c7c5c5;' align='center' cellpadding='0' cellspacing='0' width='600' style='border-collapse: collapse;'>
<tr height='301'>
<td align='center' bgcolor='#ffffff' style='padding: 0 0 0 0;'>
<img src='myimage' alt='Contact' width='100%' height='100%' style='display: block;' />
</td>
</tr>
<tr>
<td bgcolor='#eee' style='padding: 40px 30px 40px 30px; background-color: #eee;'>
<table cellpadding='0' cellspacing='0' width='100%'>
<tr>
<td>
<h1 style='font-family: Roboto Slab;'>Contactinformation</h1>
</td>
</tr>
<tr>
<td style='padding: 20px 0 30px 0; font-family: Roboto Slab;'>
<b>From:</b> " . $naam . " <br/>
<b>E-mail:</b> " . $email . " <br/>
<b>Phone:</b> " . $phone . "
</td>
</tr>
<tr>
<td>
<h1 style='font-family: Roboto Slab;'>Message</h1>
</td>
</tr>
<tr>
<td style='padding: 20px 0 30px 0; font-family: Roboto Slab;'>
" . $comment . "
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor='#33333' style='padding: 30px 30px 30px 30px; background-color: #333;'>
<table cellpadding='0' cellspacing='0' width='100%'>
<td style='color: #fed136; font-family: Roboto Slab;' width='70%'>
Copyright ®
<a style='color: #fed136; font-family: Roboto Slab;' href=''></a> " . $thisyear . "<br/>
</td>
<td align='right'>
<table border='0' cellpadding='0' cellspacing='0'>
<tr>
<td>
<a style='color: #fed136; font-family: Roboto Slab;' href=''>
</a>
</td>
</tr>
</table>
</td>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>";
mail($to, $subject, $message, $headers);
}
?>
Many thanks in advance!
Some mail clients like gmail has certain rules to mark a mail as spam. If the mail subject or body containsfree/promo/offer/,etc. and it is not from a trusted sender, it will be marked as spam. Also such mail clients blacklist some senders and list it in spam box.
It happen to many big companies too.
I have ready order confirm script in HTML/PHP in Asp.net project (receipt.php) ready to mail to customer, but strangely can't manage to send it with Sendgrid no matter how hard I've tried.
<?php
$_SESSION['data'] = $_POST['data'];
$data = $_SESSION['data'];
$email = $data[email];
$first_name = $data[shipping_address][name];
$address1 = $data[shipping_address][address_line_1];
$zip = $data[shipping_address][zip];
$city = $data[shipping_address][city];
$messageaddr = "
<html>
<head>
<title>
<td align='left' valign='bottom' width='350'>
<font face='Verdana, Geneva, sans-serif' size='2'></font>
</td>
<td align='left' valign='bottom' width='250'>
</td>
</tr>
</tbody></table>
<hr>
<table width='100%' cellpadding='0' cellspacing='0'>
<tbody><tr>
<td valign='top'>
<p><font face='Verdana, Geneva, sans-serif' size='4'>Laskutusosoite</font></p>
<font face='Verdana, Geneva, sans-serif' size='2'>
$first_name<br>
<br>
$address1<br>
$zip $city<br>
<br>
Suomi<br>
<a href='mailto: $email' target='_blank'>$email</a><br>
<div id=':nj' class='a3s' style='overflow: hidden;'><div class='adM'>
$namearr = $_POST["name"];
$imagearr = $_POST["image"];
$pricearr = $_POST["price"];
$quantityarr = $_POST["quantity"];
$totalcostarr = $_POST["totalcost"];
ob_start();
for ($x = 0; $x <= $lenth-1; $x++) {
echo "<td align='left' style='padding:10px 10px 10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'>
<td align='right' style='padding:10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'><p><font face='Tahoma, arial, sans-serif' size='2'>$pricearr[$x]<br></font></p></td>
<td align='right' style='padding:10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'><p><font face='Tahoma, arial, sans-serif' size='2'>$quantityarr[$x]<br></font></p></td>
<td align='right' style='padding:10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'><p><font face='Tahoma, arial, sans-serif' size='2'>$totalcostarr[$x]<br></font></p></td>
</tr><tr>
$products = ob_get_clean();
ob_end_clean();
$footermessage = "
</tr></tbody>
<tfoot>
<tr>
<td style='padding:10px 0;border-bottom:2px solid #000'> </td>
<td style='padding:10px 0;border-bottom:2px solid #000' align='right'><font face='Tahoma, arial, sans-serif' size='2'>Välisumma<br>Toimitus</font></td>
<td style='padding:10px 0;border-bottom:2px solid #000'> </td>
<td style='padding:10px 0;border-bottom:2px solid #000' align='right'><font face='Tahoma, arial, sans-serif' size='2'>$subtotal<br>$shipping</font></td>
</tr>
<tr>
style='padding:10px 0;border-bottom:1px solid #000'> </td>
</tr>
</tbody>
<tfoot>
";
$message = $messageaddr . ' ' . $products . ' ' . $footermessage;
return $message;
?>
I've tried with GitHub instructs https://github.com/sendgrid/sendgrid-php, added necessary 'requires' to composer.json-file etc., what else do I need on top these, except of course user and password?
No more lucky with instructions of Azure https://azure.microsoft.com/en-us/documentation/articles/store-sendgrid-php-how-to-send-email/ ,I have composer, but no matter is it with SMTP API or Web Api, with Swift ends for same 500 server error, can't even managed to install for Web Api with Curl.
Sendgrid wizard https://sendgrid.com/docs/Utilities/code_workshop.html provided the whole lib/vendor folders and several probable essential files, but don't know, should the whole package include my Web api project or just necessary (sendgrid-php, autoload.php etc.) and to which directory they needed to copy?
How on earth they call sendgrid easy(????) or maybe I still miss something essential?
Would be grateful, if somebody could give yet another instructions for dummy , prefer with PHP-script, but with ASP.NET C# too, if that could be apply for this equally.
main.js posting the receipt;
var xhr = $.post('receipt.php', { data: data, name: name, image: image, price: price, quantity: quantity, totalcost: totalcost, totals: basketCollection.totals , length: basketCollection.length }, function (data) {
var data_from_ajax = data;
console.log(data_from_ajax);
});
After an hours of trying got it work! Main PHP-script was in a wrong directory related to the others in package.
Just sending dublicate emails mostly. Could it even cause from Sendgrid or just a local operator problem?
I have a page that shows the responses from my form (in a webpage). At the moment, all the responses sit on one page, one after the other. I would like the page to show a list of all the dates submitted (date_submitted) and ID number and when that is clicked it takes us to a page with that particular response (i.e. the full response). How do I create a link that will take it to this record?
This is my code for that page:
<?php error_reporting(E_ALL); ?>
<head>
<link rel="stylesheet" type="text/css" href="surveystyle.css" media="all" />
</head>
<body>
<div id="container2">
<div class="logo-header"><img src="images/logo.jpg" alt="" width="205" height="119" /></div>
<h2> Guest Questionnaire Responses </h2>
<?php
try {
$handler = new PDO('mysql:host=localhost;dbname=***', '***', '***');
$handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo $e->getMessage();
die();
}
class guestquestionnaireEntry
{
public $id, $date_submitted, $choice, $expectations, $res, $res_information, $res_staff, $further_comments1,
$entry;
public function __construct()
{
$this->entry = "ID
<tr style='text-align: left; font:arial;'><td><h3>Date Submitted: {$this->date_submitted}</h3></td></tr>
<BR>
<table border='1' align='center'>
<tr style='background: #566890; font-size: 8pt; font-weight: bold; color: #fff;'>
<td colspan='3'>Prior to Arrival</td>
</tr>
<tr style='font-size: 8pt;'>
<td width='60%'>What made you choose us for your recent stay? </td>
<td width='40%' colspan='2'>{$this->choice}</td>
</tr>
<tr style='font-size: 8pt;'>
<td>Did our hotel meet your expectations as advertised? If no, please state why: </td>
<td width='40%' colspan='2'>{$this->expectations}</td>
</tr>
<tr style='background: #566890; font-size: 8pt; font-weight: bold; color: #fff;'>
<td colspan='3'>Making your Reservation</td>
</tr>
<BR>
<tr style='font-size: 8pt;'>
<td>Ease of making your reservation: </td>
<td width='40%'>$img</td>
<td width='5%'>{$this->res}</td>
</tr>
<BR>
<tr style='font-size: 8pt;'>
<td>Hotel information offered: </td>
<td width='40%'>$img2</td>
<td width='5%'>{$this->res_information}</td>
</tr>
<BR>
<tr style='font-size: 8pt;'>
<td>Warmth and friendliness of staff: </td>
<td width='40%'>$img3</td>
<td width='5%'>{$this->res_staff}</td>
</tr>
<BR>
<tr style='font-size: 8pt;'>
<td colspan='3'>Further Comments: </BR></BR>{$this->further_comments1}</td>
</tr>
<BR>
</table>";
}
}
// Checks if the submitted is a number. If so, isolates the ID and adds "where" clause
$id = (!empty($_GET['ID']) && is_numeric($_GET['ID']))? " where ID = '".$_GET['ID']."'" : "";
// Add the $id to the end of the string
// A single call would be SELECT * FROM guestquestionnaire where ID = '1'
$query = $handler->query("SELECT * FROM guestquestionnaire{$id}");
$query->setFetchMode(PDO::FETCH_CLASS, 'guestquestionnaireEntry');
while($r = $query->fetch()) {
echo $r->entry, '<br>';
}
?>
</div>
</body>
You need to do a where in your sql:
HTML Button:
<!-- Use whatever here to click on that triggers the ID reload -->
ID
SQL Query:
// Checks if the submitted is a number. If so, isolates the ID and adds "where" clause
$id = (!empty($_GET['ID']) && is_numeric($_GET['ID']))? " where ID = '".$_GET['ID']."'" : "";
// Add the $id to the end of the string
// A single call would be SELECT * FROM guestquestionnaire where ID = '1'
$query = $handler->query("SELECT * FROM guestquestionnaire{$id}");
$query->setFetchMode(PDO::FETCH_CLASS, 'guestquestionnaireEntry');
EDIT:
// Should be something like this
public function __construct()
{
$this->entry = "
ID...etc.
Hi if you go to http://www.deakin.edu.au/~jrhaywar/SIT104/Contact.php you will find the webpage workings (or not working in this case). What i wish for the program to do is show the form if there is not post action however if there is a post action to replace the form entries with the details of the forms. As Well as add the details to the SQL Database. However it now just repeats the tables and forms multiple times. Could someone look at this quickly for me and try to help fix the problem?
Cheers
Jesse,
Here's the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Assignment 1 - SIT 104 - 214151511</title>
<!--This is where the Classes and Division Styles are setup for recall later in the code-->
<style type="text/css">
#Wrapper{
Background:url(images/Crests.png);
background-size:26%;
background-position:top 6px;
height:100%;
}
#NavBar{
Height:26%;
Border:groove Gold 6px;
}
#Body{
Height:76%;
border:groove Gold 6px;
text-align:center;
}
#Footer{
Height:26%;
background:#999;
Border:groove gold 6px;
}
</style>
</head>
<body>
<!-- This is the php to setup the connection to the oracle database needed to record information and to display reciept -->
<?php
/* Set oracle user login and password info */
$dbuser = "jrhaywar"; /* your deakin login */
$dbpass = "haybreaker"; /* your oracle access password */
$db = "SSID";
$connect = OCILogon($dbuser, $dbpass, $db);
if (!$connect) {
echo "An error occurred connecting to the database";
exit;
}
/* build sql statement using form data */
$query = "SELECT * FROM sit104Items";
if(isset($_POST['Submit'])){
$name = $POST_['Name'];
$phone = $POST_['Phone'];
$email = $POST_['Email'];
$reason = $POST_['Reason'];
$message = $POST_['Message'];
$insert = $insert = "INSERT INTO ContactUs VALUES ('$name','$phone','$email','$reason','$message')";
$Insert = OCIParse($connect, $insert);
}
/* check the sql statement for errors and if errors report them */
$stmt = OCIParse($connect, $query);
//echo "SQL: $query<br>";
if(!$stmt) {
echo "An error occurred in parsing the sql string.\n";
exit;
}
OCIExecute($stmt);
?>
<!--This is the beggining of the code that will be shown in the browser Starting with the wrapper and Navigation bar and then continuing with the "body" division and ended by the footer-->
<div id="Wrapper">
<div id="NavBar">
<table style="width:100%" height="10%" bgcolor="#CCFF00">
<tr>
<td width="26%" align="center" ><a link href="ass1.htm"><b>Home Page</b></a></td>
<td width="26%" align="center"><a link href="Items.php"><b>Items</b></a></td>
<td width="26%" align="center" ><a link href="FAQ.html"><b>FAQ/HELP</b></a></td>
<td width="26%" align="center" ><a link href="Contact.html"><b>Contact Us</b></a></td>
</tr>
</table>
</div>
<div id="Body">
<font size="6" face="Serpentine Bold" color="lime" ><b>
Welcome to the Order Page, please order what you wish!</b>
<hr/>
</font>
<?php
while(OCIFetch($stmt)){
/*Calculate what to do and show if Post is found*/
if(isset($_POST['Submit'])){
echo('<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="4" bgcolor="#00FFCC"><b>Personal and Delivery Details</b></td>
</tr>
<tr>
<td width="6%" >Name:</td>
<td width="46%" >');
$fg1 = OCIResult($stmt, "NAME");
echo $fg1;
echo('</td>
<td width="6%" >Phone Number:</td>
<td width="46%" >');
$fg2 = OCIResult($stmt, "PHONE");
echo $fg2;
echo('</td>
</tr>
<tr>
<td width="10%">E-mail</td>
<td width="80%" colspan="3">');
$fg3 = OCIResult($stmt, "EMAIL");
echo $fg3;
echo('</td>
</tr>
</table>
<hr/>
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="2" bgcolor="#00FFCC" ><b>Message</b></td>
</tr>
<tr>
<td width="10%">Reason for message:</td>
<td width="90%">');
$fg4 = OCIResult($stmt, "REASON");
echo $fg4;
echo('</tr>
<tr>
<td width="10%">Type Message Here: </td>
<td width="90%">
');
$fg5 = OCIResult($stmt, "MESSAGE");
echo $fg5;
echo('</td>
</tr>
</table>');
} /*End of the First If. So now compute what to do if post isn't used */
else
{
echo('
<form name="ContactForm" onSubmit="Contact.php" >
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="4" bgcolor="#00FFCC"><b>Personal and Delivery Details</b></td>
</tr>
<tr>
<td width="6%" >Name:</td>
<td width="46%" ><input Type="text" name="Name" style="width:86%"/></td>
<td width="6%" >Phone Number:</td>
<td width="46%" ><input type="text" Name="Phone" style="width:86%"/></td>
</tr>
<tr>
<td width="10%">E-mail</td>
<td width="80%" colspan="3"><input type="text" name="Email" style="width:30%" /></td>
</tr>
</table>
<hr/>
<table align="center" bgcolor="#00FF66" border="4" bordercolor="black" width="100%">
<tr>
<td colspan="2" bgcolor="#00FFCC" ><b>Message</b></td>
</tr>
<tr>
<td width="10%">Reason for message:</td>
<td width="90%"><select name="Reason">
<option value="General Enquiry" >General Enquiry</option>
<option value="Returning Item" >Returning Item</option>
<option value="Missing Item" >Missing Item</option>
<option value="Price Negotiation">Price Negotiation</option>
</select>
</tr>
<tr>
<td width="10%">Type Message Here: </td>
<td width="90%"><textarea name="Message" rows="5" style="width:90%;height:100%;"></textarea> </td>
</tr>
</table>
<input type="submit" value="Send Message" style="width:95%; height:35px; margin-top:10px; background- color:#0F0"/>
</form>
');}
}
OCILogOff($connect);
?>
<br/>
</div>
<div id="Footer">
Links:<br/>
Home<br/>
Items<br/>
Order Form<br/>
faq/help<br/>
Contact Us<hr/>
<p align="left">
©Deakin University, School of Information Technology. This web page has been developed as a student assignment for the unit SIT104: Introduction to Web Development. Therefore it is not part of the University's authorised web site. DO NOT USE THE INFORMATION CONTAINED ON THIS WEB PAGE IN ANY WAY
</p>
</div>
</div>
</body>
</html>