Friday, 24 August 2012

Installing MySQL on your computer.

Follow these steps carefully :


  1. Determine whether MySQL runs and is supported on your platform.
    Please note that not all platforms are equally suitable for running MySQL, and that not all platforms on which MySQL is known to run are officially supported by Oracle Corporation:
  2. Choose which distribution to install.
    Several versions of MySQL are available, and most are available in several distribution formats. You can choose from pre-packaged distributions containing binary (precompiled) programs or source code. When in doubt, use a binary distribution. We also provide public access to our current source tree for those who want to see our most recent developments and help us test new code. To determine which version and type of distribution you should use, see Section 2.1.2, “Choosing Which MySQL Distribution to Install”.
  3. Download the distribution that you want to install.
    For instructions, see Section 2.1.3, “How to Get MySQL”. To verify the integrity of the distribution, use the instructions in Section 2.1.4, “Verifying Package Integrity Using MD5 Checksums or GnuPG.
  4. Install the distribution.
    To install MySQL from a binary distribution, use the instructions inSection 2.2, “Installing MySQL from Generic Binaries on Unix/Linux”.
    To install MySQL from a source distribution or from the current development source tree, use the instructions in Section 2.11, “Installing MySQL from Source”.
  5. Perform any necessary postinstallation setup.
    After installing MySQL, read Section 2.12, “Postinstallation Setup and Testing”. This section contains important information about making sure the MySQL server is working properly. It also describes how to secure the initial MySQL user accounts, which have no passwords until you assign passwords. The section applies whether you install MySQL using a binary or source distribution.
  6. If you want to run the MySQL benchmark scripts, Perl support for MySQL must be available. See Section 2.15, “Perl Installation Notes”.
Instructions for installing MySQL on different platforms and environments is available on a platform by platform basis:
IBM i5/OS
For instructions on installing, starting, and stopping MySQL on i5/OS, see Section 2.10, “Installing MySQL on i5/OS”.

For newer users and members using windows . Here is the illustrated guide :
  • Download the free MySQL Server Community Edition. Be sure to download a version that includes a Windows Installer. Save the file on your Windows Desktop. If you’re not sure which version to select, download MySQL Installer for Windows.
  • Double-click the downloaded file. The installation file comes as a .zip file, so double-clicking it should initiate your unzipping software and take you to an archive folder.
  • Double-click Setup.exe. (It should be the only file inside your archive.) This will initialize the setup process.
  • Click Next. This begins the setup.
  • Click Custom > Next. This will enable you to specify where you want to install MySQL. If you have Apache installed in C:\Server, you will want to install MySQL in the same directory.
  • In the next window, highlight MySQL Server, and then click the Change.
  • In the next window, in the text box Folder Name, change the directory to C:\Server\MySQL\ exactly as it’s written here and then click OK.
  • On the next window, click Next. Now MySQL is ready to install.
  • Click Install. Wait while the program self-installs.
  • Click Skip Sign-Up and then Next. Once the installation is complete, you will be presented with a MySQL Sign-Up window. Skip signing up with MySQL for now since you can sign up later if you like. Once you’ve skipped, your new dialogue box should say Wizard Completed.
  • Configure MySQL. Leave the check box Configure the MySQL Server Now checked and click Finish.
  • Click Next. This will initialize the configuration setup.
  • Check Standard Configuration and then click Next. This is the default configuration and is recommended for most users.
  • Make sure Install As Windows Service and Launch the MySQL Server Automatically are checked, then click Next.
  • Create a root password. Type in what you want your root password to be and make sure Enable root access from remote machines is checked. Make sure you choose a difficult to guess password and 'write it down so you don't forget it. Click Next.
  • Click Execute. This will start the MySQL server. After MySQL has done its thing, click Finish.
  • From the Windows task bar, go to Start > All Programs > MySQL > MySQL Server 4.x > MySQL Command line client. This will open a command window asking you for a password.
  • Enter your root password and hit Enter. This should initiate the program.

This is how the typical installation should look like :














PHP Tutorial Lesson #12 Forms

Form Handling


The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts.


Example


The example below contains an HTML form with two input fields and a submit button:


<html>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>    


When a user fills out the form above and click on the submit button, the form data is sent to a PHP file, called "welcome.php".

"welcome.php" looks like this:


<html>
<body>

Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.

</body>
</html> 


Output could be something like this:


Welcome John!
You are 28 years old.  

