How to use HTML Form in PHP

Monday, August 17, 2009 · Posted in ,

Form is one of the most important tool in making and designing a website or web application. Through the use of form you can send any values to another page. try to observe the given sample code below.



HTML Code:




<html>

<head>

<title>Title goes heretitle>

head>

<body>



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



<label>Name:label><input type="text" name="name"><br/>

<label>Age:label><input type="text" name="age"><br/>

<input type="submit" name="btn_submit">



form>



body>

html>



The page contains two input fields and a submit button in which it has a type of text and a name of name and age.



Sample Output 1:


and if we were going to run the code above and then this would be the output of the code that we have made above in which it has a two input fields in which this field will be use in getting the value that comes from the user and also the submit button.



HTML with PHP Code:

<html>

<head>

<title>Title goes heretitle>

head>

<body>



Welcome echo $_POST['name']; ?>.<br/>

You are echo $_POST['age']; ?> years old.



body>

html>

and this would be our another page in which it has a filename of welcome.php. As you notice that its filename is being put at the from action so that when the user click the submit button and then it pass the value the being input by the user through the use of the form and then the form will past the value the the welcome.php and will directly display the value in the page. As you notice in the code we embed the php code in the HTML code. In this code we have the opening and the closing PHP tag. The variable array $_post["name"]; and $_post["age"]; are the two variables that holds the value that came from the form and this variable also uses to display the value that being input in the form.


Sample Output 2:








Goodbye and Thank You Tita Cory

Tuesday, August 04, 2009 · Posted in

Last Saturday morning, I was really shock when I first heard the news that our dearest former President Corazon Aquino died, because of the colon cancer. I can’t really imagine how it comes. My 9 years old cousin asked me of who Cory Aquino is? And I thought her that she was the mother of the first EDSA revolution and the mother of the democracy, and I asked her. “Why Filipino did called her as the mother of EDSA and democracy?” and she said “YES”. I told her that Cory Aquino called as the Mother of EDSA and the mother of democracy it is because she is the one who brought to us the type of government which is the democracy which literary means FREEDOM.

I am only 19 years old boy and a student and even me I didn’t seen and witness the First EDSA Revolution but I know what Cory had done to our country during that time. So people of the Philippines we should not have to waste what our beloved former President done. Let’s remember always of what Cory had made to us and who give us freedom. So Thank you very much Tita Cory and we are lucky and grateful of all you have done for us and to our country. Cory Hindi ka Nagiisa sa Lahat ng Laban mo.

So lets all take care of the legacy of our beloved former President. This Democracy and freedom that we are enjoying now lets take care of it.

How to use While Loop in PHP

Friday, July 03, 2009 · Posted in

This is a tutorial on how to use a while loop in a PHP. The output will be the same if you were going to use a for loop, the only difference is only the code itself and especially the concept of each loop and how this loop performs its action when the programmer run his/her program. Below is a sample illustration on how to code while loop in PHP.

PHP Code:

<?php
$var_x = 1;
while($var_x <= 5)
{
echo "Number: ".$var_x."<br/>";
$var_x++;
}
?>
From the given codes above as you can observe we really put the PHP opening tag and at the end also we put the PHP ending tag, so that every time we execute the program it would not return any error. Because sometimes programmers for got to put the opening and closing tags that might be the cause of some errors sometimes in a application. After the opening tag we initialized our variable with the value of one. So, now the variable $var_x has now a value of 1. Then on the next line is the while loop itself, inside the while loop we put variable again and this time we put an operator to determine of the value is less than or equal with 5 only. Next is to print the value of the variable and after is to increment our variable. The purpose of $var_x++ is to increment the value of the variable each time the loop executes until it reach the desire value which is 5. Regarding with the open and close braces you can omit it but it is mostly required especially if you are following some coding standards but it is recommended that you have to put braces for you to be able to know where does your statement starts and ends. Below is the sample output of the above code.

Sample Output:
You can try this with your own. If there are some comments or questions about this article just CLICK THIS LINK to be redirected to the forum page.

What is PHP?

Tuesday, June 30, 2009 · Posted in

PHP stand for PHP Hypertext Preprocessor. PHP also known as a recursive acronym would you want to ask why recursive? It is because recursive is an acronym in which the first letter of the first word represented but the acronym is the acronym itself.

PHP also known as an open source, server side and a HTML embedded scripting language. When we say embedded scripting language it is a language in which it is a kind of language in where HTML and PHP codes can be combined. It is a server side client, because PHP is being process in the server and not in the browser. E,g A user request a page. As you notice that when you view source the page and then only pure HTML code are you going to see, it is because PHP process first in the server and the server will only send to the user or to the client the HTML form.

How to create a simple HTML Table

Wednesday, May 27, 2009 · Posted in

In this article we will know how to create a simple table in HTML without using any CSS but HTML tag attribute only. Try to observe the given code below and its output and then try it. If you experience some bugs or error in executing the codes, send me message through comments for me to be able to fix the program and sample below. Thank you.

HTML Code:

<html>
<head><title>Your title goes here</title></head>
<body>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="50" align="center">OTY.</td>
<td width="150" align="center">Description</td>
<td width="100" align="center">Unit Price</td>
<td width="100" align="center">Total</td>
</tr>
<tr>
<td width="50" align="center">3</td>
<td width="150" align="center">Noodles</td>
<td width="100" align="center">15.00</td>
<td width="100" align="center">45.00</td>
</tr>
<tr>
<td width="50" align="center">10</td>
<td width="150" align="center">Ballpen</td>
<td width="100" align="center">8</td>
<td width="100" align="center">80</td>
</tr>
</table>
</body>
</html>

Sample Output:

How to insert images in HTML

· Posted in

In this tutorial we will know on how to put and display an image on your HTML. Simply , first you have to choose an image and let be the width and the height of the image is 100x100 pixels.


HTML Code:


Output:

This is the result of the HTML that we made in the upper part of this tutorial. Just follow the HTML in the upper part of this article and you will surely come up with this result.

Powered by Blogger.