php contact form script

Solutions on MaxInterview for php contact form script by the best coders in the world

showing results for - "php contact form script"
Mía
04 Oct 2017
1#Contact form
2
3NOTE:  NEEDS An SMTP service on the website server.
4
5<?php
6    //Message Vars
7    $msg = '';
8    $msgClass = '';
9    //check for the submit
10    if(filter_has_var(INPUT_POST,'submit')){
11    //Get form Data
12    $name = htmlspecialchars($_POST['name']);
13    $email = htmlspecialchars($_POST['email']);
14    $message = htmlspecialchars($_POST['message']);
15
16    //Check Required Fields
17    if(!empty($email) && !empty($name) && !empty($message)){
18        //passed
19        //check enail
20        if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
21            //Failed
22            $msg = 'email format is incorrect';
23            $msgClass='alert-danger';
24        }else{
25            //Passed
26            //send to Recipient email needs an email host to send it
27            $toEmail = 'someemail@example.com';
28
29        }
30        
31    }else{
32        //failed
33        $msg = 'Please Fill in all fields completely';
34        $msgClass='alert-danger';
35        //Email Subject
36        $subject = 'contact request from '.$name;
37        //creat body of the email
38        $body = "<h2>Contact Request</h2>
39        <h4>Name</h4><p>'.$name.'</p>
40        <h4>Email</h4><p>'.$email.'</p>
41        <h4>Message</h4><p>'.$message.'</p>";
42
43        //Email Header
44        $headers = "MIME-VERSION: 1.0" . "\r\n";
45        $headers .= "Content-Type:text/html;charset=UTF-8" . "/r/n";
46
47        //Additional Headers
48        $headers.= "From: ".$name."<" .$email. ">". "\r\n";
49
50        if(mail($toEmail, $subject, $body, $headers)){
51            //Email sent
52            $msg = 'Email sent';
53            $msgClass = 'alert-success';
54
55        }else{
56            $msg = 'Email has not been sent';
57            $msgClass = 'alert-danger';
58    }
59    }
60?>
Anna
28 Feb 2020
1<?php
2  
3if($_POST) {
4    $visitor_name = "";
5    $visitor_email = "";
6    $email_title = "";
7    $concerned_department = "";
8    $visitor_message = "";
9    $email_body = "<div>";
10      
11    if(isset($_POST['visitor_name'])) {
12        $visitor_name = filter_var($_POST['visitor_name'], FILTER_SANITIZE_STRING);
13        $email_body .= "<div>
14                           <label><b>Visitor Name:</b></label> <span>".$visitor_name."</span>
15                        </div>";
16    }
17 
18    if(isset($_POST['visitor_email'])) {
19        $visitor_email = str_replace(array("\r", "\n", "%0a", "%0d"), '', $_POST['visitor_email']);
20        $visitor_email = filter_var($visitor_email, FILTER_VALIDATE_EMAIL);
21        $email_body .= "<div>
22                           <label><b>Visitor Email:</b></label> <span>".$visitor_email."</span>
23                        </div>";
24    }
25      
26    if(isset($_POST['email_title'])) {
27        $email_title = filter_var($_POST['email_title'], FILTER_SANITIZE_STRING);
28        $email_body .= "<div>
29                           <label><b>Reason For Contacting Us:</b></label> <span>".$email_title."</span>
30                        </div>";
31    }
32      
33    if(isset($_POST['concerned_department'])) {
34        $concerned_department = filter_var($_POST['concerned_department'], FILTER_SANITIZE_STRING);
35        $email_body .= "<div>
36                           <label><b>Concerned Department:</b></label> <span>".$concerned_department."</span>
37                        </div>";
38    }
39      
40    if(isset($_POST['visitor_message'])) {
41        $visitor_message = htmlspecialchars($_POST['visitor_message']);
42        $email_body .= "<div>
43                           <label><b>Visitor Message:</b></label>
44                           <div>".$visitor_message."</div>
45                        </div>";
46    }
47      
48    if($concerned_department == "billing") {
49        $recipient = "billing@domain.com";
50    }
51    else if($concerned_department == "marketing") {
52        $recipient = "marketing@domain.com";
53    }
54    else if($concerned_department == "technical support") {
55        $recipient = "tech.support@domain.com";
56    }
57    else {
58        $recipient = "contact@domain.com";
59    }
60      
61    $email_body .= "</div>";
62 
63    $headers  = 'MIME-Version: 1.0' . "\r\n"
64    .'Content-type: text/html; charset=utf-8' . "\r\n"
65    .'From: ' . $visitor_email . "\r\n";
66      
67    if(mail($recipient, $email_title, $email_body, $headers)) {
68        echo "<p>Thank you for contacting us, $visitor_name. You will get a reply within 24 hours.</p>";
69    } else {
70        echo '<p>We are sorry but the email did not go through.</p>';
71    }
72      
73} else {
74    echo '<p>Something went wrong</p>';
75}
76?>
77
queries leading to this page
contact us phpsimple contact us form phpphp contact us form tutorialphp contact form script with validationcontact us form php codephp contact forms with sqla simple contact form in php script with htmlbuilding php contact formphp for contact formhow to make contact form phpmaking a contact form work phpphp tutorial contact formcontact php scriptcreate a php contact formphp contact form and upload hostmake a working form with phpcontact us phpenquiry form in phpcontact form made with phpfree php 2cdatabase 2c and javascript contact form for websitecontact us page with phphow to create a contact form with php 2c html and cssphp contact form postcreate a working php formcontact us form functionalityphp contact page mail using querycontact form html and phpworking contact form phphtml contact form in phpcontact php codehow to configure contact us in phpcontact form using html phpsimple working contact form phpphp contact form sample with source codeadd php contact formbasic contact form phpphp projects contact formphp contact pagea php contact formcreating a php contact formphp enquiry formphp contact formhow to use php contact form on serverformulaire contact phpphp contact user to userphp contact form scritpphp contact form advanced contact form phphow to setup contact form through phpcontact html to php filecontact form 7 functions phpcreate a contact form with html and phphow to make working contact form in phpcreate simple contact form phpcustom contact form html phpcontact form php plugincontact form 7 for phpjs php html contact forma sample php save contact formcode for an html and phph contact formcontact form php codesimple php contact form examplephp creating contact formhtml php contact formhow to create php quote formeasy php contact form script gratisphp contact form with csscontact form submit phpcreate a setup form php contact php concactcontact us page using phpmaking a contact form using phpforms 2fcontact phphtml php contact form examplehow to create php contact formworking contact us phpphp contact us form with souced codecreate a working contact form phpcontact form with get phpa php backend code for contact formcontact form jusing phpphp contact formularcontact us page in php with validationcontactusform 3afunction 28 29 7b 7dcreate a html php contact formhow to use html php contact form on your websitehow to get a contact form to work phphow to make contact process phpfull contact form phpcss contact form with php contact form for website using phpfree contact form with php 2cdatabase 2c and javascript for websitecontact form php mysqlcontact form php workingtype of contact form in phpcontact us php postcontact form without phpcontact form7 php codecontact form php wpcreation of contact form using phpcontact page phpcode for a contact form phpphp contact form samplecontact in phpstreetphoto infol 2fmailform phpcontact phpcontact form para phpphp contact form submit buttoncontact form source codecontact form 7 additional phpdo you need php for a working contact formhow to make a working contact us form without phpaction page php for contactcontact us page without dbsimple html php contact formcontact form using php onlymake a contact us using phpworking php contact form how to create contact form with phpadd contact form in php filecontact us form phpphp send contact formsubmit contact form phpsending your contact us form phpphp contact form doehtml contact form without phpbest way to view php contact form messages sent from clients in a websitecontact us form php mysqlhow to make a contact form without phpcontact form using html 2c css 2c phpcontact us with php codehow do i make a php contact form workcontact us form html and phpeasy php contact form scriptphp form example contactphp contact form with resultshow to develop a working contact form with phpcontact us page in phpform backend phphow do i create a contact us form in html and php 3fhtml and php enquiry formadd php in contact form 7php contact us pagehow to get contact form 7 data in in php code contact form with html and phphow to make contact forms in phpphp contact message contact form 7contact us form in php and mysqlphp contact form with documentationhtml contact form phpphp contact formatadd php code in contact form 7contact form with phpcontact form 7 phpphp contact form in html pagecreate a php contact form for htmlcontact form php worfcontact form phphworking contact us using phpphp contact form codefully working php contact form for websitecreate a content form php contactphp complete a form from other websitephp contact sendworking php contact formbuild a contact form with phpmy contact form phpcontact form tutorial phpcontact us page form phphow to create a contact us page in phpcontact form php bookphp contact uscontact form inphpphp contact form createcontactus phpphp script for contact formphp contact form example 2020php code for contact formwhat is a php file in a contact formhow to make a contact form functionalcontact contact form using phpphp contact us form with database source codephp contact form libraryhow to contact form html site php filedesign a contact us form with all fields as required html codesetup a contact us with phphtml contact form with phpphp contact form for websiteis it necessary to add php in contact formcontact phpphp contact form option valueshow to test my php contact formphp contact us send mailexternal contact form php handler 3dcomplete contact form in html phpphp contact form script simple contact form in phploacalhost 2ffaaize corporate 2fcontact phphow to make html contact us form wok with phpphp form for contact pagecontact form php templatestandard contact form phpcontact us page phpbasic contact us php scriptuse php to add contact form in htmlcreating a working contact form phpphp contact form sendphp contact form source codejavascript or php for contact formphp contact us form with source codewrite a php script to accept the feedback on workshop event from html form with details of username 2c email 2c phone number 2c date of event rating 2c session and store it an associative array display the consolidated report in table contact form html php templatehow to create a workking contact form using phpcreate contact form phpcontact form php source codebasic php contact formhow to create a contact frome using phphow to make a working contact form phpcontact form with php codecontact us php example how to crea e a php quote formhow to create contact us form in php with databasemaking a php contact form for html webpagecontact form 7 php codecontact us form in phpcontact form php post php contactformularfull contact page phpphp contact us formcontact form submitting phpcontact us html php what does php do for a contact formcreate a contat form with phpcontact form html php tutorialcomplete working contact pagecontact form php post or getfull working contact form php codephp code to submit contact form to email tutorial with examplesimple contact form phphow to make a working php contact formcontactform phphow to create a contact form using phpcreate working contact form using html css phpphp contact form to user to usercontact us for using phpconact form phpphp contact from user to usercontactos form phpcontact us php codecontact us page php codecontact form in phphow to make a php contact formcode of php to get daata from the contact form in websitesimple contact form php codesetup form php contactphp contact form using smtpjavascript contact form without phpphp working contact boxphp tutorial contact form source codehtml inner php contact formshow to make contact form work in phpa simple contact form in phpcreate contact form html phphow to store contact form php details in databasehow to create contact us page and email phpcontact php codephp contact form examplecreate contact form with php 3cform action 3d 22contact php 22 name 3d 22 22 method 3d 22post 22 3econtact us in phpsave informoration in mobile contact in phpcontact us with php functionindex php script for index html formphp script for contact us formphp working contact formcontact form tutorialwhat do i need to use php contact pagehow to make a contact form with html 2c css and phpmodern contact form php htmlcontact us form with phpsend the contact us datacontact me phpmake a contact form with php mailhtml php user contact formphp contact form with results pagecreate working contact form using js 2c php 7c contact form designhow to create contact form in phpphp conact formscontact form html php in c 23working contact form php code create funtional contact form phpphp contactoscontactform 2fcontactform phpadding working php form to websitephp contact form with validationworking contact form html phphow to create a simple php contact form for portfolioa simple php save contact formcode for contact form in phphow to make a contact form in html and phpphp simple contact formcontact us page isuing phpphp html contact formmodern data entry forms in php mysql csscontact form in php with databaseget in touch php how to make contact us form in phpphp contact form user to userhow to setup contact form in phpcustom html and php contact formcontact us page in php soced code with datasnse email form tutorialcontact form php and htmlhtml contact phppost contact phpmy contact form displays my php scriptfree php and javascript contact form for websitegenerate page for form information in phpcontact us form in php with php and mysqlhow to make a working contact form with servercreating a contact us page phpphp free contact formreal life contact form phpphp form contactphp contact form with validation free downloada simple contact form in php scriptphp contact form functionsimple contact us form html and php 5cphp make contact form workwebsite contact form without phpphp contact form email sender example 2020simple contact us php formphp contact us form with database ajazcontact pages phpsend contact form using phpphp contact form complete source codecontact form with php web devhow to create a contact form in html phpcontact form code phpcontact formular php codephp mail contact form codemaking a working contact from in phpphp contact detais to a servercodes to create php contact formphp form messagecontact us page in html phppinclude contact form 7 on phpcontact form html phpcontact form 7 in php codecontact form using phpcontact form phpformat contact form php htmladd php code for contact form 7simple contact form with phpmessage form phpcontact us html and phpphp contact us form with databaseworking contact form without phphow to code contact us form in phpphp contact form with database connectionhw to creat contact form phpphp contact form 5cphp contact form tutorialcontact us form submit in phphow to create a contact form using php and htmlhtml php mysql contact formhow to add php code in contact form 7reactionform phpreading filelds contact form in phpreading contact from in php filesimple contact form php downloadphp contact form databasecontact form with php and htmlhow to create a contact me php pagehtml and php contact formcontact us php scriptcontact form php scriptphp contact form code downloadlogin form phpphp simple contact fromcontact form how to receive data phpmake contactform phpcontact form code in phpcontact us form using phpsimple php contact formcontact me form serverusing php for contact formphp contct us page with database downloadcontact page html phpsend contact form with script and phpa simple contact form with phphow to create a simple php contact formjs contact form emailcontact us form submission email code in phpenquiry form php codephp email contact formphp contact form source codecontact form phget in touh templates phphow to make a contact form in phphow make contact form phphow to create a working contact form in phpcontact us form example html action php codecontact form html without phpcreate functional contact form php contact form php send best way to view php contact form messages sent from clientscontact form pphphow to make contact forms in php using mailcontact strings phplocalhost 3a 2fphaliainternational 2fcontact us phphow to make a contact form with phphow to do a contact us function in phpinclude contact form php filehtml contact us form with php database code in phpphp contact form w3schoolsphp contact form script with validation htmlphp code for contact form codehow to create contact form in html php mysqlhow to make contact form in html with phphow to create a contact form for my website phpphp and html contactform contact phpphp contact form script