• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Why won't this contact form work?

Participant ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Hi All,

Ok so i decided to update the contact form of page below as i was using the out dated spry validation method. I inserted the new contact form using webassist dreamweaver extension but i am now having big problems with this page. I am now unable to even open the page, please use link below to see the page error and i have also pasted the code of this page.

http://www.milesfunerals.com/contact.php

<?php virtual("/webassist/form_validations/wavt_scripts_php.php"); ?>

<?php virtual("/webassist/form_validations/wavt_validatedform_php.php"); ?>

<!DOCTYPE HTML>

<html>

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Miles & Daughters | Contact us by email or phone</title>

<meta name="description" content="Contact us and speak to any of our friendly staff if you have any enquiries or if you would prefer you can contact us by email. You can also see pictures of all five of our branches. ">

<meta name="keywords" content="contact, questions, enquiries, friendly, email, addresses, write, funeral home, branches, reading, wokingham, crowthorne, twyford, bracknell">

<!--[if lt IE 9]>

<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>

<![endif]-->

<link href="/stylesheet.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" href="fancyBox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

<script type="text/javascript" src="fancyBox/source/jquery.fancybox.pack.js?v=2.1.5"></script>

<script type="text/javascript">

$(document).ready(function() {

$('.fancybox').fancybox();

});

</script>

<style type="text/css">

#sprytextfield2{

           form input[type=text] {width: 75%}

textarea {width: 85%}

#sprytextfield1{

           form input[type=text] {width: 75%}

textarea {width: 85%}

</style>

<LINK REL="SHORTCUT ICON" HREF="http://www.milesmemorials.com/favicon.ico">

<script src="/webassist/progress_bar/jquery-blockui-formprocessing.js" type="text/javascript"></script>

<link href="/SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">

<script src="/SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

<script src="/webassist/forms/wa_servervalidation.js" type="text/javascript"></script>

<link href="/webassist/forms/fd_basic_default.css" rel="stylesheet" type="text/css">

</head>

<body>

<div id="container">

<?php include('includes/header.php'); ?>

<?php include('includes/navbar2.php'); ?>

<?php include('includes/navbar.php'); ?>

<?php include('includes/sidebar.php'); ?>

<div id="maindiv" class="maindiv_scroll">

  <p> </p>

  <p> </p>

    <p class="subheading">Miles and Daughters - Contact us</p>

  <p class="sub2">Addresses and telephone numbers for our offices are:</p>

<p class="maintext"> </p>

<p class="wokingham"><span class="address"><a class="fancybox" href="images/Isabella house.jpg" title="Miles & Daughters Winnersh Premises"><img src="images/Isabella house.jpg" alt="Miles & Daughters Wokingham premisesh" width="297" height="263" class="shop"/></a></span> </p>

<p class="wokingham"> </p>

<p class="wokingham">Wokingham</p>

<p class="address">Isabella House  </p>

<p class="address">498a Reading Road</p>

  <p class="address"> Winnersh </p>

  <p class="address">Berkshire</p>

  <p class="address"> RG41 5EX</p>

  <p class="address"> Telephone: 0118 979 3004</p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"><a class="fancybox" href="images/cav-1.jpg" title="Miles & Daughters Reading Premises"><img src="/images/cav-1.jpg" alt="Miles & Daughters Reading premises" width="380" height="321" class="shop"/></a></p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="wokingham">Reading</p>

