|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem: Function Undefined
I have a strange problem,
My script looks like this: <? if ($HTTP_SERVER_VARS['REQUEST_METHOD']!='POST') { ?> <html><body> <form action="login.php?action=login" method="post"> UserName: <input name="loginUserName"><br> Password: <input name="loginPassword"><br> <input type="submit"> </body></html> <? } else { switch($action) { case login: ProcessLogin(); die(); case logout: die(); } function ProcessLogin() { echo "Im inside the function"; } } ?> I got the following error when I enter a UserName and a Pass: Fatal error: Call to undefined function: processlogin() in /path/to/the/file/login.php on line 18 One more thing, although my method inside the html code is POST, when I tried to echo the value of $login I typed: echo "action: $HTTP_POST_VARS[action]"; it showed nothing !!!! But when I typed: echo "action: $HTTP_GET_VARS[action]"; it showed action: login !!!! Although when I typed echo "Method: $HTTP_SERVER_VARS[REQUEST_METHOD]"; it showed Method: POST !!!! Come on, Its make no sense!!! I tested it on my virtual server (Apache) and on my web server, the same crazy result I got. |
|
#2
|
|||||
|
|||||
|
RE: Problem: Function Undefined
yes, u are using POST method, but u are passing action as GET variable!
all the variables in a url after the ? char are posted as get variables! u should just use $_GET['action'], or if u want to force action as POST parameter, use hidden field like this: php Code:
as for unknown function error, try closing { u opened after else BEFORE function declaration. the code, from else to the end, should look like this: |
|
#3
|
|||
|
|||
|
RE: Problem: Function Undefined
BTW: Yes, zombie is right. You're passing it via GET method (login.php?action=login) since that's the actual URL it'll go to even if it posts the form.. If you say method=GET then you'll lose the action variable entirely.
This is a very common way for me to mix POST and GET variables and i personally think there's nothing wrong with it since it's a bit cleaner than having hidden fields all over the place. my 2c. |
|
#4
|
|||
|
|||
|
RE: Problem: Function Undefined
i didn't say that that way was wrong.
only thing that was wrong was a way he was trying to do.. btw, u are not the only one to use this method. i thing almoust every good php programmer uses this method. (just look at this or any other forum software) |
|
#5
|
|||
|
|||
|
RE: Problem: Function Undefined
heh, sorry, i said that with the wrong inflection ;) i only meant to note that it's quite legal and good.
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Problem: Function Undefined |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|