i am trying to echo an email address onto the next page 'send_email.php' through a link using the url.
The idea is that send_email.php sends out an email to the specific email address for which that link belongs.
i am currently getting undefined index 'contact_email' errors and i am not sure what i am doing wrong, i am trying to use $_GET as a means to retrieve the email address from the url and add this to the email to/recipient line in send_email.php
our link is on 'page1' where we use a mysql query to pull details from the database like so:
$myId2 = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$query2 = mysql_query(" SELECT supplier_registration.contact_name,
supplier_registration.contact_email, supplier_registration.contact_number, supplier_registration.company_address, supplier_registration.company_postcode
FROM supplier_registration
INNER JOIN supplier_stats
ON supplier_registration.company_reg_number = supplier_stats.company_reg_number
WHERE supplier_stats.id = $myId2 AND supplier_stats.insurance_date = DATE(NOW())");
while($row2 = mysql_fetch_array( $query2 )) {
echo "<div class=\"contact_details\">Contact Details:<br/>";
echo "<p><font color=\"#999\">Contact Name:</font> ".$row2['contact_name']."<br/>";
echo "<font color=\"#999\">Contact Number:</font> ".$row2['contact_number']."<br/>";
echo "<p><font color=\"#999\">Contact Email:</font> ".$row2['contact_email']."<br/></p>";
echo "<p><font color=\"#999\">Postal Address:</font> ".$row2['company_address']."</br>";
echo "<font color=\"#999\">Contact Name:</font> ".$row2['company_postcode']."</p>";
echo "</div>";
echo "<a href=\"send_email.php?email=".$row2['contact_email']."\"\"><div class=\"buttons\">Send Reminder Email</div> </a>";
then when we click the link we go to send_email.php which looks like this:
<?php
$_GET['contact_email'];
$myEmail = $_GET['contact_email'];
$to = $myEmail;
$subject = "Hi!";
$body = "Hi,
How are you?";
if (mail($to, $subject, $body)) {
echo("<p>Email successfully sent!</p>");
} else {
echo("<p>Email delivery failed…</p>");
}
?>
but i am getting these errors:
Notice: Undefined index: contact_email in C:\xampp\htdocs\hewden_spms\send_email.php on line 2
Notice: Undefined index: contact_email in C:\xampp\htdocs\hewden_spms\send_email.php on line 3
Email successfully sent!
can someone please show me where the problem is and how i can get this to work thanks