Jump to content

PHP AJAX Contact form


namanhle91

Recommended Posts

Hi All,

 

I am trying to get this contact form to work correctly. The problem I have right now is that the e-mail sends only the Name, Email Address, and Phone Number, and it will not send anything for the body or "message" portion. The first code is contact.php

<?php
/*
Credits: Bit Repository
URL: http://www.bitrepository.com/
*/

include 'contact_config.php';
session_start();
error_reporting (E_ALL ^ E_NOTICE);

$post = (!empty($_POST)) ? true : false;

if($post)
{
include 'functions.php';

$name = stripslashes($_POST['name']);
$email = trim($_POST['email']);
$phone = stripslashes($_POST['phone']);
$subject = stripslashes($_POST['subject']);
$message = "Site visitor information:

Name: ".$_POST['name']
."

E-mail Address: ".$_POST['email']
."

Phone: ".$_POST['phone']
."

Message: ".$_POST['message'];


$error = '';

// Check name

if(!$name)
{
$error .= 'Please enter your First name.<br />';
}
// Check email

if(!$email)
{
$error .= 'Please enter an e-mail address.<br />';
}

if($email && !ValidateEmail($email))
{
$error .= 'Please enter a valid e-mail address.<br />';
}


if(isset($_SESSION['captcha_keystring']) && strtolower($_SESSION['captcha_keystring']) != strtolower($_POST['capthca']))
{
$error .= "Incorect captcha.<br />";
}


if(!$error)
{

$mail = mail(WEBMASTER_EMAIL, $subject, $message,
     "From: ".$name." <".$email.">\r\n"
    ."Reply-To: ".$email."\r\n"
    ."X-Mailer: PHP/" . phpversion());

if($mail)
{
echo 'OK';
}

}
else
{
echo '<div class="notification_error">'.$error.'</div>';
}

}
?>

 

and contact_config.php only contain the webmaster's email address.

 

Thank you for your help.

Link to comment
https://forums.phpfreaks.com/topic/259911-php-ajax-contact-form/
Share on other sites

are you basically saying that $_POST['message'] is coming in empty?

 

so for example, you see:

Site visitor information:

Name: Bob

E-mail Address: [email protected]

Phone: 555-555-5555

Message:

?

 

also... i notice you're doing some trimming and slash stripping, creating new variables... but then you continue using the POST variables..

are you basically saying that $_POST['message'] is coming in empty?

 

so for example, you see:

Site visitor information:

Name: Bob

E-mail Address: [email protected]

Phone: 555-555-5555

Message:

?

 

also... i notice you're doing some trimming and slash stripping, creating new variables... but then you continue using the POST variables..

 

Yes that is exactly what is happening! Is the conflict you listed above causing the problem?

 

Thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.