PHP-based Form Mail (Feedback) Script

Using a PHP script, you may like to add contact us form for feedbacks on your website and get the results emailed to you.

For our customers using our Linux hosting service @ ITKarobar.Asia, the sample script is given below so that you can tweak it a bit to suit your requirements.

You would need to change the email address in the field $from to any email address on the domain name (same hosted website) on which you are incorporating this script.


If your domain name is, then you would define the From email address as

This email address need not be existing on the mail server of; however, the domain name in the $from field has to be yours.

You may also use an email address such as

The value in the $mailto field needs to be changed to the email address, where the email containing the data submitted through the form needs to be delivered.

Once the visitor provides feedback, he/she can then be re-directed to another page on your website. In order to achieve this, you need to mention the path to the HTML file in the $file field in the script. Alternatively, you can display a message to the visitor thanking him/her for the feedback. Such messages can be displayed in a new page like thanks.htm. Such a page can also contain other information as deemed necessary.

Sample Script


        $subject = "Mail from Enquiry Form";

        while (list($key,$val)=each($_POST))
        $pstr = $pstr."$key : $val \n ";

        while (list($key,$val)=each($_GET))
        $gstr = $gstr."$key : $val \n ";

        if ($pcount > $gcount)




In an attempt to keep a check on abuse from our Hosting Servers, the following conditions have been set for mail scripts to work on the above mentioned Linux Hosting Server:

  • The domain name in either the To or the From email address used in the script should be your domain name hosted at this server.

    Example: is hosted at this server and and are hosted with some other hosting provider.

    • The mail will be sent if

      • the From email address is and the To email address is,


      • the From email address is and the To email address is

    • The mail will not be sent if the From email address is and the To email address is

Was this answer helpful?

 Print this Article

Also Read

How to generate/download a full backup from Cpanel

A full backup is a backup of all of your files, e-mail, databases, etc. To run a full backup, you...

Guiding bingo search engine

Telling the Bing Network How Often to Crawl Your Website   By default, the Bing Network sets...

Defining Google crawling rate

Telling Google How Often To Crawl Your Website Google uses sophisticated algorithms for...

Cpanel Video Tutorials

Creating an email account Creating an FTP account Accessing webmail Adding an addon domain...

When wordpress website overuses CPU resources.

Excessive CPU resources usage is usually caused by inefficient third party themes and plugins...

Powered by WHMCompleteSolution