3 Replies - 1314 Views - Last Post: 20 February 2012 - 12:38 AM Rate Topic: -----

#1 ReclusiveManiac  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 98
  • Joined: 18-September 09

Sending email from web page using PHP

Posted 19 February 2012 - 11:01 PM

I've found a script to send an email from a web page, but when I put the code into the page the code is displaying as text. The script is

<?php 
if ($_POST["email"]<>'') { 
	$ToEmail = '[email protected]'; 
	$EmailSubject = 'Site contact form '; 
	$mailheader = "From: ".$_POST["email"]."\r\n"; 
	$mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
	$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
	$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
	$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
	$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>"; 
	mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 
Your message was sent
<?php 
} else { 
?> 



Everything after the first bracket is showing up, if anyone has any insight I would appreciate it.

Is This A Good Question/Topic? 0
  • +

Replies To: Sending email from web page using PHP

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4191
  • View blog
  • Posts: 13,241
  • Joined: 08-June 10

Re: Sending email from web page using PHP

Posted 19 February 2012 - 11:23 PM

View PostReclusiveManiac, on 20 February 2012 - 07:01 AM, said:

Everything after the first bracket is showing up

could you elaborate on that? I'm not sure which bracket you mean and whether you refer to the mail's text or the page's text.
Was This Post Helpful? 0
  • +
  • -

#3 ReclusiveManiac  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 98
  • Joined: 18-September 09

Re: Sending email from web page using PHP

Posted 20 February 2012 - 12:09 AM

On the web page it shows

'') { $ToEmail = '[email protected]'; $EmailSubject = 'Them Flooring Guys Info Form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"]."
"; $MESSAGE_BODY .= "Email: ".$_POST["email"]."
"; $MESSAGE_BODY .= "Phone Number: ".$_POST["number"]."
"; $MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."
"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); } ?> Your message was sent

And then it shows the form that I am using.

So it is ignoring everything after
<?php
if ($_POST["email"]<>

Thank you for the reply.

This post has been edited by ReclusiveManiac: 20 February 2012 - 12:31 AM

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4191
  • View blog
  • Posts: 13,241
  • Joined: 08-June 10

Re: Sending email from web page using PHP

Posted 20 February 2012 - 12:38 AM

looks somewhat as if the file is not parsed or recognised as PHP.

try replacing <> with !=
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1