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
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: Bob@somesite.com

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..

Link to comment
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: Bob@somesite.com

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.