0

Developing a contact form and have used an open-source PHP code for the submission. The email sends without a problem and coming into my inbox, however the page is returning to the contact page and showing a blank form rather than a successful/error message in its place.

Think the code / potential problem might lie here (part of the .php form). Would someone might checking it to see if I'm missing something?

if(mail($to,$subject,$message,$headers))
    header("Location:workwithme.html?msg=Thank you! I'll be in touch shortly!");
else
    header("Location:workwithme.html?msg=Oops! There was an error sending you're email. You can email me direct at jason@jasonscott.me.uk");
    //contact:-your-email@your-domain.com
amphetamachine
  • 27,620
  • 12
  • 60
  • 72
Jason
  • 209
  • 2
  • 13
  • I am assuming you are using javascript to get the `msg` parameter since you are redirecting to a .html page which can't run server side code (php). You need to show us the code from start to end of the `workwithme.html` page for us to know what going on. – Krimson Feb 18 '15 at 23:56
  • That's not necessarily true. You can tell PHP to process .html extensions. We need to see the page that processes your $_GET['msg'] – Mooseknuckles Feb 18 '15 at 23:57
  • @Mooseknuckles yes that's true but its uncommon for people to do that. Hence why I said I am assuming – Krimson Feb 18 '15 at 23:58
  • possible duplicate of [Characters allowed in GET parameter](http://stackoverflow.com/questions/1455578/characters-allowed-in-get-parameter) – Mooseknuckles Feb 19 '15 at 00:35

1 Answers1

1

Your message that is being sent after ?msg= contains invalid characters. Certain characters are reserved as delimiters or sub-delimiters -- in your case the spaces and "!" stand out (there may be others).

You'd probably be better off doing something like this:

if(mail($to,$subject,$message,$headers))
    header("Location:workwithme.html?msg=1");
else
    header("Location:workwithme.html?msg=2");

And then when you process it on the workwithme.html page, you can do something like this:

if (isset($_GET['msg'])) {

    if ($_GET['msg'] == 1) {
        // Give success message
    }

    elseif ($_GET['msg'] == 2) {
        // Give error message
    }
}
Mooseknuckles
  • 497
  • 3
  • 7