Browse Source

Update form.php

redesign
Anxhelo Lushka 7 years ago
committed by GitHub
parent
commit
cc0dbcb5c5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 109
      form.php

109
form.php

@ -1,56 +1,53 @@
-<?php
-
-//Import the PHPMailer class into the global namespace
-use PHPMailer\PHPMailer\PHPMailer;
-require '../vendor/autoload.php';
-
-if (array_key_exists('to', $_POST)) {
- $err = false;
- $msg = '';
- $email = '';
-
- //Apply some basic validation and filtering to the name
- if (array_key_exists('name', $_POST)) {
- //Limit length and strip HTML tags
- $name = substr(strip_tags($_POST['name']), 0, 255);
- } else {
- $name = '';
- }
-
- //Apply some basic validation and filtering to the surname
- if (array_key_exists('surname', $_POST)) {
- //Limit length and strip HTML tags
- $name = substr(strip_tags($_POST['name']), 0, 255);
- } else {
- $name = '';
- }
-
- //Make sure the address they provided is valid before trying to use it
- if (array_key_exists('email', $_POST) and PHPMailer::validateAddress($_POST['email'])) {
- $email = $_POST['email'];
- } else {
- $msg .= "Error: invalid email address provided";
- $err = true;
- }
-
- if (!$err) {
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->Host = 'localhost';
- $mail->Port = 2500;
- $mail->CharSet = 'utf-8';
- //It's important not to use the submitter's address as the from address as it's forgery,
- //which will cause your messages to fail SPF checks.
- //Use an address in your own domain as the from address, put the submitter's address in a reply-to
- $mail->setFrom('form@ura.design', (empty($name) ? 'Contact form' : $name));
- $mail->addAddress('anxhelo1995@gmail.com');
- $mail->addReplyTo($email, $name);
- $mail->Subject = 'Contact form: ' . $subject;
- $mail->Body = "Contact form submission\n\n" . $projectname . $message . $budget;
- if (!$mail->send()) {
- $msg .= "Mailer Error: " . $mail->ErrorInfo;
- } else {
- $msg .= "Message sent!";
- }
- }
-} ?>
<?php
//Import the PHPMailer class into the global namespace
use PHPMailer\PHPMailer\PHPMailer;
require '../vendor/autoload.php';
if (array_key_exists('to', $_POST)) {
$err = false;
$msg = '';
$email = '';
//Apply some basic validation and filtering to the subject
if (array_key_exists('subject', $_POST)) {
$subject = substr(strip_tags($_POST['subject']), 0, 255);
} else {
$subject = 'No subject given';
}
//Apply some basic validation and filtering to the name
if (array_key_exists('name', $_POST)) {
//Limit length and strip HTML tags
$name = substr(strip_tags($_POST['name']), 0, 255);
} else {
$name = '';
}
//Make sure the address they provided is valid before trying to use it
if (array_key_exists('email', $_POST) and PHPMailer::validateAddress($_POST['email'])) {
$email = $_POST['email'];
} else {
$msg .= "Error: invalid email address provided";
$err = true;
}
if (!$err) {
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'localhost';
$mail->Port = 2500;
$mail->CharSet = 'utf-8';
//It's important not to use the submitter's address as the from address as it's forgery,
//which will cause your messages to fail SPF checks.
//Use an address in your own domain as the from address, put the submitter's address in a reply-to
$mail->setFrom('form@ura.design', (empty($name) ? 'Contact form' : $name));
$mail->addAddress('anxhelo1995@gmail.com');
$mail->addReplyTo($email, $name);
$mail->Subject = 'Contact form: ' . $subject;
$mail->Body = "Contact form submission\n\n" . $message;
if (!$mail->send()) {
$msg .= "Mailer Error: " . $mail->ErrorInfo;
} else {
$msg .= "Message sent!";
}
}
} ?>

Loading…
Cancel
Save