How To Crate A Dynamic Form With PHP Scripts Tutorial By Example Code



How To Crate A Dynamic Form With PHP Scripts Tutorial By Example Code
 (381) dminister a web business
How To Crate A Dynamic Form With PHP Scripts Tutorial By Example Code
Post Description:
Post Tags: how, to, crate, a, dynamic, form, with, php, scripts, tutorial, by, example, code
This Post Has Been Viewed 2216 Times Since Tue Dec 05, 2006 1:29 pm Posted By webmaster with 3 replies
How To Crate A Dynamic Form With PHP Scripts Tutorial By Example Code
A greate thing about PHP is ability to display dynamic content to web pages. If you don't already have PHP hosting, please visit our friends at www.webune.com they have great PHP hosting.

One way to create interactive web pages is to ask for user input. The way to get the information from a user is through a web form. once the user submits the information, it then process (by PHP) and depending on what process you have programmed, it displays the results.

In my example, i will be asking for a user's name, once the user submits their name, i will display a friendly rely with their name.

for example, the page will ask for the user to enter their name, and when they submit the form, the form will be process and depending on what the user submits, it will give a message like: Hi username! PHP is great!

So here is the code to make it happen:

1. copy and paste the following code into your editor, you can use notepad i f you don't have a web editor:


     Code:
<?php
#############################################################
############# TUTORIAL BY Wallpaperama.com #########
#############################################################
function form($prompt){ ?>
<form action="<?php $_SERVER['REQUEST_URI']; ?>" method="post">
<p><?php echo $prompt; ?>
<input name="user_name" type="text" size="25"><br /><br />
<input type="submit" name="submit" value="Submit">
</p>
</form>
<?
return;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Creating Dynamic PHP Pages with Form By Wallpaperama.com</title>
</head>

<body>
<h1 align="center">Dynamic Form Tutorial by <a href="http://www.wallpaperama.com">Wallpaperama.com</a></h1><hr />
<?php
if($_POST['submit']) {
if($_POST['user_name']) {
echo '<h1 align="center">Hi '.$_POST['user_name'].', PHP is Great!!</h1><br /><div align="center"><a href="'. $_SERVER['REQUEST_URI'].'">Try Again</a></div>';
}
else {
echo form('<strong style="color:#FF0000">ERROR: Please Provide A Name</strong>');
}
}
else {
echo form("Please enter your name:");
}
?>
<div align="center">
<p align="left"><a href="http://www.wallpaperama.com/forums/how-to-crate-a-dynamic-form-with-php-scripts-tutorial-by-example-code-t565.html">&lt;&lt; Go Back To Forums</a></p>
<p align="left">&nbsp;</p>
<p align="left">If you have found this simple and short tutorial helpful, we would like to ask you to please link to our website at <a href="http://www.wallpaperama.com">http://www.wallpaperama.com</a> by linking to Wallpaperama you will help us make tutorials like this one more easier to find by others who are looking for answers like this one. Thank You - Wallpaperama Team. </p>
<p>hosting provided by <a href="http://www.webune.com">Webune</a></p>
</div>
</body>
</html>


2. Next you want to save this file as dynamic-php-form-tutorial.php and uploaded to your site and open it with your browser, if you have PHP in your hosting, you should see a page like our demo below, otherwise, you many not have PHP in you hosting plan, if you don't you can visit our friends at www.webune.com and sign up for a PHP hosting pacakage.

CLICK HERE FOR DEMO

IF you've found this tutorial helpful, we would appreciate a link back to wallpaperama from your home page.

Thank You

Wallpaperama Team

Leave Your Comments     [ dejar commentarios ]
  * Name     [nombre]

  * eMail (will not be published)     [coreo electronico]

* Enter Your Reply or Comments:    [commentarios]


Add Picture To Comments         [incluir foto]
YES NO             upload
Receive Replies on my Comments (An email will be sent to you when someone replies to your comments)

     

Comments and replies About How To Crate A Dynamic Form With PHP Scripts Tutorial By Example Code




:: 1 :: #45248 - Reply By kavi On Wed Mar 12, 2008 11:43 pm
the form is working fine. but i need to send the echo information as a mail.
is there is any solution.....
:: 2 :: #49110 - Reply By hh On Mon Apr 07, 2008 10:07 pm
hai..hello world!!!
:: 3 :: #52850 - Reply By mesay getachew On Tue May 06, 2008 3:28 am
as long as u can!
love is sweet!
when two lips are meet
love is complete!