data into PHP variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gubbachchi
    New Member
    • Jan 2008
    • 59

    data into PHP variable

    Hi,

    How to get data from a text field into php variable without using POST variables because I need the text field value in the same PHP page.

    With regards
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    You can POST the form to the same page
    <form action="">

    Othewise, you'll have to use some client side code.

    Comment

    • gubbachchi
      New Member
      • Jan 2008
      • 59

      #3
      Thank u.

      Can you please give me some idea of client side code

      Comment

      • ifedi
        New Member
        • Jan 2008
        • 60

        #4
        Originally posted by gubbachchi
        Hi,

        How to get data from a text field into php variable without using POST variables because I need the text field value in the same PHP page.

        With regards
        Please clarify the question. What do you mean you 'need the text field value in the same page?
        Perhaps you need to draw out the field values from a database via php, but send the form variables back into the database through a different php script either elsewhere on the same page, or on another page(specified in the form 'action' attribute).

        But basically, you can only send out form variable values with POST and GET superglobals.

        If you make it clearer, I'll make this clearer.
        Regards,
        Ifedi.

        Comment

        • vsvnmurthy
          New Member
          • Nov 2007
          • 4

          #5
          [QUOTE=ifedi]Please clarify the question. What do you mean you 'need the text field value in the same page?

          Hi there..

          If you need the text value into php variable in the same page check out this code..
          but remember that method 'get' is default. No need to specify.

          <form name="f1">
          <input type="text" name="t" value="">
          <?php
          $a = $_GET['t'];
          echo $a;
          //you can check same php variable value in t2 textbox by just uncommenting.
          ?>
          <!-- <input type="text" name="t2" value="<?php // echo $a; ?>"; -->
          <input type="submit" name="submit" value="submit">
          </form>

          Hope this will help you out
          vsvnmurthy

          Comment

          Working...