0

i built a contact form and used header to redirect to thank you page but it is not redirecting me suddenly today, i checked the linked and even tried to put google and facebook links and all i get is "page not found"

any help?

<?php 
                }  
                else                /* send the submitted data */ 
                { 
                    $name=$_REQUEST['name']; 
                    $email=$_REQUEST['email']; 
                    $message=$_REQUEST['message']; 
                    if (($name=="")||($message=="")) 
                    {

                    } 
                    else{         
                        $from="From: $name<$email>\r\nReturn-path: $email"; 
                        $subject="הודעה מאתר blala.co.il"; 
                        mail("blalba@gmail.com", $subject, $message, $from); 
                        header('Location: https://www.facebook.com/');
                        exit();
                    } 
                }   
                ?> 
ssabin
  • 101
  • 2
  • 13
  • The header should be the first thing in the output. Just check if there is anything echoing before it. – Satyapal Sharma Aug 04 '16 at 11:53
  • You're probably outputting before header and not seeing it. Tell us, what does error reporting show you? http://php.net/manual/en/function.error-reporting.php – Funk Forty Niner Aug 04 '16 at 12:02
  • possible duplicate of [How to fix “Headers already sent” error in PHP](http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Funk Forty Niner Aug 04 '16 at 12:02

1 Answers1

1

Try with, here I have added ob_clean() clean output before redirect page to facebook

<?php 
}  
else                /* send the submitted data */ 
{ 
    $name=$_REQUEST['name']; 
    $email=$_REQUEST['email']; 
    $message=$_REQUEST['message']; 
    if (($name=="")||($message=="")) 
    {

    } 
    else{         
        $from="From: $name<$email>\r\nReturn-path: $email"; 
        $subject="הודעה מאתר blala.co.il"; 
        mail("blalba@gmail.com", $subject, $message, $from); 
        ob_clean();
        header('Location: https://www.facebook.com/');
        exit();
    } 
}   
Haresh Vidja
  • 8,340
  • 3
  • 25
  • 42
  • 3
    Hiding errors is the *wrong* way to handle this. Fix the problem, not the symptom. – John Conde Aug 04 '16 at 12:02
  • @JohnConde, I have removed code for ignoring error, for fixing issue if mail not going then gives warning, and I have used ob_clean for that. so please remove your down vote – Haresh Vidja Aug 04 '16 at 12:24
  • You still didn't fix the problem. You're still hiding it by using output buffering. If mail() is failing they need to capture that and deal with it. This just hides and it moves along. – John Conde Aug 04 '16 at 12:26