<p class="address">Tamela House</p>

  <p class="address">157-161 Caversham Road</p>

  <p class="address">Reading</p>

  <p class="address">Berkshire</p>

  <p class="address">RG1 8BB</p>

  <p class="address">Telephone: 0118 959 0022</p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"><a class="fancybox" href="images/Ivydene2.jpg" title="Miles & Daughters Binfield Premises"><img src="images/Ivydene2.jpg" alt="Miles & Daughters Bracknell premises" width="380" height="267" class="shop"/></a></p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham">Bracknell</p>

  <p class="address">Ivydene House</p>

  <p class="address">Forest Road</p>

  <p class="address">Binfield</p>

  <p class="address">Bracknell</p>

  <p class="address">RG42 4HP</p>

  <p class="address">Telephone: 01344 452020  </p>

  <p class="wokingham"><span class="address"><a class="fancybox" href="images/twford.jpg" title="Miles & Daughters Twyford Premises"><img src="images/twford.jpg" alt="Miles & Daughters Twyford premises" width="263" height="317" class="shop"/></a></span></p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

  <p class="wokingham">Twyford</p>

<p class="address">The Old Clock House</p>

  <p class="address">Station Road</p>

  <p class="address"> Twyford</p>

  <p class="address">Berkshire </p>

  <p class="address">RG10 9NS</p>

  <p class="address"> Telephone: 0118 934 5474</p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"><a class="fancybox" href="images/crowthorne.jpg" title="Miles & Daughters Crowthorne Premises"><img src="images/crowthorne.jpg" alt="Miles & Daughters Crowthorne premises" width="362" height="239" class="shop"/></a></p>

  <p class="wokingham"> </p>

  <p class="wokingham"> </p>

    <p class="wokingham">Crowthorne</p>

<p class="address">Alicya House</p>

  <p class="address">105 High Street</p>

  <p class="address"> Crowthorne</p>

  <p class="address">Berkshire </p>

  <p class="address">RG45 7AD</p>

  <p class="address"> Telephone: 01344 774932</p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="address"> </p>

  <p class="endtext"> </p>

  <p class="endtext"> </p>

  <p class="maintext">You may email us or alternatively use the form below to contact us, one of our members of staff will respond as soon as possible.  </p>

  <p> </p>

  <div id="SimpleContact_Basic_Default_ProgressWrapper">

    <form class="Basic_Default" id="SimpleContact_Basic_Default" name="SimpleContact_Basic_Default" method="post" action="form-to-email.php">

      <!--

WebAssist CSS Form Builder - Form v1

CC: Contact

CP: Simple Contact

TC: Basic

TP: Default

-->

      <ul class="Basic_Default">

        <li>

          <fieldset class="Basic_Default" id="Contact_me">

            <legend class="groupHeader">Contact</legend>

            <ul class="formList">

              <li class="formItem"> <span class="fieldsetDescription"> Required * </span> </li>

              <li class="formItem">

                <div class="formGroup">

                  <div class="lineGroup">

                    <div class="fullColumnGroup">

                      <label for="Full_Name" class="sublabel" > Name:<span class="requiredIndicator"> *</span></label>

                      <div class="errorGroup">

                        <div class="fieldPair">

                          <div class="fieldGroup"> <span id="Full_Name_Spry"> <span>

                            <input id="Full_Name" name="Full_Name" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("formtoemail","Full_Name"):"")); ?>" class="formTextfield_Large" tabindex="1" onBlur="hideServerError('Full_Name_ServerError');">

                            <span class="textfieldRequiredMsg">Please enter your name</span> </span> </span>

                            <?php

if (ValidatedField('formtoemail','formtoemail'))  {

  if ((strpos((",".ValidatedField("formtoemail","formtoemail").","), "," . "1" . ",") !== false || "1" == ""))  {

    if (!(false))  {

?>

                              <span class="serverInvalidState" id="Full_Name_ServerError">Please enter your name</span>

                              <?php //WAFV_Conditional form-to-email.php formtoemail(1:)

    }

  }

}?>

                          </div>

                        </div>

                      </div>

                    </div>

                  </div>

                  <div class="lineGroup">

                    <div class="fullColumnGroup">

                      <label for="Email_Address" class="sublabel" > Email:<span class="requiredIndicator"> *</span></label>

                      <div class="errorGroup">

                        <div class="fieldPair">

                          <div class="fieldGroup"> <span id="Email_Address_Spry"> <span>

                            <input id="Email_Address" name="Email_Address" type="text" value="<?php echo((isset($_GET["invalid"])?ValidatedField("formtoemail","Email_Address"):"")); ?>" class="formTextfield_Large" tabindex="2" onBlur="hideServerError('Email_Address_ServerError');">

                            <span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldRequiredMsg">Please enter a full email address</span> </span> </span>

                            <?php

