If You want to learn web design and developing from 0 to 100% then this blog is only for you Here you will be also find source code of many web design and web developing source codes. html,css,javascript,php,mysql & database tutorial, projects, source code files and many blogging tips. Best css tips etc. html css javascript amazing creations

Subscribe Us

https://affiliate.fastcomet.com/scripts/2wc9ym?a_aid=5f4ca944dcb6d&a_bid=49785082

Breaking

Post Top Ad

Wednesday, April 15, 2020

simple contact form page function in php with source code

SIMPLE CONTACT FORM IN PHP WITH SOURCE CODE




Simple contact foem in php developed by html css and php. Copy or download whoole files. You can use it in any website to make it more proffesional. Also used css to make it more bautifull. 

 full contact form tutorials in php for beginers

ABOUT THE SYSTEM

In this contact form function people can input their name, email id,phone nu and a message they want . The project container is properly responsive. People wouldn't be seen any deficulity to send their email. It is developes in php. This project files you can copy below the some lines.There is some validiation that makes it more proffeionaly realistic. You can also use it for your clienst also.

  
HOW TO RUN IT

to run this project you have to inastall first xampp server and after that make a folder in xampp/htdocs folder. You can name the folder as you want. We have to pest all the files of contact  page in the folder we made in xampp/htdocs/foldername.

1.index.php

make a file named by index.php and pest the files below under the lines.

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>contact form page</title>
  <meta content="" name="descriptison">
  <meta content="" name="keywords">
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

</head>

<body>
<?php
//link the file contactform.php
 include_once 'contactform.php';
?>
<!-----------------------------------htmlform------------------>
<div class="col-md-8">
 <!--Start Contact Us 1st Column-->
 <form action="" method="post">
  <input type="text" class="form-control" name="name" placeholder="Name"><br>
  <input type="text" class="form-control" name="subject" placeholder="Subject"><br>
  <input type="email" class="form-control" name="email" placeholder="E-mail"><br>
  <textarea class="form-control" name="message" placeholder="How can we help you?" style="height:150px;"></textarea><br>
  <input class="btn btn-primary" type="submit" value="Send" name="submit"><br><br>
  <?php if(isset($msg)) {echo $msg; } ?>
 </form>

</div> <!-- End Contact Us 1st Column-->

<!-----------------------------------htmlform------------------>

 <script src="assets/vendor/jquery/jquery.min.js"></script>
</body>

</html>

2. contactform.php

make an another file named by contactform.php In this file we write the php code.
In this page we will be order that to send message to to email id. the php code in this file are very simple. You would not be hard to understand this code. This code will capture the code
email, name, phone nu and messageand sent these data to your regarded email address. The process is very simple.

   <?php
// The contact Us Form wont work with Local Host but it will work on Live Server
if(isset($_REQUEST['submit'])) {
 // Checking for Empty Fields
 if(($_REQUEST['name'] == "") || ($_REQUEST['subject'] == "") || ($_REQUEST['email'] == "") || ($_REQUEST['message'] == "")){
  // msg displayed if required field missing

  $msg = '<div class="alert alert-warning col-sm-6 ml-5 mt-2" role="alert"> Fill All Fileds </div>';
  
 } else {
 $name = $_REQUEST['name'];
 $subject = $_REQUEST['subject'];
 $email = $_REQUEST['email'];
 $message = $_REQUEST['message'];

 $mailTo = "ravishmukkar@gmail.com";
 $headers = "From: ". $email;
 $txt = "You have received an email from ". $name. ".\n\n".$message;
 mail($mailTo, $subject, $txt, $headers);
 $msg = '<div class="alert alert-success col-sm-6 ml-5 mt-2" role="alert"> Sent Successfully </div>'; 
}
}
?>

note: Use your own email in your php file contaform.php. In that file get spot on red email change it in your own email address.

3. Link the contactform.php file
 link the the contactform.php file to index.php file. In this case you can use the code 
<?php
//link the file contactform.php
 include_once 'contactform.php';
?>
by this code you can link these files.

If you like this tutorial then please share it in your friends. You can read many more php, html, css, javascript and other programming language on my website. You can simpli download or copy my project files, And use it for learn. My code are very simple for beginers.


No comments:

Post a Comment

thanks for your comments

Post Top Ad