Jump to content

Recommended Posts

I want to change my php form handler. Right now when someone hits submit it writes out a thank you using the code below:

 

$recipient="[email protected]";

      $subject="Registration Information";

      error_reporting(0);

      if (mail($recipient, $subject, $msg)){

        echo "<h1>Thank You</h1><p>Your form has been submitted!.:</p>\n";

        echo nl2br($input);

      } else

        echo "An error occurred and the message could not be sent.";

  } else

      echo "Bad request method";

 

 

Instead i would like it to just redirect them to another web page. How do I do this? Thanks for helping a noob to php.

Link to comment
https://forums.phpfreaks.com/topic/139043-noob-needs-help/
Share on other sites

$recipient="[email protected]";
      $subject="Registration Information";
      error_reporting(0);
      if (mail($recipient, $subject, $msg)){
         header("Location: somepage.php"); exit();
      } else
         echo "An error occurred and the message could not be sent.";
   } else
      echo "Bad request method";

 

Note: that will only work if there is no output before that header call.  If you have output before that header call, refer to the sticky about headers in this forum.

Link to comment
https://forums.phpfreaks.com/topic/139043-noob-needs-help/#findComment-727213
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.