Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9163531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:28:11+00:00 2026-06-17T14:28:11+00:00

On my website , I use a contact form, which causes me a lot

  • 0

On my website, I use a contact form, which causes me a lot of trouble. I already spent some time on actually getting the mail() PHP function working on 64bit Debian with exim4, but I finally did it, and mails are sent.

Now I am experiencing another problem, which I can’t figure out how to solve. First of all the code.

<?php
$your_email = 'blahblah@gmail.com';
session_start();
$errors        = '';
$name          = '';
$visitor_email = '';
$user_message  = '';

if (isset($_POST['submit'])) {
    $name          = $_POST['name'];
    $visitor_email = $_POST['email'];
    $user_message  = $_POST['message'];
    ///------------Do Validations-------------
    if (empty($name) || empty($visitor_email)) {
        $errors .= "\n Name and Email are required fields. ";
    }
    if (IsInjected($visitor_email)) {
        $errors .= "\n Bad email value!";
    }
    if (empty($_SESSION['6_letters_code']) || strcmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0) {
        //Note: the captcha code is compared case insensitively.
        //if you want case sensitive match, update the check above to
        // strcmp()
        $errors .= "\n The captcha code does not match!";
    }

    if (empty($errors)) {
        //send the email
        $to      = $your_email;
        $subject = "New form submission";
        $from    = $your_email;

        $body = "A user  $name submitted the contact form:\n" . "Name: $name\n" . "Email: $visitor_email \n" . "Message: \n " . "$user_message\n";

        $headers = "From: $from \r\n";
        $headers .= "Reply-To: $visitor_email \r\n";

        if (mail($to, $subject, $body, $headers)) {
            header('Location: http://www.lolstreamgallery.net/thank-you.html');
        } else {
            $errors .= "\n E-Mail coulnd be sent!";
        }
    }
}

The problem is that that the header redirection is not working. The mail() does work, so the header should be executed. When I test the file locally, the redirection does occur.

If you wanna test the contact form, you can do it here.

Here is the whole file code:

EDIT2:

I’m now using the function of Ian Brindley which made the redirect work, but not the header function. It seems there is some output before the header.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T14:28:12+00:00Added an answer on June 17, 2026 at 2:28 pm

    At first glance I cannot see any output before the header() call.

    If there is no better alternative, here is a function I found a while ago which I now user for pretty much all of my redirects.

    function redirect($url){
        if (!headers_sent()){    
            header('Location: '.$url);
            exit;
        }
        else {  
            echo '<script type="text/javascript">';
            echo 'window.location.href="'.$url.'";';
            echo '</script>';
            echo '<noscript>';
            echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
            echo '</noscript>'; exit;
        }
    }
    

    I know the non server side redirect is not ideal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My website stephenharman.com is having some issues with it's contact form. I use a
use this website a lot but first time posting. My program creates a number
On my client's website (domain.com) we have a contact form which sends an email
I have a website, and in the Contact section I have a form which
I have a simple php script which I use in form on my website.
I'd like to use a contact form for a website I'm creating, but PHP
I created a contact form on my classified ads website. I use the following
I use Google Spreadsheets' built-in form functionality to build contact forms on my website.
I want to be able to open my website and use some kind of
I have a contact form on my website, and everything works like a charm.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.