Form via GET

Asked

Viewed 327 times

0

I am sending data via get by the url the form this way

<form  action="dashboard.php?link=products/home&so=app_windows" method="GET">
</form>

when sending redirects always to

dashboard/dashboard.php?so=app_android

instead of going to

dashboard/dashboard.php?link=products/home&so=app_android

some solution

  • Use the method='post' that this problem will not happen.

  • yes I’ve used for the post more and I want by the url because by the post this information is lost to the page exchange already by the url no

  • Place the complete form so that we can detect what is happening. Only with what you posted can not know what happens.

1 answer

1

You did not put it in the code but when you use the get method the values of your form elements will be entered in the url. So you probably have something like this:

<form  action="dashboard.php?link=products/home&so=app_windows" method="GET">

    <input type="text" name="so" value="app_windows">
    <input type="submit" name="" value="Enviar">

</form>

When you click submit, this url will be changed.

If you wear it like that:

<form  action="dashboard.php?link=products/home&so=app_windows" method="POST">

    <input type="text" name="so" value="app_windows">
    <input type="submit" name="" value="Enviar">

</form>

Your url will not change and you will be able to pick up the values via GET in the same way.

Or else you can do it:

<form  action="dashboard.php" method="get">

    <input type="" name="so" value="app_windows">
    <input type="" name="link" value="products/home">
    <input type="submit" name="" value="Enviar">

</form>

Depends on what you think is best.

  • I’ve done how I talk creating a <input type=""name="link" value="products/home"> more now it redirects more to Dashboard.php url? link=products%2Fhome%26&so=app_windows how to remove these characters leaving only the Dashboard.php bar? link=products/home&so=app_windows

  • @diogoDsa this is no problem. It gives a echo $_GET['link'] and see the result. It will be decoded.

  • And take off the & of value="products/home&" is not necessary.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.