Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    Sending an online form?

    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";

    ?>

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    Yes the form can be in the same file. This is a more complex script, there is simpler ones you can use.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Thanks for that Master. I'll try my hand at it!!

    Cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •