Click here to Skip to main content
15,885,366 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionCan't import pfx. Pin
ArturNoubel3-Nov-20 8:27
ArturNoubel3-Nov-20 8:27 
AnswerRe: Can't import pfx. Pin
Richard MacCutchan2-Nov-20 3:18
mveRichard MacCutchan2-Nov-20 3:18 
GeneralRe: Can't import pfx. Pin
ArturNoubel3-Nov-20 7:54
ArturNoubel3-Nov-20 7:54 
QuestionEquation of the third degree Pin
Member 1496562714-Oct-20 14:50
Member 1496562714-Oct-20 14:50 
AnswerRe: Equation of the third degree Pin
Richard MacCutchan14-Oct-20 22:37
mveRichard MacCutchan14-Oct-20 22:37 
AnswerRe: Equation of the third degree Pin
ZurdoDev15-Oct-20 1:17
professionalZurdoDev15-Oct-20 1:17 
Questionscreen with error in displaying the data, sql code does not work Pin
mynameyugioh21-Aug-20 13:38
mynameyugioh21-Aug-20 13:38 
QuestionAdding uploaded file in email response contact form mail.php Pin
DixieReid21-Jul-20 15:18
DixieReid21-Jul-20 15:18 
Hello, May I kindly ask for some help please. I have limited knowledge with html contact forms and validation by php. The form as it is works fine and validates fine. I would like to add a "file upload" field to the form, but can't quite work out what I need to add to the mail.php file. Please disregard some of the content responses, they are example questions only. Thank you very much.

<?php

    if ($_SERVER["REQUEST_METHOD"] == "POST") {

        // access
        $secretKey = '6LdhAK8UAAAAAD3Uaj5ILNiO5EPYPtDr2Wmr3sRO';
        $captcha = $_POST['g-recaptcha-response'];

        if(!$captcha){
          echo '<p class="alert alert-warning">Please check the the captcha form.</p>';
          exit;
        }

        # FIX: Replace this email with recipient email
        $mail_to = "dixie7@xtra.co.nz";
        
        # Sender Data
        $subject = trim($_POST["subject"]);
        $name = str_replace(array("\r","\n"),array(" "," ") , strip_tags(trim($_POST["name"])));
        $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL);
        $phone = trim($_POST["phone"]);

		$address1 = trim($_POST["address1"]);
		$address2 = trim($_POST["address2"]);

		$bandname = trim($_POST["bandname"]);

		$urlfacebook = trim($_POST["urlfacebook"]);

		$urlinstagram = trim($_POST["urlinstagram"]);

		$datepicker = trim($_POST["datepicker"]);

        $row1 = trim($_POST["row1"]);
		$row2 = trim($_POST["row2"]);
		$row3 = trim($_POST["row3"]);
		$row4 = trim($_POST["row4"]);

		$bandmembers = trim($_POST["bandmembers"]);

		$concertpreference = trim($_POST["concertpreference"]);

		$gender = trim($_POST["gender"]);

		$venue = trim($_POST["venue"]);

		$comment1 = trim($_POST["comment1"]);

		$ideas = trim($_POST["ideas"]);

		$comment2 = trim($_POST["comment2"]);

		$lunch = trim($_POST["lunch"]);

		$additional_options = implode(' | ', $_POST["afternoontea"]);

		$footwear = trim($_POST["footwear"]);

		$option = trim($_POST["dropdown"]);

		$message = trim($_POST["message"]);

		$contact = trim($_POST["contact"]);

        if ( empty($name) OR !filter_var($email, FILTER_VALIDATE_EMAIL) OR empty($message)) {
            # Set a 400 (bad request) response code and exit.
            http_response_code(400);
            echo '<p class="alert alert-warning">Please complete the form and try again.</p>';
            exit;
        }

        $ip = $_SERVER['REMOTE_ADDR'];
        $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
        $responseKeys = json_decode($response,true);

        if(intval($responseKeys["success"]) !== 1) {
          echo '<p class="alert alert-warning">Please check the the captcha form.</p>';
        } else {
            # Mail Content
            $content = "Name: $name\n";
            $content .= "Email: $email\n";
            $content .= "Phone: $phone\n";

			$content .= "Address 1: $address1\n";
			$content .= "Address 2: $address2\n";

			$content .= "Band Name: $bandname\n";

			$content .= "Facebook Profile: $urlfacebook\n";

			$content .= "Instagram Profile: $urlinstagram\n";

			$content .= "Preferred Date: $datepicker\n";

			$content .= "Snort Cocaine: $row1\n";
			$content .= "Smoke Marijuana: $row2\n";
			$content .= "Drink Bourbon: $row3\n";
			$content .= "Smash Guitars: $row4\n";

			$content .= "Band Members: $bandmembers\n";

			$content .= "Concert Preference: $concertpreference\n";

			$content .= "Gender: $gender\n";

			$content .= "Venue: $venue\n";

			$content .= "Venue Comments: $comment1\n";

			$content .= "Ideas: $ideas\n";

			$content .= "Ideas Comments: $comment2\n";

			$content .= "Lunch: $lunch\n";

			$content .= "Afternoon Tea: $additional_options\n";

			$content .= "Footwear: $footwear\n";

			$content .= "Option Selected: $option\n";

			$content .= "Preferred Contact: $contact\n";

			$content .= "Message: $message\n";

			
	
            # email headers.
            $headers = "From: $name <$email>";

            # Send the email.
            $success = mail($mail_to, $subject, $content, $headers);
            if ($success) {
                # Set a 200 (okay) response code.
                http_response_code(200);
                header('Location: https://www.mywebsitenz.com/test/thanks.html');
            } else {
                # Set a 500 (internal server error) response code.
                http_response_code(500);
                echo '<p class="alert alert-warning">Oops! Something went wrong, we couldnt send your message.</p>';
            }
        }

    } else {
        # Not a POST request, set a 403 (forbidden) response code.
        http_response_code(403);
        echo '<p class="alert alert-warning">There was a problem with your submission, please try again.</p>';
    }

