skip to Main Content

I have one button in <form></form> tag, so I want it to send the user from index.php to order.php with some get variables product.

index.php:

<form action="order.php?product=<?php echo $row['Name'];?>">
    <input type="submit" value="Замовити" class="btn btn-outline-warning">
</form>

But then it sends me to /order.php?, so the var product is not set for this page.

order.php:

$product_name = $_GET['product'];
if (!isset($product_name)) {
  echo 'bruh';
}

Result: Picture

2

Answers


  1. To create a form that send user to another page with some GET variables ,you need to specify some destination URL and use the HTTPGET method to submit the form.

    Form action="destinationPage.php" method="GET"

    now the user will be redirected to new page with the form data.

    Make sure that you are not passing sensitive data like password using GET as it is not secured beacuse data is visible in the URL.
    For sensitive data use POST method instead.

    Login or Signup to reply.
  2. In the action tag you are giving "order.php?product, so it will take you the orders page. Try giving the name of the page where you want to re-direct your response.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search