if (ValidatedField('formtoemail','formtoemail'))  {

  if ((strpos((",".ValidatedField("formtoemail","formtoemail").","), "," . "2" . ",") !== false || "2" == ""))  {

    if (!(false))  {

?>

                              <span class="serverInvalidState" id="Email_Address_ServerError">Please enter a full email address</span>

                              <?php //WAFV_Conditional form-to-email.php formtoemail(2:)

    }

  }

}?>

                          </div>

                        </div>

                      </div>

                    </div>

                  </div>

                  <div class="lineGroup">

                    <div class="fullColumnGroup">

                      <label for="Comments" class="sublabel" > Comments:</label>

                      <div class="errorGroup">

                        <div class="fieldPair">

                          <div class="fieldGroup"> <span>

                            <textarea name="Comments" id="Comments" class="formTextarea_Medium" rows="1" cols="1" tabindex="3"><?php echo((isset($_GET["invalid"])?ValidatedField("formtoemail","Comments"):"")); ?></textarea>

                          </span> </div>

                        </div>

                      </div>

                    </div>

                  </div>

                </div>

              </li>

              <li class="formItem">

                <div class="formGroup">

                  <div class="lineGroup">

                    <div class="fullColumnGroup">

                      <div class="fullColumnGroup">

                        <label for="Security_Code" class="sublabel" > </label>

                        <div class="errorGroup">

                          <div class="fieldPair">

                            <div class="fieldGroup"> <span> <img src="/webassist/captcha/wavt_captchasecurityimages.php?field=Security_Code&noisefreq=15&noisecolor=060606&gridcolor=080808&font=fonts/MOM_T___.TTF&textcolor=040404" alt="Security Code" class="Captcha"> </span> </div>

                          </div>

                        </div>

                      </div>

                      <div class="fullColumnGroup" style="clear:left;">

                        <label for="Security_Code" class="sublabel" > Security code:<span class="requiredIndicator"> *</span></label>

                        <div class="errorGroup">

                          <div class="fieldPair">

                            <div class="fieldGroup"> <span id="Security_Code_Spry"> <span>

                              <input id="Security_Code" name="Security_Code" type="text" value="" class="formTextfield_Large" tabindex="4" onBlur="hideServerError('Security_Code_ServerError');">

                              <span class="textfieldRequiredMsg">Entered text does not match; please try again</span> </span> </span>

                              <?php

if (ValidatedField('formtoemail','formtoemail'))  {

  if ((strpos((",".ValidatedField("formtoemail","formtoemail").","), "," . "3" . ",") !== false || "3" == ""))  {

    if (!(false))  {

?>

                                <span class="serverInvalidState" id="Security_Code_ServerError">Entered text does not match; please try again</span>

                                <?php //WAFV_Conditional form-to-email.php formtoemail(3:)

    }

  }

}?>

                            </div>

                          </div>

                        </div>

                      </div>

                    </div>

                  </div>

                  <div class="lineGroup">

                    <div class="fullColumnGroup">

                      <div class="fullColumnGroup">

                        <label for="Security_Answer_2" class="sublabel" > </label>

                        <div class="errorGroup">

                          <div class="fieldPair">

                            <div class="fieldGroup"> <span> <span class="precedingText">

                              <?php virtual("/webassist/captcha/wavt_captchasecurityquestion.php"); ?>

                            </span> </span> </div>

                          </div>

                        </div>

                      </div>

                      <div class="fullColumnGroup" style="clear:left;">

                        <label for="Security_Answer" class="sublabel" > Answer:<span class="requiredIndicator"> *</span></label>

                        <div class="errorGroup">

                          <div class="fieldPair">

                            <div class="fieldGroup"> <span id="Security_Answer_Spry"> <span>

                              <input id="Security_Answer" name="Security_Answer" type="text" value="" class="formTextfield_Large" tabindex="5" onBlur="hideServerError('Security_Answer_ServerError');">

                              <span class="textfieldRequiredMsg">Incorrect

                                response; please try again</span> </span> </span>

                              <?php

