ALC211K - Advanced Digital Portfolio


PHP Contact Form

← References

  1. Download the contact form files.

  2. Unzip the files. You'll find file called "contact_form.php" and a folder called "include" which contains a file called "recaptchalib.php".

  3. Move the files to the local copy of your website so that "contact_form.php" is in the root of the site and "include" is a folder within the root, containing "recaptchalib.php", just as it did in the zip file.

  4. If you haven't already done so, create a page, based on your site template called "contact.php" or similar.

  5. Open "contact_form.php" with Textwrangler. Select and copy the CSS styles between where it says /* START CSS COPY/PASTE */ and /* END CSS COPY/PASTE */.

  6. Edit "contact_form.php" in Dreamweaver in Code view. Select and copy all the content between where it says "<!-- Begin Copy / Paste -->" and where it says "<!-- End Copy / Paste -->".

  7. Open the file that contains your CSS with Textwrangler and paste the styles into your CSS. Save and upload this file.

  8. Paste this content into the content area of your "contact.php" file in Textwrangler or Notepad++.

  9. Go to http://recaptcha.net/ and sign in using your google credentials (may require gmail account).

  10. Click "+ Add a New Site", enter your domain (without the www) and click "Create Key"

  11. Keep the browser page with your Public and Private keys open. You'll need them.

  12. Return to editing "contact.php". Here, change $Recipient and $Subject to be what you want them to be. Make sure the email you enter as $Recipient is the email you want messages sent to.

  13. For $privatekey, replace "REPLACE-WITH-PRIVATE-KEY-FROM-RECAPCHA-SITE" with your actual private key.

  14. Further down the code, where you see some javascript, replace "REPLACE-WITH-PUBLIC-KEY-FROM-RECAPCHA-SITE" with your actual public key.

  15. If you wish, edit the parts that say "Message successfully sent" and "Thank you for your correspondence! I will reply at my first convenience." to say what you would like them to say after someone sends a message.

  16. Upload "contact.php" and test the page.

← References