Why use $_SERVER[‘PHP_SELF’] instead of “”

The action attribute will default to the current URL. It is the most reliable and easiest way to say “submit the form to the same place it came from”. There is no reason to use $_SERVER[‘PHP_SELF’], and # doesn’t submit the form at all (unless there is a submit event handler attached that handles the submission).

Form submission: PHP S_SESSION statements within a foreach loop

Let’s suppose I have the following PHP code which attempts to read from an array called $arr which takes on the values {fullname, studentnumber, email}. Upon submission of my HTML form, this PHP code will execute the foreach loop, and store the values posted to the page in the $_SESSION array. The above code doesn’t work as intended. If I … Read more