if (ValidatedField('formtoemail','formtoemail'))  {

  if ((strpos((",".ValidatedField("formtoemail","formtoemail").","), "," . "4" . ",") !== false || "4" == ""))  {

    if (!(false))  {

?>

                                <span class="serverInvalidState" id="Security_Answer_ServerError">Incorrect

                                  response; please try again</span>

                                <?php //WAFV_Conditional form-to-email.php formtoemail(4:)

    }

  }

}?>

                            </div>

                          </div>

                        </div>

                      </div>

                    </div>

                  </div>

                </div>

              </li>

              <li class="formItem"> <span class="buttonFieldGroup" >

                <input id="Hidden_Field" name="Hidden_Field" type="hidden" value="<?php echo((isset($_GET["invalid"])?ValidatedField("formtoemail","Hidden_Field"):"")); ?>">

                <input class="formButton" name="SimpleContact_submit" type="submit" id="SimpleContact_submit" value="Contact me"  onClick="clearAllServerErrors('SimpleContact_Basic_Default')">

              </span> </li>

            </ul>

          </fieldset>

        </li>

      </ul>

    </form>

  </div>

  <div id="SimpleContact_Basic_Default_ProgressMessageWrapper" class="blockUIOverlay" style="display:none;">

    <script type="text/javascript">

WADFP_SetProgressToForm('SimpleContact_Basic_Default', 'SimpleContact_Basic_Default_ProgressMessageWrapper', WADFP_Theme_Options['BigSpin:Slate']);

    </script>

    <div id="SimpleContact_Basic_Default_ProgressMessage" >

      <p style="margin:10px; padding:5px;" ><img src="/webassist/progress_bar/images/slate-largespin.gif" alt="" title="" style="vertical-align:middle;" />  Please wait</p>

    </div>

  </div>

  <p class="maintext"> </p>

</div>

<?php include('includes/footer.php'); ?>

</div>

<script type="text/javascript">

var Full_Name_Spry = new Spry.Widget.ValidationTextField("Full_Name_Spry", "none",{validateOn:["blur"]});

var Email_Address_Spry = new Spry.Widget.ValidationTextField("Email_Address_Spry", "email",{validateOn:["blur"]});

var Security_Code_Spry = new Spry.Widget.ValidationTextField("Security_Code_Spry", "none",{validateOn:["blur"]});

var Security_Answer_Spry = new Spry.Widget.ValidationTextField("Security_Answer_Spry", "none",{validateOn:["blur"]});</script>

</body>

</html>

Views

25.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 31, 2013 Dec 31, 2013

Ness_quick wrote:

No it doesnt this is what i have for it on the php page -

  $WAFV_Errors .= WAValidateRX((isset($_POST["Hidden_Field"])?$_POST["Hidden_Field"]:"" ) . "","/.* /",false,5);

  if ($WAFV_Errors != "")  {

    PostResult($WAFV_Redirect,$WAFV_Errors,"formtoemail");

  }

}

Not sure what that does to be honest.

Seems to me all you really need is to make sure the form is not submitted by a spam bot.

The form seems to work up until the point of the spam security validation.

You could try adding an a

...

Votes

Translate

Translate
LEGEND ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

I suspect the problem is caused by these two lines:

<?php virtual("/webassist/form_validations/wavt_scripts_php.php"); ?>

<?php virtual("/webassist/form_validations/wavt_validatedform_php.php"); ?>

They use the PHP virtual() function to include external files using a site-root relative link. The virtual() function works only on Apache, and it's extremely flaky. Use require() with a document-relative link instead.

