Submit Variable to self

by Mukesh Dak on 2010 Jan 11

in PHP

<?php

# Title: Subimitting variables to self
# Description : This script describes that how a variable can be sent to same page.
#  This page work on the principle that when this page is loaded , this check if a particular
#  variable is passed or not. If yes then it process the variable with required action
#  otherwise it generates a form using which that variable can be submitted.
# Author: Mukesh Dak
# Author URL: http://mukeshdak.com
# Date: 12 Nov 2009

if (isset($_REQUEST['test']))
  {
         $test      = $_POST['test'];
         echo "<p>You have submitted ".$test;
}
else
  {
  ?>

    <form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="POST" >
    <p>Test: <input type="text" name="test" value="" size='50' ><br >
    <p><input type="submit" value="Send" >

<?php
  }
?>

Leave a Comment

Previous post:

Next post: