- - - - -

Ajax Form: not forwarding to inbox


  • Please log in to reply
4 replies to this topic

#1 jbrown

jbrown

    Tiny Orange

  • Members
  • Pip
  • 7 posts

Posted 23 March 2011 - 05:14 PM

Greetings,

Currently trying out a submit form with Ajax but haven't had any success in receiving the "fill in" directly to my mail inbox. After filling in the field and submitting, it notifies with a "thanks note" but nothing is received.

Here is the demo:
http://unwrapped-stu...Form/index.html

Also, there are no filters set to my email.

Any help/suggestion?

#2 davidatfuzzylime

davidatfuzzylime

    Designer; coder; geek

  • Members
  • PipPipPipPipPip
  • 427 posts

Posted 24 March 2011 - 03:24 AM

We'd need to see the code of:
sendmailexample.php

to help, I suspect :)
fuzzylime: we know design
Save money when you sign up! Go here then use code giveme15 to get 15% off or giveme5 to get $5 off your order.

#3 jbrown

jbrown

    Tiny Orange

  • Members
  • Pip
  • 7 posts

Posted 24 March 2011 - 01:53 PM

View Postdavidatfuzzylime, on 24 March 2011 - 03:24 AM, said:

We'd need to see the code of:
sendmailexample.php

to help, I suspect :)


David,

The code is originally from the following website:
http://midmodesign.c...-with-honeypot/

Here is the php code:

<?php

$sendto = 'info@unwrapped-studio.com';

//        The subject you'll see in your inbox
$subject = 'Contact from contact form';

//        Message for the user when he/she doesn't fill in the form correctly.
$errormessage = 'Oops! There seems to have been a problem. May we suggest...';

//        Message for the user when he/she fills in the form correctly.
$thanks = "Thanks for the email! We'll get back to you as soon as possible!";

//        Message for the bot when it fills in in at all.
$honeypot = "You filled in the honeypot! If you're human, try again!";

//        Various messages displayed when the fields are empty.
$emptyname =  'Entering your name?';
$emptyemail = 'Entering your email address?';
$emptytele = 'Entering your telephone number?';
$emptymessage = 'Entering a message?';

//       Various messages displayed when the fields are incorrectly formatted.
$alertname =  'Entering your name using only the standard alphabet?';
$alertemail = 'Entering your email in this format: <i>name@example.com</i>?';
$alerttele = 'Entering your telephone number in this format: <i>555-555-5555</i>?';
$alertmessage = "Making sure you aren't using any parenthesis or other escaping characters in the message? Most URLS are fine though!";


$alert = '';
$pass = 0;

// Sanitizing the data, kind of done via error messages first. Twice is better!  ;-)
function clean_var($variable) {
    $variable = strip_tags(stripslashes(trim(rtrim($variable))));
  return $variable;
}

//The first if for honeypot.
if ( empty($_REQUEST['last']) ) {

// A bunch of if's for all the fields and the error messages.
if ( empty($_REQUEST['name']) ) {
$pass = 1;
$alert .= "<li>" . $emptyname . "</li>";
} elseif ( ereg( "[][{}()*+?.\\^$|]", $_REQUEST['name'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertname . "</li>";
}
if ( empty($_REQUEST['email']) ) {
$pass = 1;
$alert .= "<li>" . $emptyemail . "</li>";
} elseif ( !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_REQUEST['email']) ) {
$pass = 1;
$alert .= "<li>" . $alertemail . "</li>";
}
if ( empty($_REQUEST['tele']) ) {
$pass = 1;
$alert .= "<li>" . $emptytele . "</li>";
} elseif ( !ereg( "\(?[0-9]{3}\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}", $_REQUEST['tele'] ) ) {
$pass = 1;
$alert .= "<li>" . $alerttele . "</li>";
}
if ( empty($_REQUEST['message']) ) {
$pass = 1;
$alert .= "<li>" . $emptymessage . "</li>";
} elseif ( ereg( "[][{}()*+?\\^$|]", $_REQUEST['message'] ) ) {
$pass = 1;
$alert .= "<li>" . $alertmessage . "</li>";
}

//If the user err'd, print the error messages.
if ( $pass==1 ) {

//This first line is for ajax/javascript, comment it or delete it if this isn't your cup o' tea.
echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";
echo "<b>" . $errormessage . "</b>";
echo "<ul>";
echo $alert;
echo "</ul>";

// If the user didn't err and there is in fact a message, time to email it.
} elseif (isset($_REQUEST['message'])) {
    
//Construct the message.
    $message = "From: " . clean_var($_REQUEST['name']) . "\n";
$message .= "Email: " . clean_var($_REQUEST['email']) . "\n";
    $message .= "Telephone: " . clean_var($_REQUEST['tele']) . "\n";
    $message .= "Message: \n" . clean_var($_REQUEST['message']);
    $header = 'From:'. clean_var($_REQUEST['email']);
    
//Mail the message - for production
//mail($sendto, $subject, $message, $header);
//This is for javascript,
echo "<script>$(\".message\").hide(\"slow\").show(\"slow\").animate({opacity: 1.0}, 4000).hide(\"slow\"); $(':input').clearForm() </script>";
echo $thanks;
die();

//Echo the email message - for development
echo "<br/><br/>" . $message;

}

//If honeypot is filled, trigger the message that bot likely won't see.
} else {
echo "<script>$(\".message\").hide(\"slow\").show(\"slow\"); </script>";
echo $honeypot;
}
?>

#4 davidatfuzzylime

davidatfuzzylime

    Designer; coder; geek

  • Members
  • PipPipPipPipPip
  • 427 posts

Posted 24 March 2011 - 01:59 PM

OK, well, this line:
//mail($sendto, $subject, $message, $header);
is commented out. That's what the first two slashes mean. That means it's never actually sending an e-mail! Just remove those two slashes and you should be set.
fuzzylime: we know design
Save money when you sign up! Go here then use code giveme15 to get 15% off or giveme5 to get $5 off your order.

#5 jbrown

jbrown

    Tiny Orange

  • Members
  • Pip
  • 7 posts

Posted 24 March 2011 - 04:56 PM

View Postdavidatfuzzylime, on 24 March 2011 - 01:59 PM, said:

OK, well, this line:
//mail($sendto, $subject, $message, $header);
is commented out. That's what the first two slashes mean. That means it's never actually sending an e-mail! Just remove those two slashes and you should be set.


Definitely did the trick. Thanks again David!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users