?>

AnswerRe: Adding uploaded file in email response contact form mail.php Pin
Richard Deeming21-Jul-20 23:22
mveRichard Deeming21-Jul-20 23:22 
GeneralRe: Adding uploaded file in email response contact form mail.php Pin
DixieReid22-Jul-20 0:09
DixieReid22-Jul-20 0:09 
QuestionHow can I submit with 1 button and 1 form with 2 actions? Pin
amitb221-Jul-20 0:08
amitb221-Jul-20 0:08 
Rant[REPOST] How can I submit with 1 button and 1 form with 2 actions? Pin
Richard Deeming21-Jul-20 1:05
mveRichard Deeming21-Jul-20 1:05 
GeneralRe: [REPOST] How can I submit with 1 button and 1 form with 2 actions? Pin
Richard MacCutchan21-Jul-20 1:17
mveRichard MacCutchan21-Jul-20 1:17 
QuestionSubtraction of sum of 2 different table colums Pin
Mick Chambers17-Jun-20 21:58
Mick Chambers17-Jun-20 21:58 
AnswerRe: Subtraction of sum of 2 different table colums Pin
Richard MacCutchan17-Jun-20 23:43
mveRichard MacCutchan17-Jun-20 23:43 
GeneralRe: Subtraction of sum of 2 different table colums Pin
Mick Chambers18-Jun-20 2:11
Mick Chambers18-Jun-20 2:11 
GeneralRe: Subtraction of sum of 2 different table colums Pin
Richard MacCutchan18-Jun-20 4:39
mveRichard MacCutchan18-Jun-20 4:39 
GeneralRe: Subtraction of sum of 2 different table colums Pin
Mick Chambers18-Jun-20 2:13
Mick Chambers18-Jun-20 2:13 
GeneralRe: Subtraction of sum of 2 different table colums Pin
Richard MacCutchan18-Jun-20 4:40
mveRichard MacCutchan18-Jun-20 4:40 
QuestionHow to handle response after PayPal subscription approval Pin
Petar Vasilev1-May-20 10:27
Petar Vasilev1-May-20 10:27 
Questionhow to add additional in php query or jquery Pin
captan389926-Apr-20 21:57
captan389926-Apr-20 21:57 
AnswerRe: how to add additional in php query or jquery Pin
Richard MacCutchan26-Apr-20 22:35
mveRichard MacCutchan26-Apr-20 22:35 
AnswerRe: how to add additional in php query or jquery Pin
Richard Deeming27-Apr-20 0:33
mveRichard Deeming27-Apr-20 0:33 
Questionsocket_send not working without break or exit Pin
Member 147929365-Apr-20 2:04
Member 147929365-Apr-20 2:04 
QuestionHow to share session cookies from a PHP application with my WordPress website, hosted on the same server and the same domain? Pin
mplusplus29-Dec-19 17:50
mplusplus29-Dec-19 17:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.