Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: PHP Contact Form Tutorial

Let users send you feedback about your website

Tutorial Details:

PHP/MySQL and Visual Basic with easy online tutorials

If you would like to know how i can use the variables above, then checkout the php section for "How to use forms".

Now, all of that information is going to get sent to the contact.php. There, we need to sort all of the information out first, and then we need to prepare for the mail();

PHP Code
//your email address
$site_email = "contactform@yourwebsite.com" ;
//the info will come in as $_POST
$name = $_POST [ 'name' ];
$email = $_POST [ 'email' ];
$message = $_POST [ 'message' ];
if(!empty( $name ) && !empty( $email ) && !empty( $message ))
{
$subject = "Contact Form" ;
$headers = 'From: ' . $email . "rn" ;
$message = wordwrap ( $_POST [ 'message' ], 65 );
//send the email
$mail = mail ( $site_email , $subject , $message , $headers );
if( $mail == true )
{
echo "Mail Successful!" ;
}
else
{
echo "Mail Failed" ;
}
}
else
{
echo "Please fill in all the fields" ;
}
?>

Everything above its pretty self explanitory. The function wordwrap(); simply count the letters, and if it gets above 65, then a new line will be started.
The headers that were added to the mail() function, then add the different headers to the email. This can include things like Bcc, Cc and Reply to addresses.

In the above email, it will strap the from header as the email address that was provided on the forum.

Then the conditional checks to see if the mail was successful when the mail was attempted to be sent.

This script is an easy way to set up a quick and easy method to let your users send you some feeback. Copy and Paste =D


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
PHP Contact Form Tutorial

View Tutorial:
PHP Contact Form Tutorial

Related Tutorials:

Boost Struts with
Boost Struts with XSLT and XML
 
JXMLAppKit 2.0
JXMLAppKit is a pure Swing java framework for editing an XML document with multiple XML editors.
 
The JDBC RowSet Implementations Tutorial
In "The JDBC RowSet Implementations Tutorial," you will look at how to use the standard JDBC RowSet implementations specified in JSR-114.
 
Jeff Schmitt's JDBC Page
This tutorial assumes you are using the MySQL database and the GWE JDBC drivers. The host computer is triton.towson.edu.
 
Internet & Intranets: Java Servlets
What are servlets? "Servlets are modules that extend request/response-oriented servers, such as Java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to upd
 
Servlet Essentials
This document explains the concepts of Java Servlets and provides a step-by-step tutorial for writing HTTP Servlets with complete source code for the example Servlets. The tutorial and the other chapters cover all facets of Servlet programming from a ...
 
FreeMarker FreeMarker 2.3.1 an open-source HTML template engine.
FreeMarker provides an easy way to get data from Java servlets into Web pages, and helps you keep graphic design separate from application logic. To use it, you encapsulate HTML in templates.
 
JSP Tutorial
This Tutorial is for beginners in the Java Server Pages Technology
 
JavaServer Pages Technology - Documentation
Sun's tutorial for Java Server Pages that provide a good introduction to design web pages with JSP.
 
Tag Libraries Tutorial
This tutorial describes how to use and develop JavaServer Pages tag libraries. The tutorial assumes that you know how to develop servlets and JSP pages and are familiar with packaging servlets and JSP pages into Web application archives.
 
Welcome to the Apache Struts Tutorial
This is the complete Struts Tutorial. Explains ActionForm Action Class Validation Framework.
 
Java RMI Tutorial
This is a brief introduction to Java Remote Method Invocation (RMI). Java RMI is a mechanism that allows one to invoke a method on an object that exists in another address space.The other address space could be on the same machine or a different one. The
 
Getting Started With the Mobile 3D Graphics API for J2ME
This tutorial introduces the Mobile 3D Graphics API for J2ME, JSR 184. The article presents an overview, potential application areas, the differences between JSR 184 and two related APIs, the classes in the new optional package, the programming model, the
 
Device Driver Tutorial for the Solaris OS
Make your hardware work with the Solaris OS on x86 or SPARC architectures. If you are a beginning Solaris kernel programmer, start with this new tutorial on docs.sun.com.
 

Linux Hosting Plans Proxima Web-Hosting Our basic hosting packages include support for a wide variety of web technologies, backed by instant account management with our Personal Control panel. With our guaranteed
 
Introduction to the JSP Java Server Pages
Introduction to the JSP Java Server Pages Welcome to JSP Section Introduction To JSP Java Server Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database
 
Beginner to advance guide to the Apache Struts
Beginner to advance guide to the Apache Struts The Complete Apache Struts Tutorial This complete reference of Jakarta Struts shows you how to develop Struts applications using ant and deploy on the JBoss Application Server. Ant script is provided
 
Struts Validator Framework Tutorial with Example
Struts Validator Framework Tutorial with Example Struts HTML Tags Struts Validator Framework This lesson introduces you the Struts Validator Framework. In this lesson you will learn how to use Struts Validator Framework to validate the user
 
Web Hosting Guide. What is Web Hosting Plan?
Web Hosting Guide. What is Web Hosting Plan? What is Web Hosting Plan? Web hosting plan is the different plans provided by Hosting Companies for hosting your web site. Web hosting plans include the storage limit, bandwidth, access to server
 
Getting Started With the PIM APIs
This article provides a code-intensive introductory tutorial to Personal information management (PIM) APIs, JSR 75.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.