PHP Classes

How to Implement a PHP Contact Form with a MySQL Database Using the Package Contact Us Page With Database in PHP: Show and process a contact form using a database

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-09-14 (Less than 1 hour ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
contact-us-page-with 1.0The PHP License5PHP 5, Databases, Global
Description 

Author

This package can show and process a contact form using a database.

It provides a script that can display a form to enter contact details like the username and email address.

Another script processes the form submission by executing a MySQL database query to insert the contact details in a database.

Picture of ganesh kavhar
Name: ganesh kavhar <contact>
Classes: 5 packages by
Country: Indonesia Indonesia
Age: ???
All time rank: 360155 in Indonesia Indonesia
Week rank: 195 Up3 in Indonesia Indonesia Up

Instructions

Example

<?php
include 'includes/db.php';

$name = $_POST['name'] ?? '';
$email = $_POST['email'] ?? '';
$message = $_POST['message'] ?? '';

if (
$name && $email && $message) {
   
$stmt = $conn->prepare("INSERT INTO messages (name, email, message) VALUES (?, ?, ?)");
   
$stmt->bind_param("sss", $name, $email, $message);

    if (
$stmt->execute()) {
        echo
"Thank you for your message!";
    } else {
        echo
"Something went wrong. Please try again.";
    }

   
$stmt->close();
} else {
    echo
"All fields are required.";
}

$conn->close();
?>
<br><a href="contact.php">Back to Contact Form</a>


Details

Contact-Us-page-with-database-in-PHP

ready to used PHP Dynamic contact us page with database


  Files folder image Files (5)  
File Role Description
Files folder imagecontact-us-php (3 files, 1 directory)
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (5)  /  contact-us-php  
File Role Description
Files folder imageincludes (1 file)
  Accessible without login Plain text file contact.php Aux. Form script
  Accessible without login Plain text file messages.sql Data Auxiliary data
  Accessible without login Plain text file submit_contact.php Example Example script

  Files folder image Files (5)  /  contact-us-php  /  includes  
File Role Description
  Accessible without login Plain text file db.php Aux. Auxiliary script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0