Jump to content

Smeet

New Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Smeet

  1. Hey, I have tried with PHPMailer but no luck. Can you please review the code <?php $subject = filter_input(INPUT_POST, 'subject'); $name = filter_input(INPUT_POST, 'name'); $email = filter_input(INPUT_POST, 'email'); $message = filter_input(INPUT_POST, 'message'); $host = "localhost"; $username = "root"; $password = ""; $dbname = "dbname"; $conn = new mysqli ($host, $username, $password, $dbname); if (mysqli_connect_error()){ die('Connection Error('.mysqli_connect_error().')'.mysqli_connect_error()); } else { $sql = "INSERT INTO form (subject, name, email, message) values ('$subject', '$name', '$email', '$message')" ; if ($conn->query($sql)){ header("Refresh:0; url=index.html"); } else{ echo "Error: ".$sql ." ".$conn->error; } $conn->close(); } include("smtp/PHPMailerAutoload.php"); $mail = new PHPMailer(); //$mail->isSMTP(); $mail->Host = "smtp.office365.com"; $mail->Port=587; $mail->SMTPAuth = true; $mail->Username = "email-address"; $mail->Password = "email-password"; $mail->From = $mail->$Username; $mail->FromName = "Smeet Mehta"; $mail->AddAddres($email); $mail->WordWrap = 1000; $mail->IsHTML(true); $mail->Subject = $subject; $mail->Body = $message; if(!$mail->Send()) { echo "Message could not be sent. <p>"; echo "Mailer Error".$mail->ErrorInfo; exit; } else { echo "Message has been sent"; } ?>
  2. Hi All, Need your help with the situation I am stuck in. I have created a HTML Form and using PHP file saving that data into database. But now I want to send out an generic email to each visitor who fill the form. Attaching the code of html form and php database. It would be highly appreaciated if you can help me in updating the php file with which I can send an auto email. HTML Form - <!-- .contact-form --> <div class="contact-form"> <form id="contact-form" class="validate-form" method="post" action="send.php"> <!-- enter mail subject here --> <input type="hidden" name="subject" id="subject" value="You have a new message from Smeet Mehta!"> <p> <label for="name">NAME</label> <input type="text" name="name" id="name" class="required"> </p> <p> <label for="email">EMAIL</label> <input type="text" name="email" id="email" class="required email"> </p> <p> <label for="message">MESSAGE</label> <textarea name="message" id="message" class="required"></textarea> </p> <p> <button class="submit" control-id="ControlId-5">Send</button> </p> </form> </div> <!-- .contact-form --> PHP Code - <?php $subject = filter_input(INPUT_POST, 'subject'); $name = filter_input(INPUT_POST, 'name'); $email = filter_input(INPUT_POST, 'email'); $message = filter_input(INPUT_POST, 'message'); $host = "localhost"; $username = "root"; $password = ""; $dbname = "contact"; $conn = new mysqli ($host, $username, $password, $dbname); if (mysqli_connect_error()){ die('Connection Error('.mysqli_connect_error().')'.mysqli_connect_error()); } else { $sql = "INSERT INTO form (subject, name, email, message) values ('$subject', '$name', '$email', '$message')" ; if ($conn->query($sql)){ header("Refresh:0; url=index.html"); } else{ echo "Error: ".$sql ." ".$conn->error; } $conn->close(); } ?> Please Help
×
×
  • 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.