php tutorials, php form validation
Archive Tutorials
Discussion Home
Login / Register

Board List
PHP programming
General

Links
How to save gas 25% or more
Marshall Reddick
Network Marketing Forums
Income Tax Help
Lose 10 Pounds in 3 Weeks
PHP Forum Script
Online Contest

Learn PHP in 47 hours!

Back to PHP programming

Search

How to create a form in php How to create a form in php

How to create a form in php

by uclaboyz on Fri 02/24/2006 10:57 AM

It is not diffult at all to create a form in PHP.  To know how to create a form in PHP, you must know the HTML code for the form.  You must not be confused that PHP is a server side scripting language - meaning that your PHP file is run on the web server, and then the output of the file is passed to the user's browser. 

For example, the following HTML code is a simple form with a textbox and a submit button: 

<html>

<head>

<title>Form output by PHP</title>

</head>

<body>

<form method="POST" action="index.php">

  <p>

  <input type="text" name="T1" size="20">

  <input type="submit" value="Submit" name="B1">

  </p>

</form>

</body>

</html> 

Outputting the above form in your PHP form is no simpler than using the echo function.  In fact, you do not even need to use the echo function to output any HTML code. 

If you PHP file, say index.php, contains no PHP code at all, then it will simply be treated as a HTML file. 

So, to display the HTML form in the example above, you can do something like this: 

<?
// you can write any PHP code in here
?>
<html>

<head>

<title>Form output by PHP</title>

</head>

<body>

<form method="POST" action="index.php">

  <p>

  <input type="text" name="T1" size="20">

  <input type="submit" value="Submit" name="B1">

  </p>

</form>

</body>

</html>
<?
// more PHP codes here
?> 

So it is important to understand that what seperates PHP code from HTML code in your PHP file is the identifier <? and ?>  Everything that is enclosed in <? ?> will be treated as PHP code.  PHP code will be processed by the web server before it is displayed on the user's browser.

[Reply] [Back to Top]

manipulate data in a form

by sita on Sat 05/06/2006 02:42 AM

i have wrote the html code for form and submitted. its working. but i am not getting the form values in my php code. why?

[Reply] [Back to Top]

how are you referring to your input?

by uclaboyz on Sat 05/06/2006 10:15 PM

You can refer to the form input this way: 

$_POST["name"] 

Where "name" is the name value of the form input field.

[Reply] [Back to Top]

© Copyright 2006-2007.  All Rights Reserved. Site hosted by Small Business Web Design
how to start a blog | parenting tips website | Passive Income | baby websites