Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter

    Hello All, Please can I get some much needed help please, thank you in advance!

    am using a free website form script, however it can be sent with out any fields being filled in.

    The question I have is:

    How can it be changed (simply as I am am useless with computers) so that it will not send with fields (all or some of them) being filled in?

    Again, thank you in advance for any help.

    The script I am using is below, thank you



    Thank you for choosing FormToEmail by FormToEmail.com

    Version 2.4 June 21st 2008

    COPYRIGHT FormToEmail.com 2003 - 2008

    You are not permitted to sell this script, but you can use it, copy it or distribute it, providing that you do not delete this copyright notice, and you do not remove any reference or links to FormToEmail.com

    For support, please visit: http://formtoemail.com/support/

    You can get the Pro version of this script here: http://formtoemail.com/formtoemail_pro_version.php

    FormToEmail-Pro (Pro version) Features:

    Check for required fields.
    Attach file uploads.
    Upload files to the server.
    reCAPTCHA support.
    Check for a set cookie.
    HTML output option.
    CSV output to attachment or file.
    Autoresponder (with file attachment).
    Show sender's IP address.
    Block IP addresses.
    Block web addresses or rude words.
    Block gibberish (MldMtrPAgZq etc).
    Block gobbledegook characters (Å ð ç etc).
    Set encoding (utf-8 etc).
    Ignore fields.
    Sort fields.
    Auto redirect to "Thank You" page.
    No branding.
    Free upgrades for life.



    FormToEmail is a contact-form processing script written in PHP. It allows you to place a form on your website which your visitors can fill out and send to you. The contents of the form are sent to the email address (or addresses) which you specify below. The form allows your visitors to enter their name, email address and comments. The script will not allow a blank form to be sent.

    Your visitors (and nasty spambots!) cannot see your email address. The script cannot be hijacked by spammers.

    When the form is sent, your visitor will get a confirmation of this on the screen, and will be given a link to continue to your homepage, or other page if you specify it.

    Should you need the facility, you can add additional fields to your form, which this script will also process without making any additional changes to the script. You can also use it to process other forms. The script will handle the "POST" or "GET" methods. It will also handle multiple select inputs and multiple check box inputs. If using these, you must name the field as an array using square brackets, like so: <select name="fruit[]" multiple>. The same goes for check boxes if you are using more than one with the same name, like so: <input type="checkbox" name="fruit[]" value="apple">Apple<input type="checkbox" name="fruit[]" value="orange">Orange<input type="checkbox" name="fruit[]" value="banana">Banana

    ** PLEASE NOTE ** If you are using the script to process your own forms (or older FormToEmail forms) you must ensure that the email field is named correctly in your form, thus: <input type="text" name="email" etc>. Note the lower case "email". If you don't do this, you won't be able to see who the email is from and the script won't be able to check the validity of the email. If you are using the form code below, you don't need to check for this.

    This is a PHP script. In order for it to run, you must have PHP (version 4.1.0 or later) on your webhosting account, and have the PHP mail() function enabled and working. If you are not sure about this, please ask your webhost about it.


    Step 1: Put the form on your webpage
    Step 2: Enter your email address and (optional) continue link below
    Step 3: Upload the files to your webspace

    Step 1:

    To put the form on your webpage, copy the code below as it is, and paste it into your webpage:

    <form action="1FormToEmail.php" method="post">
    <table border="0" bgcolor="" cellspacing="7">
    <font face=" Arial" size="3">first aid training</font><p>
    <font face=" Arial" size="2">&nbsp;</font><p>
    <tr><td><font face=" Arial" size="2">your full name (course organiser)</td><td><input type="text" size="35" name="name"if(empty($field) {Print($field." must be filled in please go back and fillin your name")};></td></tr>
    <tr><td><font face=" Arial" size="2">Contact email address:</td><td><input type="text" size="35" name="CONTACT EMAIL ADDRESS:-"></td></tr>
    <tr><td><font face=" Arial" size="2">Contact phone number(s):</td><td><input type="Calibri" size="35" name="CONTACT PHONE NUMBER(S):-"></td></tr>

    <tr><td><font face=" Arial" size="2">The course I am booking is:-</td><td><select name="THE COURSE I AM BOOKING IS:-"></font>
    <option value="First Aid at Work">First Aid at Work</option>
    <option value="Emergency First Aid at Work">Emergency First Aid at Work</option>
    <option value="FIRST AID AT WORK REQUALIFICATION">First Aid at Work Requalification</option>
    <option value="BASIC SKILLS REFRESHER TRAINING">Basic Skills Refresher Training</option>

    <option value="OTHER (PLEASE SPECIFY BELOW">Other (please specify below)</option>

    <tr><td><font face=" Arial" size="2">Number of additional certificates:</td><td><input type="Calibri" size="35" name="NUMBER OF ADDITIONAL CERTIFICATES:-"></td></tr>
    <tr><td><font face=" Arial" size="2">one:</td><td><input type="Calibri" size="35" name="1:-"></td></tr>
    <tr><td><font face=" Arial" size="2">two:</td><td><input type="Calibri" size="35" name="2:-"></td></tr>
    <tr><td><font face=" Arial" size="2">three:</td><td><input type="Calibri" size="35" value="£" name="3"></td></tr>

    <tr><td valign="top"><font face=" Arial" size="2">Any additional comments and questions:</td><td><textarea name="ANY ADDITIONAL COMMENTS AND QUESTIONS:-" rows="5" cols="50"></textarea></td></tr>
    <tr><td><font face=" Arial" size="2">How did you hear about us:</td><td><input type="Calibri" size="35" name="HOW DID YOU HEAR ABOUT US:-"></td></tr>
    <tr><td valign="top"><font face=" Arial" size="2">Please tick each box to confirm that:</td><td><input name="1/1 - PLEASE TICK EACH BOX TO CONFIRM THAT:-" type="checkbox" value="*you have read and accept our Terms and Conditions">&nbsp;<font face=" Arial" size="2">*you have read and accept our Terms and Conditions

    <tr><td></td><td><input type="submit" value="SEND BOOKING FORM"></td></tr>
    </table><font face=" Arial" size="2">Your form has been sent</font><p>
    </table><font face=" Arial" size="2"></font><p>

    </table><font face=" Arial" size="2">Thank you><p>

    Step 2:

    Enter your email address.

    Enter the email address below to send the contents of the form to. You can enter more than one email address separated by commas, like so: $my_email = "[email protected]"; or $my_email = "[email protected],[email protected] o.uk,[email protected]";


    $my_email = "emailaddress";


    Enter the continue link to offer the user after the form is sent. If you do not change this, your visitor will be given a continue link to your homepage.

    If you do change it, remove the "/" symbol below and replace with the name of the page to link to, eg: "mypage.htm" or "http://www.elsewhere.com/page.htm"


    $continue = "websiteaddress";


    Step 3:

    Save this file (FormToEmail.php) and upload it together with your webpage containing the form to your webspace. IMPORTANT - The file name is case sensitive! You must save it exactly as it is named above!


    You do not need to make any changes below this line.


    $errors = array();

    // Remove $_COOKIE elements from $_REQUEST.

    if(count($_COOKIE)){foreach(arra y_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}

    // Validate email field.

    if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))

    $_REQUEST['email'] = trim($_REQUEST['email']);

    if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($ exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domai n)){$errors[] = "Email address is invalid";}else{foreach($exploded _domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}


    // Check referrer is from same site.

    if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}

    // Check for a blank form.

    function recursive_array_check_blank($ele ment_value)

    global $set;

    if(!is_array($element_value)){if (!empty($element_value)){$set = 1;}}

    foreach($element_value as $value){if($set){break;} recursive_array_check_blank($val ue);}



    recursive_array_check_blank($_RE QUEST);

    if(!$set){$errors[] = "You cannot send a blank form";}


    // Display any errors and exit if errors exist.

    if(count($errors)){foreach($erro rs as $value){print "$value<br>";} exit;}

    if(!defined("PHP_EOL")){define(" PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}

    // Build message.

    function build_message($request_input){if (!isset($message_output)){$messa ge_output ="";}if(!is_array($request_input )){$message_output = $request_input;}else{foreach($re quest_input as $key => $value){if(!empty($value)){if(!i s_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL. PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}

    $message = build_message($_REQUEST);

    $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";

    $message = stripslashes($message);

    $subject = "enquiry";

    $subject = stripslashes($subject);

    $from_name = "";

    if(isset($_REQUEST['name']) && !empty($_REQUEST['name'])){$from_name = stripslashes($_REQUEST['name']);}

    $headers = "From: {$from_name} <{$_REQUEST['email']}>";

    mail($my_email,$subject,$message ,$headers);


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


    <title>Form To Email PHP script from FormToEmail.com</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <body bgcolor="#ffffff" text="#000000">

    <b>Thank you <?php if(isset($_REQUEST['name'])){print stripslashes($_REQUEST['name']);} ?></b>
    <br>we will be in contact
    <p><a href="<?php print $continue; ?>">Click here to continue</a></p>
    <p><b></b> <a href="</a></p>


    Maybe insert a spoiler around that code so this page isn't so long?

    Anyway, if you don't want the form to be submitted without all of the fields being filled, you want to do this client-side (PHP is server-side) using something like Javascript - which I recommend as it's extremely easy to check something like this and there will be plenty of tutorials online already for it.

    Below is a bit of Javascript from one of my websites doing just this. I'll comment it so you can amend it to your needs

    <script type="text/javascript">
    function validateForm()
            // Create a variable containing the value of the field named "username" from the html form named "register"
    	var username=document.forms["register"]["username"].value;
    	var password1=document.forms["register"]["password1"].value;
    	var password2=document.forms["register"]["password2"].value;
    	if (username==null || username=="") {
      		alert("The name field can't be empty");
      		return false;
    	else if (password1==null || password1=="") {
     		alert("The first password field can't be empty");
      		return false;
    	 else if (password2==null || password2=="") {
     		alert("The second password field can't be empty");
      		return false;
    	else if (password1 != password2) {
     		alert("The passwords don't match");
      		return false;
    Here's the bit of html that goes along with this script (I haven't included all of it)
    <form name=register onsubmit="return validateForm()" action="scripts/registerscript.php" method="post">
    		<td style="padding:0px;"><input type="text" name="username"></td>
    		<td style="padding:0px;"><input type="password" name="password1"></td>

    I hope that your form issue has finally been resolved.

    If this isn't the case, I can help you out on this.


    PM me with your email address and what you want the form to do and I will code you something in PHP to do the trick

Submit reply
TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Updated: May 25, 2013
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Would you like to hibernate through the winter months?
    Useful resources
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.