ktm
ktm

Reputation: 6085

how does this php form work without defining variable?

how does this php form work without defining $SCRIPT_NAME variable ?

<form action="<?php echo $SCRIPT_NAME ?>" method="post">

Upvotes: 1

Views: 102

Answers (3)

Eldros
Eldros

Reputation: 561

The variable $_SERVER['PHP_SELF'] will give you the relative path of the executing script, as well as the variable $_SERVER['SCRIPT_NAME'] gives the current script name.

An alternative would be to use $_SERVER['SCRIPT_FILENAME'] or the constant FILE, which each give the absolute path.

Those should be preferred and used instead of using the register-globals feature which should be disabled as @ThiefMaster said.

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318518

This code relies on the ancient, deprecated and horrible register_globals feature which creates global variables from all the $_REQUEST, $_COOKIE and $_SERVER fields.

I'd highly suggest you to get rid of this code and disable the register_globals setting.

Upvotes: 4

James
James

Reputation: 13501

There is a variable, $_SERVER['SCRIPT_NAME'] that prints out the name of the current script. You can find some information on it here: http://php.net/manual/en/reserved.variables.server.php

I would suspect that is what is being used.

Upvotes: 1

Related Questions