Using HTML Forms to pass data to PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AutumnsDecay
    New Member
    • Mar 2008
    • 170

    #16
    You need to set the variable on the next page, it's not automatically set for you.

    Page1:
    Code:
    <input type="text" name="qty" />
    Page2:
    Code:
    $qty = $_POST['qty'];

    Comment

    • mangal
      New Member
      • Dec 2006
      • 9

      #17
      What is the solution of stop submission of form on refresh, I am trying lot of tips and tricks, some of them works but I am not satisfied with them. If you have any clean solution please update.
      Regards,
      Mangal Kumar

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #18
        Redirection after submission will do the trick.

        Comment

        • Freedom Coach
          New Member
          • Jan 2012
          • 3

          #19
          Thank you for this article. It resolved a problem that I have had for days.

          Comment

          • MerilFernando
            New Member
            • Mar 2017
            • 4

            #20
            Variable Data passing between PHP, HTML, JAVASCRIPT

            Code:
            <?php  $xphp= "My PHP WORLD"; ?>   <!-- Define a PHP variable -->
            <script> var xjs='My Java Script world'; </script> <!-- Define a JAVASCRIPT variable -->
            <input type='hidden' id='myhtml' value='My HTML world!' > <!-- Define a HTML variable -->
            
            <BR>sending PHP variable value into JAVASCRIPT <BR>
            <script>
            var xphp='<?php echo $xphp; ?>';
            document.write(xphp);    
            </script>
            
            <BR>getting PHP variable value into HTML <BR>
            <?php echo $xphp; ?>
            
            <BR><BR>getting JAVASCRIPT  variable value into PHP <BR>
            <?php
            $xjs = "<script>document.write(xjs);</script>";
            echo $xjs;
            ?>
            
            <BR>getting JAVASCRIPT  variable value into HTML <BR>
            <script>document.write(xjs);</script>
            
            <BR><BR>getting HTML variable value into JAVASCRIPT  <BR> 
            <script>
            var xhtml=document.getElementById('myhtml').value;
            document.write(xhtml);    
            </script>
            
            <BR>getting HTML variable value into PHP <BR> 
            <?php
            $xhtml = "<script>document.write(document.getElementById('myhtml').value);</script>";
            echo $xhtml;
            ?>

            Comment

            Working...