Form: POST a string & get the result in the same form field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
easyrider767
Forum Newbie
Posts: 1
Joined: Thu Dec 23, 2010 10:56 am

Form: POST a string & get the result in the same form field

Post by easyrider767 »

Is to possible to POST a string in the form field and get converted string result in the same form field?

I use the code:

Code: Select all

<?php
  $string='';
  if (isset($_POST['string']))
    $string=$_POST['string']

  if (isset($_POST['DoStuff']))
  {
    $string = doStuffWithThisString($string);
  }
  if (isset($_POST['DoOtherStuff']))
  {
    $string = doOtherStuffWithThisString($string);
  }

?>

<form action="" method="post">
<!-- blank action attribute will post form to the current page-->
  <input type="text" value="<?=$string?>" name="string" />
<!-- <?=$string?>  is the same as <?php echo $string; ?> -->
  <input type="submit" value="Do Stuff" name="DoStuff" />
  <input type="submit" value="Do Other Stuff" name="DoOtherStuff" />
</form>
but get the result above form field
anantha
Forum Commoner
Posts: 59
Joined: Thu Dec 23, 2010 7:38 pm

Re: Form: POST a string & get the result in the same form fi

Post by anantha »

what do u mean u get above form field? u need to pass the $string to the value..if for example, if it is a text box..
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Form: POST a string & get the result in the same form fi

Post by califdon »

Have you tried it? What do you get?
Post Reply