Reputation: 413
When filling out the form it is saying sent successfully. So I need to enable or include phpmailer? The form is being sent via submit.php but the contact form is an html page. Do I also need to make the contact page php as well. Chmod permissions for submit.php is 755. In the script I do have the email address properly. I have phpmailer installed, do I need to activate it?
<?php
// specify your email here
$to = '[email protected]';
// Assigning data from $_POST array to variables
if (isset($_POST['name'])) { $name = $_POST['name']; }
if (isset($_POST['email'])) { $from = $_POST['email']; }
if (isset($_POST['company'])) { $company = $_POST['company']; }
if (isset($_POST['message'])) { $message = $_POST['message']; }
// Construct subject of the email
$subject = 'Contact Inquery ' . $name;
// Construct email body
$body_message .= 'NAME: ' . $name . "\r\n\n";
$body_message .= 'EMAIL: ' . $from . "\r\n\n";
$body_message .= 'SUBJECT: ' . $company . "\r\n\n";
$body_message .= 'MESSAGE: ' . $message . "\r\n\n";
// Construct headers of the message
$headers = 'From: ' . $from . "\r\n";
$headers .= 'Reply-To: ' . $from . "\r\n";
$mail_sent = mail($to, $subject, $body_message, $headers);
if ($mail_sent == true) { ?>
<script language="javascript" type="text/javascript">
window.alert("Sent Successfuly.");
</script>
<?php } else { ?>
<script language="javascript" type="text/javascript">
window.alert("Error! Please Try Again Later.");
</script>
<?php
} // End else
?>
Upvotes: 0
Views: 73
Reputation: 1563
When you say:
The form is being sent via
submit.php
I think you want to say:
The form is being sent to
submit.php
If this is the case, then I think the source code you posted is the content of this file.
php.ini
file in order to make your host correctly
send the email.N.B: I see that you PHP code is very simple and I deduce that you're a beginner, that you took this source code somewhere and that you don't really understand it. That's right. You have to start from somewhere.
BUT:
Be careful with this code! It takes the user inputs and sends it without any sanity checks. I recommend you to not deploy this code in production environment (if it's for testing and learning, that's right).
Look at this answer about PHP user input sanitation. It doesn't talk about sanitation for email sending. But it might be a good starting point to understand how it works basically. Then you have to search by yourself.
Upvotes: 1