0
<form id="cat_insert" method="POST" action="admin-process.php?action=cat_insert" onsubmit="return false;">

I found this format of HTML form in the sample code provided by my teacher. I know apply php code after submitting the form would use action="admin-process.php". But I don't understanding what is "?" after the php in this case, and the meaning of on submit.

asked Oct 30, 2016 at 12:11
2
  • ? tells that your parameters start after this Commented Oct 30, 2016 at 12:12
  • and parameters passed here will be available in $_GET['paramname']. In this case as $_GET['action'] with value 'cat_insert'. This way you can pass POST and GET Parameters at the same time when submitting a form. Commented Oct 30, 2016 at 12:23

1 Answer 1

2

? at the end of admin-process.php?action=cat_insert denotes where the url parameters begin. This allows you to pass information from one page to the next using the GET method. This is in addition to the parameters passed through to admin-process.php by the form which use the POST method.

The GET method is useful for passing a reasonable amount of non sensitive data between pages, while the POST method has less limitations and is best for more sensitive data.

In this instance you could obtain the value of action on admin-process.php by using either $_GET['action'] or $_REQUEST['action'] ($_REQUEST includes the contents of $_GET, $_POST and $_COOKIE).

onsubmit="return false;" is JavaScript and is used to suppress the default behaviour of the form when it is submitted, this will stop the form from submitting (if JavaScript is enabled). This is likely because some other action is taken by JavaScript (for example validation), exactly what this is for in this case is unclear given the snippet of code.

answered Oct 30, 2016 at 12:30
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.