php


  • (PHP) Simple e-mail contact form.

    A simple contact form, just for reference. Will add more info later on… [php] <?php if (isset($_POST[‘submit’])) { $name = $_POST[‘name’]; //name of sender $email = $_POST[’email’]; //e-mail of sender $email = stripslashes($email); $subject = $_POST[‘subject’]; //e-mail subject $subject = str_replace(array("\r\n","\r","\n"), "", $subject); //remove any linebreaks to keep from code injections $message = $_POST[‘message’]; //…

  • A couple of principles when learning how to code.

    Principle 1. Always have a clear image of what you want to do BEFORE you start writing your code. Then break it down in logical instructions – making an algorithm.  An algorithm is a step by step instruction on how to solve a specific problem. You might think of it as a recipe. If you…

  • Convert MySQL timestamp to PHP date

    If you save your date in the format of timestamp in your MySQL database, and want to output it like this: [php] $result = mysql_query("SELECT * FROM articles"); $row = mysql_fetch_array($result); $date = $row[‘timestamp’]; echo $date; [/php] Your date come out looking something like this: 2011-01-30 20:54:12 So it’s formated like YYYY-MM-DD HH:MM:SS But what…

  • (PHP) How to make a simple gallery

    This is just a VERY basic gallery that you can modify to suit your needs. For example you could add columns in the database and store more info about the images (date, size, tags etc.). You could very easily make the output use Lightbox or similar images viewers. And you could of course do a…