简体   繁体   中英

Need help to use the following line of code to do a post method in html

my value is as follows, i need the value to do post method. I have tried the following but the post method does not work.

              <input type="hidden" name="return_url"    value="<?php echo URLROOT; ?>/shop/payment" > 

echo '<form method="post" name="myform" action="script to check and manipulate your posts">
<input type="hidden" name="return_url" value="'.URLROOT.'/shop/payment" >
</form>';

you will get the return_url in POST if you submit this form, but you need to write a script which redirects to the url given in the return_url

let's say you have 2 files:

---------- form_file.php

<!DOCTYPE html>
<html>
 <body>
   <form method='post' name='myform' action='post_read.php'>
      <input type='text' name='return_url' value='blablabla.php'>
      <input type='submit' name='submit_btn' value='SUBMIT THIS FORM'>
   </form>
 </body>
</html>

---------- post_read.php

<?php
echo "POST VARIABLE: ".$_POST['return_url'];
?>

so the form_file.php will send the POST variables to post_read.php file. Of course if both files are in the same directory, otherwise give the proper address to the form_read.php in the "action" attribute of the form tag in the form_file.php

In my example the return_url input field is type TEXT to show you the value sent to the post_read.php file, but you can change the type to hidden with the same result in post_read.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM