0

When customers submit bookings on my website http://www.n-v-m.co.uk/Booking.html most of the time the booking goes through fine but sometimes I get completely blank bookings sent through (even when I know the customer has filled the form out).

Does anybody know why this could be happening? It is a very rare problem which makes me think it may have something to do with internet settings on the customers computer

The php code I am using is displayed below:

<?php

$Name = $_POST['name']; //senders name

$to = "info@n-v-m.co.uk"; //recipient
$subject = "Order from ".$_POST['company']." (".$_POST['name'].")"; //subject
$message = $_POST['company']."|".$_POST['name']."|".$_POST['phonenum']."|".$_POST['email']."|".$_POST['vmam']."|".$_POST['vreg']."|".$_POST['colladd']."|".$_POST['collconname']."|".$_POST['collconnum']."|".$_POST['deladd']."|".$_POST['delconname']."|".$_POST['delconnum']."|".$_POST['collectiondt']."|".$_POST['deliverydt']."|".$_POST['Taxed']."|".$_POST['billadd']."|".$_POST['custordnum']."|".$_POST['addcom']; //mail body
$from = "NVM Booking Form"; //
$headers = "From: ".$from."\r\n"; //optional headerfields
 
mail($to, $subject, $message, $headers); //mail command
header( 'Location: http://www.n-v-m.co.uk/Thankyou.html' ) ;
?>

Any help would be much appreciated

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by FlashCreations
0

When customers submit bookings on my website http://www.n-v-m.co.uk/Booking.html most of the time the booking goes through fine but sometimes I get completely blank bookings sent through (even when I know the customer has filled the form out).

Does anybody know why this could be happening? It is a very rare problem which makes me think it may have something to do with internet settings on the customers computer

The php code I am using is displayed below:

<?php

$Name = $_POST['name']; //senders name

$to = "info@n-v-m.co.uk"; //recipient
$subject = "Order from ".$_POST['company']." (".$_POST['name'].")"; //subject
$message = $_POST['company']."|".$_POST['name']."|".$_POST['phonenum']."|".$_POST['email']."|".$_POST['vmam']."|".$_POST['vreg']."|".$_POST['colladd']."|".$_POST['collconname']."|".$_POST['collconnum']."|".$_POST['deladd']."|".$_POST['delconname']."|".$_POST['delconnum']."|".$_POST['collectiondt']."|".$_POST['deliverydt']."|".$_POST['Taxed']."|".$_POST['billadd']."|".$_POST['custordnum']."|".$_POST['addcom']; //mail body
$from = "NVM Booking Form"; //
$headers = "From: ".$from."\r\n"; //optional headerfields
 
mail($to, $subject, $message, $headers); //mail command
header( 'Location: http://www.n-v-m.co.uk/Thankyou.html' ) ;
?>

Any help would be much appreciated

hi there man! Ϋ

hhhmmm.
i have visited your site and it states that fill as many as possible.
it also don't have any reminders if a certain information or fill to a field is required.

do you already checked whether all the data fields in your database columns are accepting null or blank values?

i might help if you are using a MYSQL generated database.
:) good luck!

0

