this is my input
<input type="text" name="quantity" id="quantity" value="1" />
this is my href link
<a href="UserOrderProduct.php?id=<?php echo $Pid; ?>
&price=<?php echo $Price; ?>&quantity=">add</a>
how to write it in the href and please ignore the
<?php echo $Pid; ?>&price=<?php echo $Price; ?>
this is because i get the id already from the database but only the quantity not really how to get it, can teach me?
If you have a form where you get the "quantity" value as it looks from your code:
<input type="text" name="quantity" id="quantity" value="1" />
if you use the "GET" method
<FORM method='get' action='next_script.php'>
all the values will be in the address, otherwise, if you POST the values you'll get them in the next script via $_POST array.
If you need to pass one or more couples variable=value between different scripts the best solution is to use PHP sessions.
You just need to add at the beginning of each script:
session_start();
and put your_variable and your_value as:
$_SESSION['your_variable'] = your_value;
or
$_SESSION['session_variable'] = $your_variable;
In such a way data are not visible on the link and you can access them anywhere you like provided that you keep the session_start() command at the beginning of each php page.
If you have html...
<form method="post" action="phpfile.php">
<input type="text" name="quantity" id="quantity" value="1" />
<input type="submit" value="send">
</form>
...in your phpfile.php you can retrieve the value of quantity like this:
<?php
$qty = $_POST['quantity'];
?>
<a href="UserOrderProduct.php?id=<?php echo $Pid; ?>
&price=<?php echo $Price; ?>&quantity=<?php echo $qty;?>">add</a>
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.