Assuming that the webassist folder is at the top level of your site, this should do it:

<?php require("webassist/form_validations/wavt_scripts_php.php"); ?>

<?php require("webassist/form_validations/wavt_validatedform_php.php"); ?>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Ok, that has now allowed page to open but there is now another error on line 250? Also the footer doesn't seem to appear?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Not to worry i found what the problem was.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Well, if you read the error message, the problem should become clear. Looking at the code you have posted here, you have this:

<?php virtual("/webassist/captcha/wavt_captchasecurityquestion.php"); ?>

Judging from the error message, you have changed virtual to require on that line, but you still have a site-root-relative link to the captcha page. Remove the forward slash at the beginning of the path (before webassist).

The reason the footer doesn't appear is because PHP throws a fatal error when it can't find a page included with require.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Ok thank you, it all seems to be working properly on that page now except im having problems with my form-to-email.php page. The email i receive when the form has been submitted doesnt show all of the the entered data, name or comments? Code for this page is below.

<?php require("webassist/form_validations/wavt_scripts_php.php"); ?>

<?php require("webassist/form_validations/wavt_validatedform_php.php"); ?>

<?php

if (isset($_POST["SimpleContact_submit"]) && !isset($_GET["invalid"]))  {

  $WAFV_Redirect = "contact.php";

  $_SESSION['WAVT_formtoemail_Errors'] = "";

  if ($WAFV_Redirect == "")  {

    $WAFV_Redirect = $_SERVER["PHP_SELF"];

  }

  $WAFV_Errors = "";

  $WAFV_Errors .= WAValidateRQ((isset($_POST["Full_Name"])?$_POST["Full_Name"]:"") . "",true,1);

  $WAFV_Errors .= WAValidateEM((isset($_POST["Email_Address"])?$_POST["Email_Address"]:"") . "",true,2);

  $WAFV_Errors .= WAValidateLE((strtolower(isset($_POST["Security_Code"])?$_POST["Security_Code"]:"")) . "",((isset($_SESSION["captcha_Security_Code"]))?strtolower($_SESSION["captcha_Security_Code"]):"") . "",true,3);

  $WAFV_Errors .= WAValidateLE((strtolower(isset($_POST["Security_Answer"])?$_POST["Security_Answer"]:"")) . "",((isset($_SESSION["random_answer"]))?strtolower($_SESSION["random_answer"]):"") . "",true,4);

  $WAFV_Errors .= WAValidateRX((isset($_POST["Hidden_Field"])?$_POST["Hidden_Field"]:"") . "","/.* /",false,5);

  if ($WAFV_Errors != "")  {

    PostResult($WAFV_Redirect,$WAFV_Errors,"formtoemail");

  }

}

?>

<?php

$email_from = "$Email_Address \r\n";//<== update the email address

$email_subject = "Message from M&D website contact form";

$email_body = "Visitors name: $Full_Name.\n".

     "Message:\n $Comments".

   

$to = "Ness_Rob@yahoo.com";//<== update the email address

$headers = 'From: '.$Email_Address."\r\n";

$headers .='Reply-To:'.$Email_Address."\r\n";

//Send the email!

mail($to,$email_subject,$email_body,$headers);

//done. redirect to thank-you page.

header('Location: thankyou.php');

  

?>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Judging from the code you have posted here, you're trying to send an email using a script that's more than 10 years out of date. Back in the bad, old days of PHP register_globals, you could get the value from a form just by prefixing the field name with a dollar sign. You now need to use $_POST['fieldname'] if the form was submitted by the POST method.

You're also using an extremely insecure technique by injecting the user's email directly into the email headers. See the following article that explains the problem and the solution: http://foundationphp.com/tutorials/email.php.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Ok so i've taken a huge leap into the 21st century! This is what i now currently have for my form-to-email script but im still having a few problems. The page tries to submit but seems to get lost and i don't receive an email from the form?

