Error passing php variables to another page via form data

user3142442

I want to pass a variable to another page by form data. I've looked at other tutorials and codes, i've followed them closely, but the contents of the variable doesn't output. Basically php doesn't work inside the value="". Here's the code.

page 1.

 <?php
    $hi = 1224;
 ?>
    <form method = "post" action = "page2.php">
    <input type = "hidden" Name = "var" Value = "<?phpecho$hi;?>"/>
    <input type = "submit" Name = "enter" Value = "Submit"/>
    </form>

page 2.

 <?php
    $test = $_REQUEST['var'];
    echo $test;
 ?>

Nothing is outputted. I've even tried session variables but somehow they worked but once i refreshed the page, the variables were reset. I've started sessions on all pages etc..

user3142469

When something isn't working, make sure to check the source code for error, don't just look browser's rendering. In the source, you'd clearly have seen that <?phpecho$hi;?> wasn't evaluated, but instead just printed in the source.

So in conclusion, <?phpecho$hi;?> is wrong. Write <?php echo $hi;?>.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Javascript

passing form data to another HTML page

From Dev

Sending data from the form to an email with jQuery ajax and redirect to another page with passing POST variables not work

From Dev

Form not passing variables php

From Dev

Passing data to another page

From Dev

Passing data from one page to another via StackNavigator in DrawerNavigator

From Dev

Passing two php variables to another page from a link

From Dev

Passing variables to another page with include

From Dev

Error in Passing PHP value to another page using JavaScript

From Dev

Passing PHP variable data onto another page after validation

From Dev

Passing JSON data from one php page to another

From Dev

send information via form without transaction in another page PHP

From Dev

how to send the data to another page via form tag?

From Dev

Passing a variable to another php page

From Dev

PHP Form not passing variables to second form

From Dev

passing variables from one jsp page to another?

From Dev

Passing variables from page view controller to another

From Dev

echo an error without redirecting to another page and keep all form data?

From Dev

Passing variables to PHP script via AJAX

From Dev

Passing variables from javascript via ajax to php

From Dev

Pass variables to another page PHP

From Dev

Is that possible to use the passing data form another page in Statefulwidget without using "widget."

From Dev

form action is another page(php code) how to validate the form and display error message in view page

From Dev

Passing multidimensional with dynamic form via ajax to PHP

From Dev

Passing variables from a HTML form to PHP

From Dev

Submit a form data to another php page but display the result back to the same page from where the form was submitted?

From Dev

Delphi - passing variables to another form (without global variables)

From Dev

Angular 2 Passing form data to another component

From Dev

Error: No Multipart boundary is found when passing form-data via AJAX

From Dev

Pass data to another page and submit form on that page

Related Related

  1. 1

    passing form data to another HTML page

  2. 2

    Sending data from the form to an email with jQuery ajax and redirect to another page with passing POST variables not work

  3. 3

    Form not passing variables php

  4. 4

    Passing data to another page

  5. 5

    Passing data from one page to another via StackNavigator in DrawerNavigator

  6. 6

    Passing two php variables to another page from a link

  7. 7

    Passing variables to another page with include

  8. 8

    Error in Passing PHP value to another page using JavaScript

  9. 9

    Passing PHP variable data onto another page after validation

  10. 10

    Passing JSON data from one php page to another

  11. 11

    send information via form without transaction in another page PHP

  12. 12

    how to send the data to another page via form tag?

  13. 13

    Passing a variable to another php page

  14. 14

    PHP Form not passing variables to second form

  15. 15

    passing variables from one jsp page to another?

  16. 16

    Passing variables from page view controller to another

  17. 17

    echo an error without redirecting to another page and keep all form data?

  18. 18

    Passing variables to PHP script via AJAX

  19. 19

    Passing variables from javascript via ajax to php

  20. 20

    Pass variables to another page PHP

  21. 21

    Is that possible to use the passing data form another page in Statefulwidget without using "widget."

  22. 22

    form action is another page(php code) how to validate the form and display error message in view page

  23. 23

    Passing multidimensional with dynamic form via ajax to PHP

  24. 24

    Passing variables from a HTML form to PHP

  25. 25

    Submit a form data to another php page but display the result back to the same page from where the form was submitted?

  26. 26

    Delphi - passing variables to another form (without global variables)

  27. 27

    Angular 2 Passing form data to another component

  28. 28

    Error: No Multipart boundary is found when passing form-data via AJAX

  29. 29

    Pass data to another page and submit form on that page

HotTag

Archive