What do you mean by blank bookings? Is the email you receive blank or are the spaces where data should be blank?
Do you enforce the filling of required fields via PHP? You can also enforce this via JavaScript (it doesn't seem like you do), but you should always enforce on the backend too! Enforcing the filling of a field is as simple as:

//Init error array
$errors = array();

//Check that fields are filled with valid data
if(!isset($_POST['name'])) {
   $errors[] = '<p>Please enter your name</p>';
}
//etc.
if(count($errors) != 0) {
    echo implode("\n", $errors);
    //Output the form
    exit();
}

//Send the email

@ﻼim: Did I mention how much I love code examples? :P

EDIT On second glance there is an easier way to validate the form in one script. Here is some sample code:

//Init error array
$errors = array();

//Check if form has been submitted
if($_POST['submit_button_name'] == 'Submit Button Value') {
    //Check that fields are filled with valid data
    if(!isset($_POST['name'])) {
       $errors[] = '<p>Please enter your name</p>';
    }
    //etc.
    if(count($errors) != 0) {
        break;
    }

    //Send the email
    //Redirect to thank you
    exit();
}

echo implode("\n", $errors);
//Output the form

Edited by FlashCreations: n/a

0

What do you mean by blank bookings? Is the email you receive blank or are the spaces where data should be blank?
Do you enforce the filling of required fields via PHP? You can also enforce this via JavaScript (it doesn't seem like you do), but you should always enforce on the backend too! Enforcing the filling of a field is as simple as:

//Init error array
$errors = array();

//Check that fields are filled with valid data
if(!isset($_POST['name'])) {
   $errors[] = '<p>Please enter your name</p>';
}
//etc.
if(count($errors) != 0) {
    echo implode("\n", $errors);
    //Output the form
    exit();
}

//Send the email

@ﻼim: Did I mention how much I love code examples? :P

EDIT On second glance there is an easier way to validate the form in one script. Here is some sample code:

//Init error array
$errors = array();

//Check if form has been submitted
if($_POST['submit_button_name'] == 'Submit Button Value') {
    //Check that fields are filled with valid data
    if(!isset($_POST['name'])) {
       $errors[] = '<p>Please enter your name</p>';
    }
    //etc.
    if(count($errors) != 0) {
        break;
    }

    //Send the email
    //Redirect to thank you
    exit();
}

echo implode("\n", $errors);
//Output the form

:D yeah, you're really good at samples- no second thought with that PHP man (former PMC man). Ϋ

Edited by ﻼim: additional words. Ϋ

1

:D yeah, you're really good at samples- no second thought with that PHP man (former PMC man). Ϋ

Never gotten that before, but PHP Man works too. I'll have to make note of that somewhere on the new site! :)

0

Thanks for the replies.

I should have explained that I need for the customer to be able to leave any field on the form blank.

If somebody does submit a blank booking form I would get this string sent through to me '||||||||||||||No|||' - note that the 4th to last field (Taxed) must be set to 'Yes' or 'No' so I should never receive a completely blank order.

Recently however I have received a couple or orders like this '|||||||||||||||||'. As the Taxed field must be either 'Yes' or 'No' these orders should not be possible which proves to me there is some kind of problem occurring during the booking process.

As this has only happened once or twice I am inclined to think the problem is specific to certain computers which is why I am wondering if the solution could be in internet settings?

0

The problem probably doesn't involve the user's internet settings, but you never know. Why not try something like this to process the form:

<?php
//Protect email's reader by sanitizing all data
array_walk($_POST, 'htmlentities');

//Ensure Taxed Field is filled
if($_POST['Taxed'] != 'No' && $_POST['Taxed'] != 'Yes') {
    //Send user back to form asking for taxed field
    //Don't fill the form because it is impossible for a user to not submit
    //An answer to taxed. Only a hacker or exploiter would be able to do this
    header('Location: http://www.n-v-m.co.uk/Booking.html');
    die('No taxed option selected'); //You can change this text if you want
}

//Fields to grab
$fields = array('company', 'name', 'phonenum', 'email', 'vman', 'vreg', 'colladd', 'collconname', 'collconnum', 'deladd', 'delconname', 'delconnum', 'collectiondt', 'deliverydt', 'Taxed', 'billadd', 'custordnum', 'addcom');

//Construct message
$message = '';
for($x = 0; $x < count($fields); $x  ) {
    $message .= $_POST[$fields[$x]];
    if($x != count($fields) - 1) {
        $message .= '|';
    }
}

//Send message and redirect to Thank You Page
mail('info@n-v-m.co.uk', 'Order from '.$_POST['company'].' ('.$_POST['name'].')', $message, "From: NVM Booking Form\r\n");
header('Location: http://www.n-v-m.co.uk/Thankyou.html');
?>

Edited by FlashCreations: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.