<?php require("webassist/form_validations/wavt_scripts_php.php"); ?>

<?php require("webassist/form_validations/wavt_validatedform_php.php"); ?>

<?php

if (isset($_POST["SimpleContact_submit"]) && !isset($_GET["invalid"]))  {

  $WAFV_Redirect = "contact.php";

  $_SESSION['WAVT_formtoemail_Errors'] = "";

  if ($WAFV_Redirect == "")  {

    $WAFV_Redirect = $_SERVER["PHP_SELF"];

  }

  $WAFV_Errors = "";

  $WAFV_Errors .= WAValidateRQ((isset($_POST["Full_Name"])?$_POST["Full_Name"]:"") . "",true,1);

  $WAFV_Errors .= WAValidateEM((isset($_POST["Email_Address"])?$_POST["Email_Address"]:"") . "",true,2);

  $WAFV_Errors .= WAValidateLE((strtolower(isset($_POST["Security_Code"])?$_POST["Security_Code"]:"")) . "",((isset($_SESSION["captcha_Security_Code"]))?strtolower($_SESSION["captcha_Security_Code"]):"") . "",true,3);

  $WAFV_Errors .= WAValidateLE((strtolower(isset($_POST["Security_Answer"])?$_POST["Security_Answer"]:"")) . "",((isset($_SESSION["random_answer"]))?strtolower($_SESSION["random_answer"]):"") . "",true,4);

  $WAFV_Errors .= WAValidateRX((isset($_POST["Hidden_Field"])?$_POST["Hidden_Field"]:"") . "","/.* /",false,5);

  if ($WAFV_Errors != "")  {

    PostResult($WAFV_Redirect,$WAFV_Errors,"formtoemail");

  }

}

?>

<?php

if (isset($_POST['submit'])) {

    // validate the email address first

    $email = filter_input(INPUT_POST, 'Email_Address', FILTER_VALIDATE_EMAIL);

    // process the form only if the email is valid

    if ($Email_Address) {

        $to = 'ness_rob@yahoo.com'; // where you want to send the mail

        $from = 'milesfunerals.com'; // a valid address on your domain

        $subject = 'Message from M&D contact form';

        $message = 'From: ' . $_POST['Full_Name'] . "\r\n\r\n";

        $message .= 'Comments: ' . $_POST['Comments'];

        $headers = "From: $from\r\nReply-to: $Email_Address";

        $sent = mail($to, $subject, $message, $headers);

        if ($sent) {

            $result = 'Location: thankyou.php';

        }

    } else {

        $result = 'Sorry, there was a problem.';

    }

}

?>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 30, 2013 Dec 30, 2013

Copy link to clipboard

Copied

Might want to have a look at this form below. It's similar to yours but no styling - you'd need to use some css to style it up a bit. It's just the raw html/php coding. The form action="form_send.php" - basically save the code to a Dreamweaver document named form_send.php and send the information back to the page to be processed.

<?php

$number_1 = rand(1, 9);

$number_2 = rand(1, 9);

$answer = md5($number_1+$number_2);

if(isset($_POST['submit'])) {

// get the name from the form 'name' field

$name = trim($_POST['name']);

if (empty($name)) {

$error['name'] = "<span>Please provide your name</span>";

}                                                                               

// get the email from the form 'email' field

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

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {

$error['email'] = "<span>Please provide a valid email address</span>";

}

// get the comments from the form 'comments' field 

$comments = trim($_POST['comments']);   

if (empty($comments)) {

$error['comments'] = "<span>Please provide your comments</span>";

}

// security against spam   

$user_answer = trim(htmlspecialchars($_POST['user_answer']));

$answer = trim(htmlspecialchars($_POST['answer']));

if (md5($user_answer) != $answer) {

    $error['answer'] = "<span>Wrong answer - please try again</span>";

}

// if no errors send the form   

if (!isset($error) && md5($user_answer) == $answer) {

$to = 'info@xxxxxxxxxxxxxxxxxxx.co.uk'; // send to recipient

$from = 'mailserver@yourDomain.com'; // from your domain

$subject = 'Response from website';

$message = "From: $name\r\n\r\n";

$message .= "Email: $email\r\n\r\n";

$message .= "Comments: $comments";

$headers = "From: $from\r\nReply-to: $email";

$sent = mail($to, $subject, $message, $headers);

echo 'Your message has been sent.';

}

else {

$number_1 = rand(1, 9);

$number_2 = rand(1, 9);

$answer = md5($number_1+$number_2);

}

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Untitled Document</title>

<style>

#contactForm span {

    color: #900;

}

