Web Hosting Talk







View Full Version : PHP Mailer Help


Benji
03-27-2004, 04:56 PM
Okay, I created a PHP file that should take the results of a form, and mail them. But, however, all it does is when I hit the submit button, it opens the PHP file in that window, but it shows the code. In the form I made the form tag like this:
<form method="POST" action="rfq.php">
That way, it is showing that it should use the code in rfq.php. Here is rfq.php:
<?

// -------- EMail Form-----------
// By: Ben Gordon----------------
// -- Let's see if it works------


// Make message
$msg = "Name:\t$name\n";
$msg .= "E-Mail:\t$email\n";
$msg .= "Comments:\t$comments\n\n";

// Build mail message and send it to target recipient.
$recipient = "psoportal@knology.net";
$subject = "RFQ Form";

$mailheaders = "From: RFQ Form\n";
$mailheaders .= "Reply-To: $sender_email\n\n";

mail("$recipient", "$subject", $msg, $mailheaders);

// Print confirmation to screen.
echo "
<H1 align=center>Thank You, <?php print $name ?></h1>
<p align=center>Your message has been sent.</p>
";


?>
But all it shows in the browser, is the code I just posted. If anyone could help, it would be greatly appreciated.

Thanks,
Ben Gordon

ballingtonma
03-27-2004, 05:46 PM
Have you uploaded it to a server, if so, has the server got PHP installed. If you are trying it on your computer, to test the page you will need to download PHP and install it on your computer.

Benji
03-27-2004, 06:31 PM
Okay, I changed the code a bit.
This time, it does send the e-mail, except it doesn't pull the name category.

Here is the updated code:
<html>
<body><?php

// -------- EMail Form-----------
// By: Ben Gordon----------------
// -- Let's see if it works------


// Make message
$message1 = "Name:\t$yourname";
$message2 = "E-Mail:\t$email";
$message3 = "Type of Work:\t$type";
$message4 = "Comments:\t$comments";

// Build mail message and send it to target recipient.
$recipient = "psoportal@knology.net";
$subject = "RFQ Form";

mail("$recipient", "$subject", "$msessage1\n$message2\n$message3\n$message4");

// Print confirmation to screen.
echo "<p align=center>Your message has been sent.</p>";


?></body>
</html>

Hassan
03-27-2004, 06:38 PM
Hello,

Sound like PHP is not installed,

I think you are trying this script on your computer, if yes than upload it on server and try and if its not working on server than check PHP is installed or not.

Best Regards
Hassan

Benji
03-27-2004, 06:43 PM
No. It's uploaded on a server now. Look at my 2nd post in this topic.

Hassan
03-27-2004, 06:46 PM
Can you post the URL here so we can easily check it.

Benji
03-27-2004, 08:09 PM
It's fixed, thanks to everyone that wanted to help.

Rich2k
03-28-2004, 06:30 AM
The PHP you posted is a bit messy anyway

for instance you don't need to put quotes around $recipient and $subject in the mail command, you're just slowing it down for no reason.

The other point is when you asked why one variable wasn't working, you didn't post all of your code, we wouldn't have been able to really solve the problem without all parts that related to the form.

Sasuke
03-28-2004, 12:21 PM
$msessage1

There was one of your errors, you typoed the word message.