...

View Full Version : Sending an online form?



SteveH
01-18-2010, 07:22 PM
Hello

I am just asking for some basic PHP advice since I am just feeling my way round at the moment.

I have the following script from my Web hosting people. Can I ask, do I write the HTML form fields in this same file - I would like to add the name, email, subject, message, and attachment plus the submit button.

Many thanks for any advice.

Cheers

Steve


<?php

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP(); // set mailer to use SMTP

$mail->Host = "smtp.mySite.com"; // specify main and backup server

$mail->SMTPAuth = true; // turn on SMTP authentication

$mail->Username = "XXXXX"; // SMTP username

$mail->Password = "XXXXX"; // SMTP password

$mail->From = "info@XXXXXXXXX.com";

$mail->FromName = "Mailer";

$mail->AddAddress("personal_Email@yahoo.com", "Josh Adams");

$mail->AddAddress("ellen@example.com"); // name is optional

$mail->AddReplyTo("info@XXXXXXXX.com", "Information");

$mail->WordWrap = 50; // set word wrap to 50 characters

$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments

$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name

$mail->IsHTML(true); // set email format to HTML

$mail->Subject = "Thank you for your message";

$mail->Body = "This is the HTML message body <b>in bold!</b>";

$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

if(!$mail->Send())

{

echo "Message could not be sent. <p>";

echo "Mailer Error: " . $mail->ErrorInfo;

exit;

}

echo "Message has been sent";

?>

masterofollies
01-18-2010, 08:00 PM
Yes the form can be in the same file. This is a more complex script, there is simpler ones you can use.

SteveH
01-18-2010, 08:10 PM
Thanks for that Master. I'll try my hand at it!!

Cheers



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum