Jump to content

So. I have this form.

<form class="emailForm" name="Email Form" method="post" action="contact.php" enctype="text/plain">
<input name="first" type="first" required class="formDec" id="first" placeholder="First*">
<input name="last" type="last" required class="formDec" id="last" placeholder="Last*">
<input name="email" type="email" required class="formDec" id="email" placeholder="Email*" />
<input name="subject" type="subject" required class="formDec" id="subject" placeholder="Event Type (Wedding, party, etc.)">
<input name="message" type="message" required class="formDec messageForm" id="message" placeholder="Message">
<input type="submit" class="submitForm" id="submit" value="Submit">
</form>

And I have my PHP code mixed with PHPMailer

<?php

	$first=($POST['first']);
	$last=($POST['last']);
	$email=($POST['email']);
	$subject=($POST['subject']);
	$message=($POST['message']);
	
$body = "First: " . $first . "<br />" . "Last: " . $last . "<br />" . "Email: " . $email . "<br />" . "Type of Event: " . $subject . "<br />" . "Message: " . $message;

    require "phpmailer/class.phpmailer.php"; //include phpmailer class
      
    // Instantiate Class  
    $mail = new PHPMailer();  
      
    // Set up SMTP  
    $mail->IsSMTP();                // Sets up a SMTP connection  
    $mail->SMTPAuth = true;         // Connection with the SMTP does require authorization    
    $mail->SMTPSecure = "ssl";      // Connect using a TLS connection  
    $mail->Host = "smtp.gmail.com";  //Gmail SMTP server address
    $mail->Port = 465;  //Gmail SMTP port
	$mail->SMTPDebug = 2;
    $mail->Encoding = '7bit';
	
    // Authentication  
    $mail->Username   = "put my gmail in here"; // Your full Gmail address
    $mail->Password   = "and password"; // Your Gmail password
      
    // Compose
    $mail->SetFrom($_POST['email'], $_POST['first']);
    $mail->AddReplyTo($_POST['email'], $_POST['first']);
    $mail->Subject = "New Contact Form from Ultra Media";      // Subject (which isn't required)  
    $mail->MsgHTML($body);
 
    // Send To  
    $mail->AddAddress("this is where i put another gmail in", "Ultra Media Admins"); // Where to send it - Recipient
    $result = $mail->Send();		// Send!     
	unset($mail);

?>

But when I try this live on my website, I do get an email, but it doesn't contain any content.

It just looks like this:

 

First:

Last:

Email:

Type of Event:

Message:

 

Without any information that the user typed in.

 

Also, when I try it live, I get this message along with my success message:

Screenshot (28).png

 

What is happeninnn???

Link to comment
https://linustechtips.com/topic/593323-email-form/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×