php contact form

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

showing results for - "php contact form"
Roxane
03 Feb 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?>
Alessia
27 Oct 2019
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
localhost 3a 2fphaliainternational 2fcontact us phphow to make a contact form without phpcode for contact form in phpphp send contact formcontact us page using phpenquiry form php codecontact form html and phpsimple contact us form html and php 5ccode for a contact form phphow to make contact form in html with phpphp working contact boxcontact us phpcontact us for using phpmaking a working contact from in phpadd php contact formsimple html php contact formcontact form in phpphp script for contact formcontact us form in php with php and mysqlsimple contact form phpphp contact page mail using queryhtml and php enquiry formstreetphoto infol 2fmailform phpsimple contact form php downloadfree php and javascript contact form for websitehow to develop a working contact form with phpcontact us page in phpdesign a contact us form with all fields as required html codephp contact form with results pagephp contact form sendhtml and php contact formcontact form 7 php codetype of contact form in phpcontact form using html phphow to make a working php contact formphp contact form samplephp contact pagecustom html and php contact formcontact form source codejs php html contact formcreate contact form with phpreactionform phpcontact us form html and phphow to configure contact us in phpfull contact page phpsimple contact us form phpphp contact form in html pagebasic php contact forma simple contact form in phpphp contact forms with sqlphp contact us form with source codehow to get contact form 7 data in in php code create working contact form using js 2c php 7c contact form designcontact form html phpcontact contact form using phphtml php mysql contact formcontact form tutorialeasy php contact form scriptcontact us page in php soced code with datasnse how to make contact process phpcontact form html php templatehow to test my php contact formcontact form 7 phpphp contact form scritp 3cform action 3d 22contact php 22 name 3d 22 22 method 3d 22post 22 3eadd php code in contact form 7php contact form user to usercreate a contat form with phpphp contact formatcontact form without phphow to make contact form work in phpwebsite contact form without phpcontact in phpworking contact form without phpcontact form how to receive data phpconact form phpmaking a php contact form for html webpagecontact php scripthow to setup contact form in phpphp conact formsphp html contact formphp contact form codecontact form submitting phpcontact form html php in c 23contact php codehow to setup contact form through phphow to make html contact us form wok with phpuse php to add contact form in htmlphp contact form createcontact html to php filephp code to submit contact form to email tutorial with examplemake contactform phpa simple contact form with phpcontact form 7 for phpbuild a contact form with phpfree contact form with php 2cdatabase 2c and javascript for websitephp contact us form with database source codecontact php codephp contact us form with database ajazphp complete a form from other websitewhat does php do for a contact formcontact us in phpmaking a contact form work phpcontact form with php and htmlbasic contact form phpis it necessary to add php in contact formphp contact formularhow to create a simple php contact formphp contact form example 2020how to use html php contact form on your websitephp contact form submit buttonhow to crea e a php quote formcontact us phphow to make contact form phpcontact us php codecontact form using php onlycontact us form php codephp contact form functionstandard contact form phpcontactusform 3afunction 28 29 7b 7demail form tutorialcontact form php mysqlcontact us form in php and mysqla simple contact form in php scripthow to create contact form in html php mysqlphp contact form source codephp script for contact us formcontact form php source codehow to store contact form php details in databasehow to make a contact form in html and phpcontact form php codephp contact form databasephp contact form to user to userphp contact form examplephp contact form script html php user contact formworking contact form html phpsimple working contact form phpcreate contact form phpphp contact us send mailexternal contact form php handlercode for an html and phph contact formget in touh templates phploacalhost 2ffaaize corporate 2fcontact phpcode of php to get daata from the contact form in websitecustom contact form html phpphp contact form tutorialcontact us page php codecodes to create php contact formformulaire contact phpphp contact form using smtpmake a contact us using phpphp projects contact formphp tutorial contact form source codehow to create contact us form in php with databasemake a working form with phpcomplete working contact pagephp contact us form with souced codehow do i make a php contact form workcontact form html without phpcontactform phpcontact us page without dbphp contact usphp form contacthow to make a working contact form phphtml php contact formcontact page phphow to make a contact form with phpphp email contact formlogin form phpcontact us form submit in phpphp contact form script with validation htmladd php code for contact form 7contact form with php codecontact form php pluginhow to make a contact form functionalhtml contact us form with php database code in phpcontact form pphpwhat do i need to use php contact pagecontact us page form phpmessage form phpcontactus phphow to create php quote formphp contactformularphp contact us form with databasehow to make working contact form in phphow to create a contact form for my website phpcontact us with php codehow do i create a contact us form in html and php 3fget in touch php php contact us pagephp contact from user to userhow to add php code in contact form 7php contact detais to a servercreate a working contact form phpworking contact form php code setup form php contactcontact form php worfusing php for contact formcontact form made with phpsimple contact form with phpform contact phpphp contact form w3schoolsfull contact form phpcreate simple contact form phpcontact form using phpcontact form phphow to create contact form in phphow to make a working contact form with servercontact us page in html phppaction page php for contactcontact form for website using phpcontact us page in php with validationphp contact form code downloadphp contact senda simple php save contact formworking php contact form reading filelds contact form in phpcontact us with php functiondo you need php for a working contact formphp contactosforms 2fcontact phpmake a contact form with php mailcreate functional contact form php post contact phpphp contact forma php backend code for contact formgenerate page for form information in phpphp form example contactsend contact form with script and phpcreation of contact form using phpcontact form php bookmy contact form displays my php scriptphp contact form option valuesa sample php save contact formcreating a php contact formcontact us form example html action php codehow to create a contact form in html phphow to do a contact us function in phpcontact form php template php concactcreating a contact us page phpmodern contact form php htmlhow to contact form html site php filecontact form php scripthow to create contact us page and email phpbasic contact us php scripthow to make contact forms in phpcontact us php example making a contact form using phpphp contact user to userphp code for contact form codecontact form submit phpphp contact form for websitephp contact form email sender example 2020php contact form with database connectionsend the contact us datahow to create a simple php contact form for portfoliophp for contact formcontact pages phpcontact form7 php codesubmit contact form phpcreate a php contact formphp working contact formhow to make a contact form in phpcreate funtional contact form phpcontactform 2fcontactform phpcontact form jusing phpphp contact us formcontact form using html 2c css 2c phpphp form for contact pagea php contact formcontact us form submission email code in phpsend contact form using phphtml contact form phpsimple contact form in phpreading contact from in php filewhat is a php file in a contact formhow to make contact us form in phpphp mail contact form codehow to make contact forms in php using mailcontact us form functionalityhow to create contact form with phpcontact form in php with databasecontact form tutorial phphow to create a contact form using phpbest way to view php contact form messages sent from clients in a websitecontact phpphp code for contact formcreating a working contact form phpsimple php contact formcontact form para phpphp make contact form workcontact form 7 in php codecontact form 7 functions phpcontact us form in phpcontact form php and htmlhow to get a contact form to work phpa simple contact form in php script with htmlcontact me phpphp simple contact formphp contact form with validationjavascript contact form without phpphp and html contactphp contact form source codehow to create a contact me php pagebuilding php contact formphp free contact formhow to code contact us form in phpcontact us form phpphp contact form with resultscontact us form using phphow make contact form phpphp contact form and upload hostadd contact form in php filehow to make a php contact formhow to make a contact form with html 2c css and phpphp contact form 5cjavascript or php for contact formsimple php contact form examplesimple contact form php 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 php contact us form tutorialhtml contact form in phpcreate a html php contact formadding working php form to websitephp creating contact formphp enquiry formcontact form phphcontact page html phpenquiry form in phpmodern data entry forms in php mysql cssindex php script for index html formphp contact form posthtml contact phphow to create php contact formsimple contact us php formcreate a content form php contacthow to use php contact form on serverhw to creat contact form phpcontact form html php tutorialhow to create a contact frome using phphow to make a working contact us form without phpfully working php contact form for websitefull working contact form php codeworking php contact formhtml inner php contact formsbest way to view php contact form messages sent from clientssetup a contact us with phpreal life contact form phpcontact us page isuing phpcontact form with get phpadd php in contact form 7php contact form libraryform backend phpcontact us page with phpcontact us php postcontact form with html and phpcontact form with php web devphp contact form advanced contact us form with phpcreate a setup form php contactphp contact form with validation free downloadhow to create a contact us page in phpcontact form 7 additional phphtml contact form with phpphp contact form script with validationcontact form inphpphp contact message contact form 7include contact form php filecreate working contact form using html css php 3dcomplete contact form in html phpphp tutorial contact formcreate a php contact form for htmlworking contact us using phpphp contct us page with database downloadhtml contact form without phphow to create a contact form using php and htmlinclude contact form 7 on phpformat contact form php htmlphp contact form with csscontact form php send easy php contact form script gratisworking contact form phpcontact form phpphp contact form sample with source codecss contact form with php contactos form phphow to create a workking contact form using phpmy contact form phpcontact form php post how to create a working contact form in phphow to create a contact form with php 2c html and csssending your contact us form phphtml php contact form examplecreate a contact form with html and phpcontact us form php mysqlcreate a working php formcontact form phphp form messagesave informoration in mobile contact in phpfree php 2cdatabase 2c and javascript contact form for websitecontact form php wpcontact form php workingphp simple contact fromcreate contact form html phpcontact phpcontact us html and phpcontact form php post or getcontact us html php contact us page phpcontact form code phpcontact form code in phpcontact form with phpjs contact form emailcontact us php scriptphp contact form doecontact me form serverworking contact us phpcontact formular php codephp contact form