Hey everyone
So i have been pulling my hairs over this and need some guidance and help. In a nutshell, i need to be able to fill in an empty field(field is called “shippingnumber”) within the database or custom backend, which would then trigger a custom email notification to the persons email within the same row. Here is what i got so far. We will be using the email "[email protected]" as an example. This is the email that the person will submit into the form below, and is also the same email which will receive the email notification when the field, “shippingnumber” has data put into it.
So i have created an order form (http://www.topchoicedata.com/175.php#175). Here we have 5 fields the customer would enter with the option for an extra shipping cost. When the user submits, it will take them to a paypal payment page. At this point the persons info from the 5 fields has been inputted into a new row within the table database. When the person progresses further with the payment, the rest of the fields get inputted, all except for one, that field is called “shippingnumber”. This is located in an hidden input field for the form mentioned above. Below is the html code for the $175 form, with the form action being done in a subfolder named PPPaymentForm/PPPaymentForm.php. Take notice of the “shippingorder” input below in the form.
[code]
19.99(Optional Shipping, will be added to total if chosen)
Pay Now
<input type="hidden" name="hdwtablename" id="hdwtablename" value="1">
<input type="hidden" name="hdwppproductname" id="hdwppproductname" value="Basic Plan $175">
<input type="hidden" name="hdwppamount" id="hdwppamount" value="175">
<input type="hidden" name="hdwppcurrency" id="hdwppcurrency" value="USD">
<input type="hidden" name="hdwpplanguage" id="hdwpplanguage" value="en_US">
<input type="hidden" name="hdwok" id="hdwok" value="http://www.topchoicedata.com/paymentmadethanks.php">
<input type="hidden" name="hdwemail" id="hdwemail" value="mauriceflopez+gmail.com">
<input type="hidden" name="hdwnook" id="hdwnook" value="http://">
<input type="hidden" name="hdwactivation_email" id="hdwactivation_email" value="email">
<input type="hidden" name="plan" id="plan" value="$175">
<input type="hidden" name="shippingchoosen" id="shippingchoosen" value="">
<input type="hidden" name="shippingnumber" id="shippingnumber" value=""> -----**TAKE NOTICE HERE**
[/code]
Below is a link to a picture of my backend when the customers info is saved after submitting their credentials in the 175 form(Info collected at this point is only for form submission and not paypal info).
As you can see, the person submitted his email("[email protected]) in the form, and is now in the row, at this point the shippingorder field is empty which is what i want. I now want to fill the “shipping order” field with info, which would then trigger an email to the person’s email in that row. I wrote some code hoping that it would work, and placed it at the bottom of the PPPaymentForm/PPPaymentForm.php file, but nothing is working. Below is the code i added to the bottom of the PPPaymentForm.php, with section 2 being the section where i was trying to send an email if the shippingorder field had data put into it. Any help would be greatly greatly appreciated. I have also included a link to the code for PPPaymentForm.php
http://www.topchoicedata.com/phpcode.txt
[php]
$connect = mysql_connect(“localhost”, “username”, “password”) or die (“Cannot connect”);
mysql_select_db(“database”) or die(“Cannot select database”);
[b] /SECTION 2/
/*
- Checks form field for shipping number, then where shipping has email, send email to recipient
*/
$results = mysql_query(“SELECT shippingnumber FROM topchoiceform WHERE email=$email”);
if(mysqli_num_rows($result) >0){
$row = mysqli_fetch_assoc($result);
if ($_POST[‘shippingnumber’]==$row[‘shippingnumber’]) {
$email = $_POST['email'];
$subject = "Product has been shipped";
$message='Your product has been shipped';
foreach($email as $email){
mail($email,$subject, $message);
}
}
}[/b]
/SECTION 3/
/*
-
Checks if the shipping number exists and look for email in that row which belongs to that shipping number to send email out.
*/$sql = “SELECT COUNT(*) FROM topchoiceform WHERE shippingnumber = ‘$shippingnumber’ AND ‘$shippingnumber’ MATCHES $email”;
$result = mysql_query($sql)or die('Could not find member: ’ . mysql_error());
if(mysqli_num_rows($result) >0){
$row = mysqli_fetch_assoc($result);
if($shippingnumber = $row[‘shippingnumber’]){
echo “It exists”;
}
}else{
echo “No matching shipping number found upon sql call”;}
[/php]