PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 27th, 2002, 12:27 AM
alsaffar alsaffar is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 58 alsaffar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
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.

Reply With Quote
  #2  
Old August 27th, 2002, 04:58 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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:
Original - php Code
  1.  
  2. <form action="login.php" method="post">
  3.   <input type="hidden" name="action" value="login" />
  4.   ...
  5. </form>


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:

php Code:
Original - php Code
  1.  
  2. else
  3. {
  4. switch($action)
  5. {
  6. case login:
  7. ProcessLogin();
  8. die();
  9. case logout:
  10. die();
  11. }
  12. }   // this should go here
  13.  
  14. function ProcessLogin()
  15. {
  16. echo "Im inside the function";
  17. }
  18.  
  19. //      one } removed from here
  20. ?>


Reply With Quote
  #3  
Old August 27th, 2002, 08:04 AM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
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.

Reply With Quote
  #4  
Old August 27th, 2002, 10:28 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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)

Reply With Quote
  #5  
Old August 28th, 2002, 08:12 AM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Problem: Function Undefined


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek