Skip to content
HostClub
Get started

Hosting

PHP-based Form Mail (Feedback) Script

Using a PHP script, you may accept feedback from your website visitors and get the results emailed to you. You can use the sample script provided by HostClub and 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 on which you are incorporating this script.

Example:

If your domain name is yourdomain.com, then you would define the From email address as some-name@yourdomain.com.

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

You may use an email address such as Do_Not_reply@yourdomain.com.

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.

Note

In an attempt to keep a check on abuse from HostClub's Hosting Servers, the following conditions have been set for mail scripts on HostClub's Linux Hosting Servers:

  • The domain name in either the To or the From email address used in the script should be your domain name hosted with HostClub.

    Example: yourdomain.com is hosted with HostClub and yourotherdomain1.com and yourotherdomain2.com are hosted with some other hosting provider.

  • For mail scripts with the From email address as <user>@<server_hostname>, the To email address compulsorily should be an email address on your domain name hosted with HostClub.

    Example: yourdomain.com is hosted with HostClub with parent user yourdo & server name cp-00.webhostbox.net and yourotherdomain1.com is hosted with some other hosting provider.

    With the From email address as yourdo@cp-00.webhostbox.net:

Once the visitor provides feedback, you can display a message to the visitor thanking them for their feedback.

Sample Script


   <?
        $mailto="some-name@yourdomain.com"; 
        $pcount=0;
        $gcount=0;
        $subject = "Mail from Enquiry Form";

        $from="some-name@abc.com";
        while (list($key,$val)=each($_POST))
        {
        $pstr = $pstr."$key : $val \n ";
        ++$pcount;

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

        }
        if ($pcount > $gcount)
        {
        $message_body=$pstr;
        mail($mailto,$subject,$message_body,"From:".$from);
        echo "Mail has been sent";
        }
        else
        {
        $message_body=$gstr;
        mail($mailto,$subject,$message_body,"From:".$from);
        echo "Mail has been sent";
        }
?>

Need a hand with this?

Our team can do it with you. Contact support, open a ticket from your dashboard, or write to support@hostclub.in.

Cookie settings

Switch each kind on or off. You can change or withdraw your consent here at any time.

Necessary and functional

Keep you signed in, hold your cart, remember your country and currency, protect forms and payments, run the support chat and remember these choices. The site cannot work without them, so they are always on.

Always on

Analytics

Google Analytics counts visits and shows which pages are used, so we can improve them. Nothing is set until you switch this on.

Marketing

The Meta Pixel measures visits from our Facebook and Instagram ads. Leaving this off opts you out of the sale or sharing of personal information for advertising.