Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/255624-php-code-issue/
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/255624-php-code-issue/#findComment-1310441
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.