Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['submitForm'])) {
- $firstname = $_POST['firstname'];
- $lastname = $_POST['lastname'];
- $email = $_POST['email'];
- $organisation = $_POST['organisation'];
- $question_1 = $_POST['question1'];
- $question_2 = $_POST['question2'];
- $question_3 = $_POST['question3'];
- $question_4 = $_POST['question4'];
- $question_5 = $_POST['question5'];
- $image_1 = $_POST['fileToUpload1'];
- $image_2 = $_POST['fileToUpload2'];
- $image_3 = $_POST['fileToUpload3'];
- $message = $_POST['message'];
- $target_dir = "/var/www/vhosts/system/removed.co.uk/etc/contact-facility/uploads/";
- $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
- $uploadOk = 1;
- $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
- $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
- if($check !== false) {
- $uploadOk = 1;
- }
- else {
- $uploadOk = 0;
- }
- if (file_exists($target_file)) {
- $uploadOk = 0;
- }
- if ($_FILES["fileToUpload"]["size"] > 500000) {
- echo "Sorry, your file is too large.";
- $uploadOk = 0;
- }
- if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) {
- echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
- $uploadOk = 0;
- }
- $servername = "localhost";
- $username = "removed";
- $password = "removed";
- $dbname = "removed";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $sql = "INSERT INTO contact_facility (first_name, last_name, email_address, hospital_trust, question_1, question_2, question_3, question_4, question_5, image_1, image_2, image_3, message) VALUES ('$firstname', '$lastname', '$email', '$organisation', '$question_1', '$question_2', '$question_3', '$question_4', '$question_5', '$image_1', '$image_2', '$image_3', '$message')";
- $conn->exec($sql);
- $success = "<p style='color: green;'>Thank you for contacting REMOVED.<br /><br />We have received your Contact Enquiry and will contact you within 24-48 hours with information regarding your request.</p>";
- }
- catch(PDOException $e) {
- echo $sql . "<br />" . $e->getMessage();
- }
- $conn = null;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement