PHP-simple Form

Since you'll need a place for the user to enter
 a search query, let's begin by building a form
 to handle the user's input. Every form must
 have these basic components:

The submission type defined with the method keyword

One or more input elements defined with the input tag

The destination to go to when submitted defined with
the action keyword

  <html>
  <head>
  <title>Building a Form</title>
  </head>
  <body>
   <form action="<?php echo($_SERVER['PHP_SELF']); ?>"
         method="get">
    <label>
          Search: <input type="text" name="search" />
     </label>
       <input type="submit" value="Go!" />
   </form>
  </body>
  </html>


 A file called simple.php in a web-accessible directory
on your web server, such as the document root. Strictly
 speaking, forms are defined purely by HTML, but we're
using some PHP code on line 6 to reference the super
global PHP_SELF. This provides a shortcut to the name of
the current PHP file that handles the submission of
the form data.

The form  allows you to capture the search sting from
 the user for a search. Notice how we wrapped a label
 tag around the input where the text was; this makes
 the form easier to use. Since clicking on the Search:
 text automatically sends the cursor to the search field.

 we set the form submission method to GET. This is done
 to insure that users can bookmark their searches and
 not have to come back to the page and reenter their
 data.


Related Posts:
  • Reading DOC file in php   read PDF and DOC files using PHP Reading PDF Files   $content = shell_exec('/usr/local/bin/pdftotext '.$filename.' -');     Reading DOC Files  $content = shell_exec('/usr/local/bin/antiword '.$fi… Read More
  • What is triggers? A trigger is a database object which is associated with particular database table. Triggers gets called automatically when particular event(INSERT, UPDATE, DELETE) occurs on table. … Read More
  • Associative Arrays? You can use string values as keys. For example, you might create an arraylike this: $myStuff = array();$myStuff[“name”] = “andy”;$myStuff[“email”] = “andy@fsdsd.ca”;Print $myStuff[“name”]; Associative arrays are different t… Read More
  • Checking Variable Values and Types FUNCTION is_numeric() True if number or numeric stringctype_digit() True if all digits are numeric charactersis_bool() True if variable is a Booleanis_null() True if variable is NULLis_float() True if variable type is a fl o… Read More
  • magic_quotes_gpc, magic_quotes_runtime Magic quotes is the name of a PHP feature that automatically quotes inputdata, by using the addslashes() function. Historically, this was used so thatform data could be used directly in SQL queries without any security or qu… Read More
  • Setting Environment Variables Setting environment variables in your server configuration on a host-by-host basis allows you to configure virtual hosts differently. <?php putenv('ORACLE_SID=ORACLE'); // configure oci extension ?>   Adjusting… Read More
  • PHP Classes Classes do not use scope keywords, but you can prevent people from instantiating the class by makingthe __construct() method and the __clone() methods private or protected. The __construct()method is used to create the objec… Read More
  • Extracting Substrings You want to extract part of a string, starting at a particular place in the string. For example, you want the first eight characters of a username entered into a form.  Extracting a substring with substr( ) &l… Read More
  • Turning an Array into a String convert it into a  formatted string. Use join( ): // make a comma delimited list $string = join(',', $array); Or loop yourself: $string = ''; foreach ($array as $key => $value) { $string .= ",$value"; } $str… Read More
  • How we know browser properties? echo $_SERVER['HTTP_USER_AGENT']; $browser = get_browser(); foreach ($browser as $name => $value) { echo “$name $value \n”; } get_browser   returns the capabilities of the user's browser. … Read More
  • $_ENV and $_SERVER ? PHP sets several variables for you containing information about the server, the environment, and your visitor's request. These are stored in the superglobal arrays $_ENV and $_SERVER, but their availability depends on whe… Read More
  • $_GET , $_POST,$_COOKIE?? $_GET contains any variables provided to a script through the GET method.  $_POST contains any variables provided to a script through the POST method.  $_COOKIE contains any variables provided to a script through a… Read More
  • Setting Default Values for Function Parameters Assign the default value to the parameters inside the function prototype: function wrap_html_tag($string, $tag = 'b') { return "<$tag>$string</$tag>"; }     The example in the Solution sets the… Read More
  • Finding the Position of a Value in an Array Use array_search( ) . It returns the key of the found value. If the value is not in the array, it returns false:   $position = array_search($value, $array); if ($position !== false) { // the element in position&n… Read More
  • Web server compression? The best way to understand web server compression is to think of sending ZIP filesinstead of uncompressed files from your web server to your web user. Sending less dataover the network will minimize network latency and your … Read More