Script Contact Form

from coursesweb.net

With this script (that uses PHP and AJAX) you can add a simple Contact Form in your website, through which the visitors can send messages to the administrator e-mail address directly from site.
The received email contains: the Name and IP of the sender, his /her E-mail address, the Subject, and Message added in textarea in the form.
The Contact Form can be added in both "*.html" or "*.php" files, but the web server must run PHP.
- The form is valid XHTML and has antispam verification code. The Ajax technology avoids resending data in case of refresh.
The script also works if the user has disabled JavaScript. As anti-spamm and re-sending data additional protection, the PHP script blocks the user to send another email in the next 5 minutes.
The script sends the message with the PHP mail() function, but if the server on which your website is hosted doesn't have a mail server, you can easily set to send the message via a GMail account; in this case you must have a GMail account, it's free and can be created at the page: GMail.

Installation:

1. Open the "contact_mail.php" file and change the value of the $to variable:
$to = 'your_email@domain.mail';		 - Replace the 'your_email@domain.mail' with the e-mail address to which you want the message to be sent.
- If you want to use the SMTP from GMail, set the value 1 at GMAIL constant (line 13 in the "contact_mail.php" file).
- Add your GMail address at the GMAIL_USER constant, and add the password for this e-mail at GMAIL_PASS.
- When using Gmail, the messages will be sent to the e-mail address added in the "$to" variable, but via your GMail account.


2. Copy the "contact_mail.php", "contact.js", and the "sendmail" folder with all its files on your server (in the same place where you have the file in which you want to include the contact form):.
3. Add the following HTML code in the "*.html", or "*.php" file in which you want to display the contact form (as you can see added in the "test.html" file):
<form style="width:350px; background:#e8e8fe; text-align:center;" id="cform" method="post" action="contact_mail.php">
 <h3 id="fc_titlu"><u>Send a message</u></h3>
 <label for="nume">Your Name: &nbsp;</label><input type="text" name="nume" id="nume" size="18" maxlength="40" /><br />
 <label for="email">Your E-mail:</label> <input type="text" name="email" id="email" size="18" maxlength="58" /><br />
 <label for="subject">Subject: &nbsp; </label> <input type="text" name="subject" id="subject" size="28" maxlength="70" /><br />
 <label for="message">Your message: (<i>maximum 500 characters</i>)</label><br />
 <textarea name="message" id="message" cols="35" rows="6"></textarea>
 <input type="hidden" name="anti_spam" id="anti_spam" value="" /><br />
 <a href="http://coursesweb.net/" title="Free WebMaster Courses" target="_blank" style="font-size:8px; color:#eaeafe;">coursesweb.net</a><br />
 <i>Verification code:</i> <b id="codas"> </b><br />
 Add the verification code: <input type="text" name="anti_spam1" id="anti_spam1" value="" size="7" maxlength="7" /><br />
 <input type="submit" value="Send" id="csubmit" />
</form>
<script type="text/javascript" src="contact.js"></script>

- This script is free, you can change and use it as you want, but does not provide support or personal modifications.

It was successfully tested with a general configuration on localhost with XAMPP
. If on other systems does not work properly, depends on their configuration.

Respectfully,
Marius