</style>

</head>

<body>

<form name="contactForm" id="contactForm" method="post" action="form_send.php">

<p><label for="name">Name<input type="text" name="name" id="name" value="<?php if(isset($name)) {echo $name; } ?>" <?php if(isset($error['name'])) {echo 'style="background-color: #FCC;"'; } ?>></label><br>

<?php if(isset($error['name'])) {echo $error['name']; } ?></p>

<p><label for="email">Email<input type="text" name="email" id="email" value="<?php if(isset($email)) {echo $email; } ?>" <?php if(isset($error['email'])) {echo 'style="background-color: #FCC;"'; } ?>></label><br>

<?php if(isset($error['email'])) {echo $error['email']; } ?></p>

<p><label for="comments">Comments<textarea name="comments" id="comments" <?php if(isset($error['comments'])) {echo 'style="background-color: #FCC;"'; } ?>>

<?php if(isset($comments)) { echo $comments; } ?></textarea></label><br>

<?php if(isset($error['comments'])) {echo $error['comments']; } ?></p>

<p>Spam prevention - please answer the question below:</p>

<p><?php echo $number_1; ?> + <?php echo $number_2; ?> = ?<input type="text" name="user_answer" <?php if(isset($error['answer'])) {echo 'style="background-color: #FCC;"'; } ?>/>

<input type="hidden" name="answer" value="<?php echo $answer; ?>" /><br>

<?php if(isset($error['answer'])) {echo $error['answer']; } ?></p>

<p><input type="submit" name="submit" id="sumbit"></p>

</form>

</body>

</html>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Great thank you. I think i have sorted it though. Its submitting and im receiving the email with all the correct information.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Ness_quick wrote:

Great thank you. I think i have sorted it though. Its submitting and im receiving the email with all the correct information.

Humm.... doesn't seem to be working as one would expect on the url provided?

http://www.milesfunerals.com/contact.php

Maybe you're testing another version of the form?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Thats strange its working fine for me. Which part of the form isn't working for you? Maybe try refreshing the page, see if that helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Ness_quick wrote:

Thats strange its working fine for me. Which part of the form isn't working for you? Maybe try refreshing the page, see if that helps.

I can put what I want in the security code and the answer fields and the form still 'appears' to send the information through.

If it isnt sending the information then its confusing to the user because they get no message to say the form has failed - they just get taken back to the form page where all the boxes are blank and have to start over again. 

In that senario you should at least 'preserve' the information that they have previously filled in for the 'name' , 'email' and 'comments' fields so they don't have to fill them in again.

At the moment the form from a users perspective is not clearly indicating what is happening or what has happened.

I'm assuming when the form field turns green that indicates the field has been validated correctly - try inserting anything in the 2 security boxes and see what happens.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

How strange, i tried it several times last night and it was all working fine. I just tried submitting another form just now as you alerted me to this issue and found i had the same problem which you just described. I have also been experiencing problems when trying to check my emails of the email address which this form is set up to. So i changed the email location to a different email address on my form-to-email.php page and now all works as it should again. If you try it again you'll see, it should now all make sense to the user?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Form is still submitting when I type any old garble into the spam security fields.

The form is possibliy not picking up one of the js validation files as these two lines should not appear when you first go to the form:

Entered text does not match; please try again

