Savage L
Savage L

Reputation: 51

How can the action at the form get the value?

When I try to use this structure:

<form name="confirm" method="get" accept-charset="utf-8" enctype="multipart/form-data" action="confirm_sent.php?name=<?PHP echo $name; ?>">
...........//sth doing at here
<input type="submit" class="popUpButton" name="confirmButton" id="submitPage4" value="Confirm" />

The name was get from the URL:

http://localhost/reserve/app/confirm.php?name=$name

But, when I click the button confirmButton it will directly to confirm_sent.php but at the URL there the value of name does not show out only show this:

http://localhost/reserve/app/confirm_sent.php?confirmButton=Confirm

So, I would like to ask that it is my concept wrong or did I do it the wrong way?

Thanks for the help / advice... :)

Sorry for any inconvenience.

Upvotes: 2

Views: 61

Answers (1)

Barmar
Barmar

Reputation: 780724

If you use method="GET", you can't put parameters in the action URL. You should use a hidden input field instead:

<form name="confirm" method="get" accept-charset="utf-8" action="confirm_sent.php">
<input type="hidden" name="name" value="?PHP echo $name; ?>">

But if you need to use multipart/form-data, because you have a file input, you can't use method="GET", you have to use method="POST". In that case, you can either have the parameter in the URL or in a hidden field.

<form name="confirm" method="post" accept-charset="utf-8" enctype="multipart/form-data" action="confirm_sent.php?name=<?PHP echo $name; ?>">

The name parameter will be in $_GET['name'], all the other inputs will be in $_POST (except the file inputs will be in $_FILES).

Upvotes: 2

Related Questions