0

want to submit a form with name and quantity but i want to pass a get variable to the form without input. When the form is submitted the get variable for quantity is pass but i want also to pass the name quantity which is displayed already. Can i do this either through action="site.php?name=theName" or how can i do this.

"<"form action='site.php?name={$name_row['name']}' method='GET'>

2
  • please provide some code ! which highlight your question and help to answer Commented Mar 29, 2019 at 6:17
  • Just add a hidden input? <input type="hidden" name="name" value="<?= $name_row['name']?>" /> Commented Mar 29, 2019 at 6:18

3 Answers 3

1

Using GET method in forms is not recommended, maybe you want to use hidden inputs?

<form action='site.php' method='POST'>
  <input type="hidden" name="name" value="<?=$name_row['name']?>">
</form>

You can use it with GET too

Sign up to request clarification or add additional context in comments.

Comments

0

If you don't want the variable passed to be displayed, you can use a hidden input:

<input type="hidden" name="name" value="<?php echo $_GET['name'] ?>"/>

If you don't want to use any input, of course you can pass them in form action:

<form action="somewhere.php?name="<?php echo $_GET['name'] ?>" method="post">

Comments

0

You have 3 most popular methods

i. Input type hidden

<input type='hidden' name='name' value='<?=$variabel?>'>

ii. Add on form GET method

<form action='site.php?xyz=<?=$variabel?>'>

</form>

iii. User $_SESSION

<?php $_SESSION['xyz'] = variabel; ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.