Incorrect response; please try again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Oh yes i see. The validation is working for the email address but not on the security section. Although i does flag up red if nothing is entered. All the validation pages are linked up ok so it must be that there is some code missing somewhere

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Ness_quick wrote:

Oh yes i see. The validation is working for the email address but not on the security section. Although i does flag up red if nothing is entered. All the validation pages are linked up ok so it must be that there is some code missing somewhere

Halve the problem.......you don't need 2 spam validation fields.

Or make it simpler. Personally I use a hidden form field which if a spam bot fills in as they do the form won't send.

captcha is rather overdoing it in my opinion although at least with yours it is just about readable but not for those who have trouble with contrast.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

I used the webassist form builder for the first time but like you say its all a bit overkill for a simple contact form and yet this is the basic, most simple form they use. I have found out why the validation isn't working on the security questions.... I was supposed to set up a server validation. Again its all getting very complicated for a simple contact form.

If i keep the spry functions so that they turn green etc and i remove all the php script within the form, how do i then apply the hidden form field?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

I have just noticed that there is already a hidden form field (see below) will this not do the same thing?

<input id="Hidden_Field" name="Hidden_Field" type="hidden" value="<?php echo((isset($_GET["invalid"])?ValidatedField("formtoemail","Hidden_Field"):"")); ?>">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Ness_quick wrote:

I have just noticed that there is already a hidden form field (see below) will this not do the same thing?

<input id="Hidden_Field" name="Hidden_Field" type="hidden" value="<?php echo((isset($_GET["invalid"])?ValidatedField("formtoemail","Hidden_Fi eld"):"")); ?>">

Could be :

Does the php file form-to-email.php reference it by trying to get a value from it?

$variable = $_POST['Hidden_Field'];

if(!empty($variable)) {

DO something - like terminate the form being sent.

}

To test you can make the hidden field visible. Type something in it and send the form. If you don't get a response it's worked - if you do then the hidden form field is for some other reason.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

No it doesnt this is what i have for it on the php page -

  $WAFV_Errors .= WAValidateRX((isset($_POST["Hidden_Field"])?$_POST["Hidden_Field"]:"") . "","/.* /",false,5);

  if ($WAFV_Errors != "")  {

    PostResult($WAFV_Redirect,$WAFV_Errors,"formtoemail");

  }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Ness_quick wrote:

No it doesnt this is what i have for it on the php page -

  $WAFV_Errors .= WAValidateRX((isset($_POST["Hidden_Field"])?$_POST["Hidden_Field"]:"" ) . "","/.* /",false,5);

  if ($WAFV_Errors != "")  {

    PostResult($WAFV_Redirect,$WAFV_Errors,"formtoemail");

  }

}

Not sure what that does to be honest.

Seems to me all you really need is to make sure the form is not submitted by a spam bot.

The form seems to work up until the point of the spam security validation.

You could try adding an additional hidden form field after the current hidden form field:

<input type="hidden" name="antiSpam">

Then insert the below at the beginning of your form-to-email.php file after the opening <?php tag. If a spam bot populates the field then the 'exit;' php command should terminate the php file processing any further and the information never gets sent to the recipients email address - job done.

// check antiSpam form field

$antiSpam = trim($_POST['antiSpam']);

if (!empty($antiSpam)) {

    exit;

}

As said in my last post you can test by temporary making the hidden field a normal <input type="text" form field.

If this works then you can get rid of the captcha

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 31, 2013 Dec 31, 2013

Copy link to clipboard

Copied

Ok so it seems that if i enter anything into the the hidden field the page wont submit, it just sends you back to the page again. Also the captcha validation works, if i enter the wrong code the page reloads flagging up in red that the wrong code was entered. Anyway i can now remove the captcha.

Thank you! Happy New Year!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 01, 2014 Jan 01, 2014

Copy link to clipboard

Copied

LATEST

Ness_quick wrote:

Thank you! Happy New Year!

Happy New Year.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines