通过超链接传递表单输入名称

I am trying to pass input tag value to the another page to simply multiply the value of qty with price and return the updated price.The problem is when i pass the value of qty with get method it passes the value of qty only but does not pass another values.

cart.php

echo" <form method='get' name='form1' action='update_cart.php?id={$id}&name={$name}&price={$price}&qty=$_GET['qty']'>";//the problem comes here.

echo"<input type='number' name='qty' max='10'>
    <input type='submit' value='update'></form>";

update_cart.php

$id = isset($_GET['id']) ? $_GET['id'] : "";
$name = isset($_GET['name']) ? $_GET['name'] : "";
$qty=isset($_GET['qty'])? $_GET['qty']: "";
$price=isset($_GET['price'])? $_GET['price']: "";

$price=$price*$qty;
header('Location: cart.php?action=quantity_updated&id=' . $id . '&name=' . $name . '&price='.$price . '&qty='.$qty);

when i click on update button after giving qty a value it shows something like this.

http://localhost/abc/cart.php?action=quantity_updated&id=&name=&price=0&qty=2

form method="get" passes variables automatically.

You do (and can) not need to append query string to the action attribute.

You do however need to represent those data in your form, if with <input type="hidden" name="qty" value="<?=$qty?>" /> style.

if you want pass some values , you can choose 2 way for it :

you can use the input with hidden type in you form. if you use hidden type input you can use data just on one page.

<form method='get' action='?????'>
<input type='hidden' name='?????' value='?????'>
<input type='hidden' name='?????' value='?????'>
....
...
..
<input type='number' name='qty' max='10'/>
<input type='submit' value='submit'/>
</form>

you can use session for save data and use it in another page. if you use session, you can use data in all php pages. on page 1:

<?php
session_start();
$_SESSION['name']='value';
?>

on page 2:

<?php
session_start();
echo $_SESSION['name']; // value
?>

Your syntax for this line contains errors.

echo" <form method='get' name='form1' action='update_cart.php?id={$id}&name={$name}&price={$price}&qty=$_GET['qty']'>";

Change it to...

echo" <form method='get' name='form1' action='update_cart.php?id=".$id."&name=".$name."&price=".$price."&qty=".$_GET['qty']."'>";

Happy Coding !