0

looking to use one webpage for a user to add information and i am using a button to pass that data onto another page, that other page adds the data into a database - this is all working

as part of clicking on the button i want an email to be sent automatically to an email address to say something has been added to the database

so the email is acting like a notification

i can get the email function to work on a single page, but when added to the page i want it to work on it doesn't work.

any help would be appreciated as to why this doesn't work:

UPDATED CODE, it sends an email on a single page, but the button here passes the data onto another page, but it will add to the database, but wont send the email...

echo "</form>";
}
echo "</table>";

} else {
echo "You have successfully added the property to the current portfolio";
}

if(isset($_POST['submit']))
{
$to      = 'Property Administrator <admin@luxor-estates.com>';
$subject = 'IMPORTANT: Property has been added and needs to be reviewed';
$body = 'Property has been added to the Luxor Estates Portfolio and needs to    
be reviewed. Many thanks.';

mail($to, $subject, $body);
}


$conn->close();
[/insert_php]
  • Do you get any error? – Tomasz Aug 27 '15 at 22:31
  • i can get an email to send now which is great news when the page calls itself, i.e. i have a test page which sends the email, but the page i use to add to the database passes the variables to another page and that button i wanted to just send an email but it wont work that way....any ideas? – Craig Nicholson Aug 27 '15 at 23:26
  • How do you know it won't send email? What errors do you show? On the page you want to use, use this snippet: `var_dump( mail($to, $subject, $body) );`. if it returns TRUE the mail is sent, otherwise it's FALSE. Also consider using WordPress's mail function: https://codex.wordpress.org/Function_Reference/wp_mail – visevo Aug 28 '15 at 19:59

0 Answers0