Archive for the 'php basic' Category

PHP $_GET and $_POST at php form

PHP $_GET
The $_GET variable is used to collect values from 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)
<html>
<body>
<form action=”welcome.php” method=”get“>
Name: <input type=”text” name=”name” />
Age: <input type=”text” name=”age” />
<input type=”submit” />
</form>
</body>
</html>
When we input Johnson at name and 30 […]

PHP Forms and User Input

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.
Form example :
<html>
<body>
<form action=”welcome.php” method=”post”>
Name: <input type=”text” name=”name” />
Age: <input type=”text” name=”age” />
<input type=”submit” />
</form>
</body>
</html>
The example HTML page above contains two input fields and a […]

Adding parameters in PHP Function

Adding parameters in PHP Function
Our first function writedate() is a very simple function. It only writes a static string.
To add more functionality to a function, we can add parameters. A parameter is just like a variable.
You may have noticed the parentheses after the function name, like: writedate(). The parameters are specified inside the […]

PHP Functions

Create a PHP Function
function is a block of code that can be executed whenever we need it.
Creating PHP functions:

All functions start with the word “function()”
Name the function - It should be possible to understand what the function does by its name. The name can start with a letter or underscore (not a number)
Add […]

The foreach Statement

The foreach Statement
The foreach statement is used to loop through arrays.
For every loop, the value of the current array element is assigned to $value (and the array pointer is moved by one) - so on the next loop, you’ll be looking at the next element.
foreach (array as value)
{
code to be executed;
}
Example
The following example […]