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 6993767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:48:23+00:00 2026-05-27T19:48:23+00:00

I have a problem with my contact form. When the data is sent, I

  • 0

I have a problem with my contact form. When the data is sent, I would like to have the fields blank again. I’ve tried a lot but nothing works.

Here is the script to send the mail:

<?php
error_reporting(0);
session_start();


if ("post" === strtolower($_SERVER['REQUEST_METHOD'])) {

$name = $_POST['name'];
$email = $_POST['email'];
$adres = $_POST['adres'];
$postcode = $_POST['postcode'];
$woonplaats = $_POST['woonplaats'];
$telefoon = $_POST['telefoon'];
$dag = $_POST['dag'];
$dag_nummer = $_POST['dag_nummer'];
$maand = $_POST['maand'];
$tijd = $_POST['tijd'];
$opmerking = $_POST['opmerking'];

$_SESSION['name'] = $name;
$_SESSION['email'] = $email;
$_SESSION['adres'] = $adres;
$_SESSION['postcode'] = $postcode;
$_SESSION['woonplaats'] = $woonplaats;
$_SESSION['telefoon'] = $telefoon;
$_SESSION['dag'] = $dag;
$_SESSION['dag_nummer'] = $dag_nummer;
$_SESSION['maand'] = $maand;
$_SESSION['tijd'] = $tijd;
$_SESSION['opmerking'] = $opmerking;

if (empty($name) || empty($email) || empty($telefoon) || empty($tijd)) {

    if (empty($name)) {
        $errors[] = "name";
    }

    if (empty($email)) {
        $errors[] = "email";
    }

    if (empty($telefoon)) {
        $errors[] = "telefoon";
    }

    if (empty($tijd)) {
        $errors[] = "tijd";
    }

    header("Location: afspraak.php?error[]=" .implode('&error[]=', $errors));
    exit;
} else {

    // send mail if (post) parameters are correct
    mail(
        'tim-luijten@hotmail.com', 
        'Afsprakenformulier o-vita.nl', 
        "Er is contact opgenomen via het afsprakenformulier. Zie onderstaande gegevens: \n\n
        Naam: {$name} \n
        E-mailadres: {$email} \n
        Adres: {$adres} \n
        Postcode: {$postcode} \n
        Woonplaats: {$woonplaats} \n
        Telefoonnummer: {$telefoon} \n
        Datum: {$dag} - {$dag_nummer} - {$maand} \n
        Tijd: {$tijd} \n
        Opmerking: {$opmerking} \n"         
                    ,
        "From: {$email} \r\n"
    );

    header("Location: bedankt_afspraak.php");
    exit;
}

}
header("Location: afspraak.php");
?>

