Page 1 of 1

$PHP_SELF

Posted: Mon Apr 12, 2004 8:07 pm
by richie256
I don't know why, but I am getting this error:

Code: Select all

Forbidden
You don't have permission to access /<br /><b>Notice</b>: Undefined variable: PHP_SELF in <b>C:/Program Files/Apache Group/Apache2/htdocs/clients.php</b> on line <b>203</b><br /> on this server.
here on line 203:

Code: Select all

<?php
<form method="post" action="<?php echo $PHP_SELF; ?>?mode=add">
?>
I really don't know why I can't use $PHP_SELF

Posted: Mon Apr 12, 2004 8:11 pm
by markl999
<?php echo $_SERVER['PHP_SELF']; ?>

See http://php.net/variables.predefined for more info

Posted: Mon Apr 12, 2004 8:11 pm
by ol4pr0

Code: Select all

$_SERVER['PHP_SELF']

// or EDIT:

action={$_SERVER['PHP_SELF']} method="GET"       ect...

Posted: Mon Apr 12, 2004 8:51 pm
by Steveo31
I had this problem.

Code: Select all

<form method="get" action="<?php $_SERVER['PHP_SELF'] ?>">
You cant have it be a POST form with GET variables appended to it. :)

Posted: Mon Apr 12, 2004 8:58 pm
by markl999
You cant have it be a POST form with GET variables appended to it.
Sure you can :o
Example:

Code: Select all

<?php
if(!empty($_GET)){
    var_dump($_GET);
}
if(!empty($_POST)){
    var_dump($_POST);
}
?>
<html>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?id=45">
<input type="text" name="uname">
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Posted: Mon Apr 12, 2004 11:22 pm
by Steveo31
Really... wow. My bad. Didn't know that :)