R S R S - 1 month ago 8
PHP Question

Notice: Undefined Index in form submission to another page

I am new to php and I am trying to submit a form using POST. My form element looks like

<form action="<?php htmlspecialchars($_SERVER["/php/somefunctions.php"]);?>" method="post">

Both the files have session_start(); declared at the top and the form doesn't have any required field. When I open the form in browser it shows,

Notice: Undefined index: /php/somefunctions.php in 'filepath' on line 31.

Line 31 is the above mentioned line.
If I ignore this and fill in the form and click on submit, it gives me

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

Answer Source

You should use server document root.

$_SERVER["DOCUMENT_ROOT"]./path to file

Also you forgot to add echo. Without echo php won't display anything

echo htmlspecialchars();