Jump to content

another php contact form problem


dr1983

Recommended Posts

Hi first off i`d like to say hello, i`ve just been customising a site template and the contact form php script appears to be incorrect. I`ve tried to contact the templates creator, but have had no success.

 

The contact form is pretty simple, a name, email and message fields. The form is sending an email but i`m not getting the message text. i get something like this

"The Name Of The Sender: 1

Email: blahblah@blah.com

 

Subject:

 

 

Message:

 

 

 

IP ADDRESS: 82.28.90.77

 

Daniel Reed Photography"    which is pretty useless. I`m less than a novice and i know it could be as simple as a typo but if anyone could have a look over this i`d really appreciate it.       

<?php
//Type the receiever's e-mail address
$emailAddress = "dr@danielreedphotography.com";
//Type your Site Name
$siteName = "Daniel Reed Photography";  $contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];  if( $contact_name = true ) {
$sender = $contact_email;
$receiver = $emailAddress;
$client_ip = $_SERVER['REMOTE_ADDR'];   $email_body = "The Name Of The Sender: $contact_name \nEmail: $sender \n\nSubject: $contact_subject
\n\nMessage: \n\n$contact_message \n\nIP ADDRESS: $client_ip \n\n$siteName";   $emailAutoReply = "Hi $contact_name, \n\nWe have just received your E-Mail. We will get
in touch in a few days. Thank you!  \n\n$siteName ";   $extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
$autoReply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();   mail( $sender, "Auto Reply: $contact_subject", $emailAutoReply, $autoReply );   if( mail( $receiver, "New E-Mail - $contact_subject", $email_body, $extra ) ) {
  echo "success=yes";
} else {
  echo "success=no";
}
}
?> 

the website is danielreedphotography.com if you`re if seeing the form will help. click the contacts link at the top to see it in action or inaction lol.    many thanks,  Daniel Reed

Link to comment
Share on other sites

I`m sorry if the code is messy, to me it makes very little sense. I see the definitions and the processes calling them but it still is baffling to me. I have no real background with php syntax, i know coming here and asking for help and not doing your homework is a big ask.

 

The code was written by the templates creator, the bulk of the site is in flash, a SWF file calling the xml page entitled email which i posted above. Template came without an FLA file too.

 

Infact the code didnt do anything at first and thought php wasnt enabled on my server, ran a test script and that sent. It turns out the creator of the code had put two = signs next to each other, that was about the only thing i could spot that might be wrong at first glance and then it started sending emails like the one included above.

 

 

Link to comment
Share on other sites

here is the code that has been cleaned up:

 

<?php
//Type the receiever's e-mail address
$emailAddress = "dr@danielreedphotography.com";

//Type your Site Name
$siteName = "Daniel Reed Photography";  $contact_name = $_POST['name'];
$contact_email = $_POST['email'];
$contact_subject = $_POST['subject'];
$contact_message = $_POST['message'];  

if( $contact_name = true ) {
$sender = $contact_email;
$receiver = $emailAddress;
$client_ip = $_SERVER['REMOTE_ADDR'];
$email_body = "The Name Of The Sender: $contact_name \nEmail: 
		$sender \n\nSubject: $contact_subject\n\nMessage: \n\n$contact_message \n\n
		IP ADDRESS: $client_ip \n\n$siteName";   $emailAutoReply = "Hi $contact_name, \n\n
		We have just received your E-Mail. We will get in touch in a few days. Thank you!  \n\n
		$siteName ";   

$extra = "From: $sender\r\n" . "Reply-To: $sender \r\n" . "X-Mailer: PHP/" . phpversion();
$autoReply = "From: $receiver\r\n" . "Reply-To: $receiver \r\n" . "X-Mailer: PHP/" . phpversion();   

mail( $sender, "Auto Reply: $contact_subject", $emailAutoReply, $autoReply );   

if( mail( $receiver, "New E-Mail - $contact_subject", $email_body, $extra ) ) {
	echo "success=yes";
} else {
	echo "success=no";
}
}
?>

 

if by saying there were two = signs in this line:

if( $contact_name = true ) {

then you should have left it...

One equal sign, in PHP, attributes the value on the right to the variable on the left of it

 

So it probably should be

if( $contact_name == true ) {

 

You need to make sure that the fields in your contact name

are subject and message

 

maybe you could do a

var_dump($_POST);

then you'll be able to see the names of the variables

 

 

 

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.