Skip navigation
Currently Being Moderated

Why won't this form submit?

Jan 22, 2013 8:16 AM

Why won't the form on this page submit?

 

www.milesmemorials.com/contact.html

 

Php for this form is-

 

<?php

 

 

$name = $_POST['name'];

$visitor_email = $_POST['email'];

$message = $_POST['message'];

 

 

//Validate first

if(empty($name)||empty($visitor_email))

{

    echo "Name and email are mandatory!";

    exit;

}

 

 

if(IsInjected($visitor_email))

{

    echo "Bad email value!";

    exit;

}

 

 

$email_from = "milesmemorials.com";//<== update the email address

$email_subject = "Message from Miles Memorial contact form";

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

     "Message:\n $message".

   

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

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

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

//Send the email!

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

//done. redirect to thank-you page.

header('Location: thankyou.html');

 

 

 

 

// Function to validate against any email injection attempts

function IsInjected($str)

{

  $injections = array('(\n+)',

              '(\r+)',

              '(\t+)',

              '(%0A+)',

              '(%0D+)',

              '(%08+)',

              '(%09+)'

              );

  $inject = join('|', $injections);

  $inject = "/$inject/i";

  if(preg_match($inject,$str))

    {

    return true;

  }

  else

    {

    return false;

  }

}

  

?>


 


 
Replies
  • Currently Being Moderated
    Jan 22, 2013 8:22 AM   in reply to Ness_quick

    Is it not submitting?  Or is it not redirecting?

     

    ^_^

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 22, 2013 8:24 AM   in reply to Ness_quick

    Are you using a web host, or your own server? 

     

    try changing:

     

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

     

    to this:

     

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

     

    Just to see your result.  You should have a "from" already defined in your .cfg file.  I realize you want to set your own "from" which is possbile, but try this change just to see if your mail function works without the headers first.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 22, 2013 8:33 AM   in reply to Ness_quick

    I've had problems with empty().  Instead, trim the value and check for length.

     

    ^_^

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 22, 2013 9:41 AM   in reply to Ness_quick

    >I do apologise if i seem slow, i am still very new to dreamweaver

     

    Just to be clear, this is not an issue with learning dreamweaver. This is just a lack of understanding of HTML and PHP. You need to learn those first before trying to learn DW.

     

    You have a form field named 'donorName' but are checking for a field named 'name'.

     

    $name = $_POST['name'];

     

    <input name="donerName" type="text"

     

    You need to rename one or the other.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points