The PHP $_GET and $_POST variables will be explained in the next sections.



Form Validation


User input should be validated on the browser whenever possible (by client scripts). Browser validation is faster and reduces the server load.

You should consider server validation if the user input will be inserted into a database. A good way to validate a form on the server is to post the form to itself, instead of jumping to a different page. The user will then get the error messages on the same page as the form. This makes it easier to discover the error.



The $_GET Variable


In Php, the predefined $_GET variable is used to collect values in a form with method="get"

Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.


Example


<form action="welcome.php" method="get">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>


When the user clicks the "Submit" button, the URL sent to the server could look something like this:

http://www.w3schools.com/welcome.php?fname=Peter&age=37

The "welcome.php" file can now use the $_GET variable to collect form data (the names of the form fields will automatically be the keys in the $_GET array):

Welcome <?php echo $_GET["fname"]; ?>.<br />
You are <?php echo $_GET["age"]; ?> years old!


When to use method="get"?


When using method="get" in HTML forms, all variable names and values are displayed in the URL.

Note: This method should not be used when sending passwords or other sensitive information!

However, because the variables are displayed in the URL, it is possible to bookmark the page. This can be useful in some cases.

Note: The get method is not suitable for very large variable values. It should not be used with values exceeding 2000 characters.





The $_POST Variable


The predefined $_POST variable is used to collect values from a form sent with method="post".

Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

Note: However, there is an 8 Mb max size for the POST method, by default (can be changed by setting the post_max_size in the php.ini file).


Example



<form action="welcome.php" method="post">

Name: <input type="text" name="fname" />

Age: <input type="text" name="age" />
<input type="submit" />
</form>

When the user clicks the "Submit" button, the URL will look like this:

http://www.mywebsite.com/welcome.php

The "welcome.php" file can now use the $_POST variable to collect form data (the names of the form fields will automatically be the keys in the $_POST array):

Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.


When to use method="post"?

Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.
However, because the variables are not displayed in the URL, it is not possible to bookmark the page.

The PHP $_REQUEST Variable

The predefined $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.

The $_REQUEST variable can be used to collect form data sent with both the GET and POST methods.

Example

Welcome <?php echo $_REQUEST["fname"]; ?>!<br />
You are <?php echo $_REQUEST["age"]; ?> years old.





PHP Tutorial Lesson #11 Functions


In this chapter we will show you how to create your own functions.

To keep the script from being executed when the page loads, you can put it into a function.

A function will be executed by a call to the function.

You may call a function from anywhere within a page.


Create a PHP Function


A function will be executed by a call to the function.


Syntax



function functionName()
{
    code to be executed;
}


PHP function guidelines:


  • Give the function a name that reflects what the function does
  • The function name can start with a letter or underscore (not a number)



Example


A simple function that writes my name when it is called:


<html>
<body>

<?php
function writeName()
{
    echo "Mohammed Kateregga";
}

echo "My name is ";
writeName();
?>

</body>
</html>




Output :

My name is Mohammed Kateregga



Adding parameters


To add more functionality to a function, we can add parameters. A parameter is just like a variable.

Parameters are specified after the function name, inside the parentheses.


Example 1


The following example will write different first names, but equal last name:


<html>
<body>

<?php
function writeName($fname)
{
echo $fname . " Kateregga.<br />";
}

echo "My name is ";
writeName("Mohammed");
echo "My sister's name is ";
writeName("Halma");
echo "My brother's name is ";
writeName("Abdulhameed");
?>

</body>
</html>

Output :

My name is Mohammed Kateregga.
My sister's name is Halma Kateregga.
My brother's name is Abdulhameed Kateregga.



Example 2




The following function has two parameters:

<html>
<body>
<?php
function writeName($fname,$punctuation)
{
echo $fname . " Kateregga" . $punctuation . "<br />";
}
echo "My name is ";
writeName("Mohammed",".");
echo "My sister's name is ";
writeName("Halma","!");
echo "My brother's name is ";
writeName("Abdulhameed","?");
?>
</body>
</html>

Output:

My name is Mohammed Kateregga.
My sister's name is Halma Kateregga!
My brother's name is Abdulhameed Kateregga?

Return values

To let a function return a value, use the return statement.

Example


<html>
<body>
<?php
function add($x,$y)
{
$total=$x+$y;
return $total;
}
echo "1 + 16 = " . add(1,16);
?>
</body>
</html>

Output:

1 + 16 = 17