learner
learner

Reputation: 11

Why do we put "?" in action = "?"

When I was learning Php with Mysql, I got a problem :

<form action="?" method="POST">
    .
    .
    .
</form>

Why do we put "?" in the action attribute?
PS: this form was for inserting text into a database.

Actually, I have an Index.php file which is the controller, and 2 files (form.html.php and joke.html.php as templates). In the tutorial, I first clicked on a link "add joke" to include the form.html.php file and in this form there is <form action="?"> </form> and a submit <input>. When I click on submit, the controller index tests and executes the inserted SQL query.

Thanks.

Upvotes: 0

Views: 130

Answers (2)

Dummy Code
Dummy Code

Reputation: 131

Personally don't ever do that.... Use action="action.php" or use action="" post to the current URL.

Not sure what you are trying to accomplish with ? in the action attribute.

Upvotes: 1

ThiefMaster
ThiefMaster

Reputation: 318488

"We" don't and "You" shouldn't do so either.

  • If you want to POST the data to the current URL, leave it empty, i.e. action="".
  • If you want to POST to another URL, put that URL in there, e.g. action="save.php".

Upvotes: 0

Related Questions