0
    <?php 

    require 'PHPMailer/PHPMailerAutoload.php';

    $mail = new PHPMailer();

    //$mail->SMTPDebug = 3;// Enable verbose debug output
    $mail->isSMTP();// Set mailer to use SMTP
    $mail->Host = '124docs.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;// Enable SMTP authentication
    $mail->Username = 'infor@124docs.com';// SMTP username
    $mail->Password = '#';// SMTP password
    $mail->SMTPSecure = 'ssl';// Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;// TCP port to connect to
    $mail->setFrom('infor@124docs.com', '124Docs');
    $mail->addAddress('dulanga.weerasuriya@gmail.com', 'Dulanga');// Add a recipient
    $mail->addReplyTo($_POST['email'],$_POST['name']);
    //Keep it simple - don't use HTML
    $mail->isHTML(false);// Set email format to HTML

    $mail->Subject = 'Welcome';
    //Build a simple message body
    $mail->Body = <<<EOT
    Email: {$_POST['email']}
    Name: {$_POST['name']}
    Message: {$_POST['message']}
    EOT;
     //Send the message, check for errors
    if (!$mail->send()) {
    //The reason for failing to send will be in $mail->ErrorInfo
    //but you shouldn't display errors to users - process the error, log it on your server.
    $msg = 'Sorry, something went wrong. Please try again later.';
    } else {
    $msg = 'Message sent! Thanks for contacting us.';
    }

    ?>

    This is my contact form

Contact Form
<?php if (!empty($msg)) {
    echo "<h2>$msg</h2>"; } ?>

    <form id="contact-form" method="post" enctype="multipart/form-data" action="email.php">
    <fieldset>
    <label for="name"><span class="text-form">Name:</span><input type="text" name="name" id="name"/></label>
    <label for="email"><span class="text-form">Email:</span><input type="email" name="email" id="email"/></label>
    <div class="wrapper">
    <div class="text-form"><label for="message">Message:</div><textarea name="message" id="message" rows="8" cols="20"></textarea></label></div>
    <div style="margin-left:75px">
    <input class="form-control" id="bttn" type="reset" value="Clear">
    <input class="form-control" id="bttn" type="submit" value="Send">
    <div>
    </fieldset>
    </form>  


This is my full code now email are going correctly but now my question this my contact form page not show messages. so now I need help fix this error. I use the code for show the Message but it's not work correctly. then my code this not work. some one place help me fix this error. 

there are two code first one is the action page email.php and other page contact page. but at that time I mention only contact page form code only.

contact form show php code:

contact form show php code

that image means it show my php code in front end page. actually I need to show the contact form fill all details and I click the send button the successful message or it has some error. that's I need to show i my contact form.

0 Answers0