Simple PHP Contact Us Form

I’ve noticed a simple contact us form is something that a lot of people frequently look for online, however many of the current solutions/examples out there are quite complex, ‘bloated’, and can also be, in some cases, complete overkill.

So here’s a simple PHP-based contact us form which makes use of one single PHP file to handle both the output of the form, the output of the thank you message, and the email processing.

You are more than welcome to copy and use this code both in a commercial and non-commercial sense.

  1. <?php
  2. if($_POST['contactus']) { // if user submitted the form, then
  3. extract($_POST); // extract form contents and assign them to variables
  4. $name = htmlentities($name);
  5. $subject = htmlentities($subject);
  6. $msg = htmlentities($msg);
  7. $msg .= “Name: {$name}”;
  8. mail(‘recipient-email@domain.com’,$subject,$msg);
  9. }
  10. ?>
  11. <html>
  12. <head>
  13. </head>
  14. <body>
  15. <form name=”contactus” action=”<?php $_SERVER['PHP_SELF']; ?>” method=”POST”>
  16. Name: <input type=”text” name=”name” /><br />
  17. Subject: <inpout type=”text” name=”subject” /><br />
  18. Message: <input type=”textarea” name=”msg” /><br />
  19. <input type=”submit” name=”contact” value=”Contact us” /></form>
  20. </body>
  21. </html>

It is crucial to consider that the automatically created variables, which were extracted from the $_POST array, are the same as the name of each input element.
For example:
<input type="text" name="xyz" id="xyz_input" />

Would result in a variable $xyz being created, which would be assigned the value of xyz_input.value

The htmlentities() functions are used to convert any HTML tags within the input boxes to the HTML character code equivalents, to help prevent unsanitized data from being processed. Note: Typically, using htmlentities alone is not enough – it’s strongly suggested that you use Javascript or PHP to validate the input fields prior to processing. In Web Development, always consider that someone out there may enter incorrect and/or potentially malicious data into your forms (google SQL injection, etc and you’ll see what I mean).

Obviously, if your web host doesn’t support the mail() function, you might have to consider sending your mail via an SMTP provider, using an SMTP class. There are plenty of these on the internet, however this SMTP class seems quite promising. (I haven’t used this, however – so any feedback would be greatly appreciated.)

SnipeMe

SnipeMe is an easy to use eBay bid sniper, aimed to automate the eBay bidding process.
You simply enter the eBay Item number (found on the eBay item page, to the right, underneath the Seller information box), i.e. 170550521897; The price which you want to bid; the Date in which you want to bid; and the time that you want to bid.

It is best to set the Bid time no closer than 30 seconds to the auction’s end time. The Bid time is entered in 24-hour time format.
SnipeMe Main Window

Download:Download SnipeMe v1.0

ExifyMe

ExifyMe helps to simplify some of the functionality offered in the command-line application, Exiftool, by offering an easy to use GUI.

You simply select the modified image, and the original, unmodified image, and click Restore – and the EXIF data of the modified image will automatically be restored to what it originally was, and a backup file (saved as .original) is automatically created, so as to not cause any data loss.
EXIFyMe Main screen

Just as an example of what EXIFyMe can do, here’s an original image:
http://www.flickr.com/photos/xtrasimplicity/5117254299/

Post-processed with Photoshop, without using ExifyMe
http://www.flickr.com/photos/xtrasimplicity/5117254295/

Post-processed with Photoshop, with EXIFyMe
http://www.flickr.com/photos/xtrasimplicity/5117865162/

Note: The difference is in the EXIF data view

Download: Download EXIFyMe 1.0 (~3.3MB)
Mirror:
Download via Brothersoft
Although this application is released for free, Donations are appreciated, as they cover development costs, and help support the further development of this software.