• php RSS Feed

    by Published on 02-27-2010 01:47 PM
    1. Categories:
    2. Php

    When you are writing programs you will find that sometimes you need to perform code only if something has happened, in the previous form post article we used an if statement to get the information from the form only if a used had submitted the form, this stopped the script from trying to get blank form information.

    This shows how we can use conditional statements within scripts to specify when certain code should be run depending on the outcome of a condition that we set.

    The main conditional statements in php are:
    • If
    • Else
    • Switch


    The if Statement can be used in the following format:

    PHP Code:
    <?php
    if (condition)
    {
         
    // If condition is true Perform this code
    }
    else
    {
         
    // Else perform this code
    }
    ?>
    The above example shows how the if statements works, if the condition inside the brackets is met then the code is run with the {} brackets, if that condition is not met then the code in {} brackets after the else is run.

    Sometimes we need to use multiple if statements because there is more than one condition, for this we can combine if and else to use the elseif statement, this works in the following: ...
    by Published on 02-26-2010 09:05 PM
    1. Categories:
    2. Php

    Todays article will guide you through the process of how we can use php to get information from forms when they are submitted. To do this in php we use the post function, this means when a form is submitted with the post method then values are stored and available for use.

    These values are hidden from anyone else which is good for security as opposed to the php get function. There are also no limits on the amount of data that can be stored at once with post so it is more useful for longer user inputs such as comments in text boxes foe example.

    The only limit imposed with the post function is an 8mb maximum size for the data, this is set by default in php.ini and can be changed if needed when uploading larger amounts of data or files.

    Let's create a file called testPost.php to test this new method of getting information from forms:

    HTML Code:
    <form action="testPost.php" method="post">
    Test Field - <input type="text" name ="testField" />
    <input type="submit" value="submit" />
    </form>
    This is ...
    by Published on 02-20-2010 06:40 PM
    1. Categories:
    2. Php

    The next step to learning php is beginning to pass content into your page, this can be done via variables set within the url. The values of these variables are also present within the url.

    To set a variable and it's value in a url you would do the following:

    Code:
    http://www.domain.com/test.php?variable=content&variable2=content2
    The ...
    by Published on 02-08-2010 10:56 PM
    1. Categories:
    2. Php

    This tutorial will teach you how to store information as variables and then use these throughout the page to generate content. In php variables are shown by a dollar sign followed by the name of the variable. So if you wished to have a variable named default then it would be written as $default.

    Variables are one of the keys to learning how to create dynamic websites, let's see how we can generate page content by simply creating a few variables.

    From the first php tutorial you should know how to implement php code and how to show basic messages on screen to the user, above described how a variable is shown.

    Here is an example of how we can set our first variable in php:

    PHP Code:
    <?php

    $testVariable 
    'Here is my first variable';

    ?>
    The above sets the sentance ...
    by Published on 02-08-2010 07:42 PM
    1. Categories:
    2. Php

    Today's article will give you a brief introduction to php, This language is currently one of the most used throughout the internet and is very useful to know because you can create very large dynamic sites with very little code.

    A dynamic site means that code is used to create content automatically, this is the opposite to static html pages where you put the content into the page/file. In php you tell the file what content to get and where to get it. You can also control which information it put into the file to get a different output.

    php is a server side language so it runs on the server before it reaches the user, this means the user will not see the code. Another advantage of php is it's abilities to interact with databases, this means you can store information from user input and create content such as forums, members and comment forms.

    Let's have a look at how php code works.

    HTML Code:
    <html>
     <head>
    	<title>PHP Test</title>
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-625990-23']);
      _gaq.push(['_trackPageview']);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        (document.getElementsByTagName('head')[0]
    ...

  • Stay Updated