The form:

              <form action="afspraak_verstuur.php" method="post" name="contact_form">
                <table width="300" border="0">
                        <tr>
                        <td class="tabform">Naam*:</td>
                        <td>&nbsp;</td>
                        </tr>
                        <tr>
                        <td colspan="2">
                                <input name="name" type="text" class="text_veld" value="<?php echo (isset($_SESSION['name'])) ? $_SESSION['name'] : ""; ?>" /></td>
                </tr>
                <?php if (in_array('name', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen naam ingevuld</font>
                        </td>
                </tr>
                <?php } ?>


                        <tr>
                        <td class="tabform">E-mail*:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                        <input name="email" type="text" class="text_veld" value="<?php echo (isset($_SESSION['email'])) ? $_SESSION['email'] : ""; ?>" />
                                </td>
                        </tr>
                        <?php if (in_array('email', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen e-mailadres ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>


                        <tr>
                        <td class="tabform">Adres:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                        <input name="adres" type="text" class="text_veld" value="<?php echo (isset($_SESSION['adres'])) ? $_SESSION['adres'] : ""; ?>" />
                                </td>
                        </tr>
                        <?php if (in_array('adres', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen adres ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>


                                <tr>
                        <td class="tabform">Postcode:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                        <input name="postcode" type="text" class="text_veld" value="<?php echo (isset($_SESSION['postcode'])) ? $_SESSION['postcode'] : ""; ?>" />
                                </td>
                        </tr>
                        <?php if (in_array('postcode', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen postcode ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>


            <tr>
                        <td class="tabform">Woonplaats:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                        <input name="woonplaats" type="text" class="text_veld" value="<?php echo (isset($_SESSION['woonplaats'])) ? $_SESSION['woonplaats'] : ""; ?>" />
                                </td>
                        </tr>
                        <?php if (in_array('woonplaats', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen woonplaats ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>


                        <tr>
                        <td class="tabform">Telefoon*:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                        <input name="telefoon" type="text" class="text_veld" value="<?php echo (isset($_SESSION['telefoon'])) ? $_SESSION['telefoon'] : ""; ?>" />
                                </td>
                        </tr>
                        <?php if (in_array('telefoon', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen telefoonnummer ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>

            <tr>
                        <td class="tabform">Datum*:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                        <select name="dag" type="text" class="text_dag" value="Selecteer een dag" />
                    <option value="maandag">maandag</option>
                    <option value="dinsdag">dinsdag</option>
                    <option value="woensdag">woensdag</option>
                    <option value="donderdag">donderdag</option>
                    <option value="vrijdag">vrijdag</option>
                    <option value="zaterdag">zaterdag</option>
                    </select>
    <?php echo (isset($_SESSION['dag'])) ? $_SESSION['dag'] : ""; ?>

                    <select name="dag_nummer" type="text" class="text_dag_nummer" value="1" />
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option> 
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option> 
                    <option value="19">19</option>
                    <option value="20">20</option>
                    <option value="21">21</option>
                    <option value="22">22</option>
                    <option value="23">23</option>
                    <option value="24">24</option>
                    <option value="25">25</option>
                    <option value="26">26</option>
                    <option value="27">27</option>
                    <option value="28">28</option>
                    <option value="29">29</option>
                    <option value="30">30</option>
                    <option value="31">31</option>
                    </select>
    <?php echo (isset($_SESSION['dag_nummer'])) ? $_SESSION['dag_nummer'] : ""; ?>

                    <select name="maand" type="text" class="text_maand" value="Januari" />
                    <option value="januari">januari</option>
                    <option value="februari">februari</option>
                    <option value="maart">maart</option>
                    <option value="april">april</option>
                    <option value="mei">mei</option>
                    <option value="juni">juni</option>
                    <option value="juli">juli</option>
                    <option value="augustus">augustus</option>
                    <option value="september">september</option>
                    <option value="oktober">oktober</option>
                    <option value="november">november</option>
                    <option value="december">december</option>
                    </select>
      <?php echo (isset($_SESSION['maand'])) ? $_SESSION['maand'] : ""; ?>
                                </td>
                        </tr>
                        <?php if (in_array('datum', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen datum ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>


            <tr>
                        <td class="tabform">Tijd*:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td colspan="2">
                                        <input name="tijd" type="text" class="text_veld" value="<?php echo (isset($_SESSION['tijd'])) ? $_SESSION['tijd'] : ""; ?>" />
                                </td>
                        </tr>
                        <?php if (in_array('tijd', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen tijd ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>


            <tr>
                        <td class="tabform">Opmerking:</td>
                                <td>&nbsp;</td>
                        </tr>
                        <tr>
                                <td height="60" colspan="2">
                                        <textarea name="opmerking" type="text" class="text_comments" rows="4" value="" /><?php echo (isset($_SESSION['opmerking'])) ? $_SESSION['opmerking'] : ""; ?></textarea>
                                </td>
                        </tr>
                        <?php if (in_array('opmerking', $_GET['error'])) { ?>
                <tr>
                        <td colspan="2">
                                <font color="red">Er is geen opmerking ingevuld</font>
                        </td>
                </tr>
                <?php } ?>
                        <tr>


                        <tr>
                                <td colspan="2" class="verzenden">
                                        <input name="verzenden" type="image" id="verzenden" src="img/verzenden.png" alt="Verzenden" title="Verzenden" />
                                </td>
                        </tr>
                </table>
        </form>
  • 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-05-27T19:48:23+00:00Added an answer on May 27, 2026 at 7:48 pm

    Since your using sessions to set the value in the inputs of the form you could just set those session values to nothing after the send occurs.

    } else {
    
    // send mail if (post) parameters are correct
    if (mail(
        'tim-luijten@hotmail.com', 
        'Afsprakenformulier o-vita.nl', 
        "Er is contact opgenomen via het afsprakenformulier. Zie onderstaande gegevens: \n\n
        Naam: {$name} \n
        E-mailadres: {$email} \n
        Adres: {$adres} \n
        Postcode: {$postcode} \n
        Woonplaats: {$woonplaats} \n
        Telefoonnummer: {$telefoon} \n
        Datum: {$dag} - {$dag_nummer} - {$maand} \n
        Tijd: {$tijd} \n
        Opmerking: {$opmerking} \n"         
                    ,
        "From: {$email} \r\n"
      ))
     {
         $_SESSION['name'] = "";
         $_SESSION['email'] = "";
         $_SESSION['adres'] = "";
         $_SESSION['postcode'] = "";
         $_SESSION['woonplaats'] = "";
         $_SESSION['telefoon'] = "";
         $_SESSION['dag'] = "";
         $_SESSION['dag_nummer'] = "";
         $_SESSION['maand'] = "";
         $_SESSION['tijd'] = "";
         $_SESSION['opmerking'] = "";
    
         header("Location: bedankt_afspraak.php");
    
         exit;
       } else {
        //display a message that the message failed to send.
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have bought a template that have built in contact form problem is that
I have set up an AJAX contact form on a client's website. The problem
I have a contact form on my website, which actually works :D The problem
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have problem when I try insert some data to Informix TEXT column via
I have a problem in customizing labels in a Django form This is the
I have a website with a contact form. User submits name, email and message
I have this as template account_form.html <form action=/contact/ method=post> {% for field in form
I have a form where I'm collecting contact information (name, address, etc) for an
I am writing a basic jQuery form validation script and I have something like

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.