Guest Posted January 23, 2012 Share Posted January 23, 2012 ok, I thought I had this working but I guess not. Once I click the submit button the email goes but I need to be redirected to a web page named http://myserver/notification_sent.php I edited the line: <form method="post"> to look like <form method="post" action="http://myserver/notification_sent.php"> & I then get redirected to the page I need but the email don't go out. $mailheaders = "From: Reporting System<[email protected]>"; $destination = array(); if (!empty($_POST['notify_jane'])) $destination[] = '[email protected]'; if (!empty($_POST['notify_john'])) $destination[] = '[email protected]'; if ($destination) { mail(join(', ', $destination), 'Document Added/Updated', 'This is a test notification', $mailheaders); } ?> <form method="post"> <input type="hidden" name="formsent" value="true" /> <br/> If you do not need to send a notification to someone you can close this window. If you do, choose the name(s) below and click submit. <br/>------------------------------------------------------- <br/>Check this box <input autocomplete="off" type="checkbox" name="notify_jane" value="yes" /> to send <strong>John Doe</strong> a notification. <br/>Check this box <input autocomplete="off" type="checkbox" name="notify_jane" value="yes" /> to send <strong>Jane Doe</strong> a notification. <br> <br> <input type="submit" value="Submit" /> <br/>------------------------------------------------------- </form> <?php Quote Link to comment https://forums.phpfreaks.com/topic/255624-php-code-issue/ Share on other sites More sharing options...
dzelenika Posted January 23, 2012 Share Posted January 23, 2012 You can do it by adding header (redirection). But I think that better solution is to add mail sending code to http://myserver/notification_sent.php $mailheaders = "From: Reporting System<[email protected]>"; $destination = array(); if (!empty($_POST['notify_jane'])) $destination[] = '[email protected]'; if (!empty($_POST['notify_john'])) $destination[] = '[email protected]'; if ($destination) { mail(join(', ', $destination), 'Document Added/Updated', 'This is a test notification', $mailheaders); header("Location: http://myserver/notification_sent.php"); } ?> <form method="post"> <input type="hidden" name="formsent" value="true" /> <br/> If you do not need to send a notification to someone you can close this window. If you do, choose the name(s) below and click submit. <br/>------------------------------------------------------- <br/>Check this box <input autocomplete="off" type="checkbox" name="notify_jane" value="yes" /> to send <strong>John Doe</strong> a notification. <br/>Check this box <input autocomplete="off" type="checkbox" name="notify_jane" value="yes" /> to send <strong>Jane Doe</strong> a notification. <br> <br> <input type="submit" value="Submit" /> <br/>------------------------------------------------------- </form> <?php Quote Link to comment https://forums.phpfreaks.com/topic/255624-php-code-issue/#findComment-1310441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.