Wallpapers Forums Login

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.

[url=http://www.wallpaperama.com/tutorials/dynamic-php-form-tutorial.php]CLICK HERE FOR DEMO[/url]

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

Thank You

Wallpaperama Team
yoga Tue Feb 07, 2012
This is example is very easy..LOL hahahaa
Noname Tue Jun 07, 2011
you call this dynamic update? You're a fool. Dynamic update is called when the page elements are updated without having to reload the page and it can never be done with pure php. Ajax is required in addition with php to gain dynamic content.
Maurice Thu May 05, 2011
how to do the same for an sms contact dynamic form?
Chris Tue Mar 01, 2011
That's pretty cool.
prativa Tue Jul 20, 2010
20-565-baby.jpg|5212
i wanna a dynamic email form and after sending mail it will send another mail like thank u for registering
edas Sun Mar 28, 2010
esta muy bien escrito me gustaria saber mas de tu tutoriales
Lutsam Tue Mar 16, 2010
how do you align an echo ouput form in the middle of an html page
kamal Tue Mar 09, 2010
i tried this on my computer but it doest work. how do i install php on my windows computer. i would like to learn all this because i want to start my own web page with dynamic content. i am used to using HTML because i took a class in college and my next step is either php or javascript

which do you recommend i learn first?
jULIE Sun Apr 12, 2009
hello everybody, please write more tutorials like this!!
ugly Wed Feb 11, 2009
i have created a similar script if anyone is interested. im string to learn php and its a good script to start. i have not gone to school to learn all this so i am doing all this by melf and its great to know that there are people like you who want to teach others
gorlie Fri Sep 19, 2008
i was looking for something similar, but this helps
mesay Tue May 06, 2008
as long as u can!
love is sweet!
when two lips are meet
love is complete!
hh Mon Apr 07, 2008
hai..hello world!!!
kavi Wed Mar 12, 2008
the form is working fine. but i need to send the echo information as a mail.
is there is any solution.....

Related Content

Information

Share

wallpaperama | Wallpapers | Forums | Terms Of Service

copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5