Session, Functions and Includes

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Session, Functions and Includes

Post by $var »

Hello, I am hitting a wall!

I am implementing a captcha in a form that is being called in a template via include.
eg: index.php includes form.php

Form PHP doesn't have any <head></head> or similar mark-up, it's just a form with PHP processing at the bottom.

I am calling the captcha function at the top of the form.php page, but it always fails processing with no errors.
When I put the form code in a test.php page that calls the captcha function and include before the HTML DOC, it succeeds.
When I put the captcha function in index.php before the HTML DOC and include form.php, captcha check fails with the error called to undefined function.

This leads me to believe that it's not allowed to assign a function at the top of the main index because it doesn't pass that along to the include, and that because the include doesn't have proper HTML mark-up for a complete page that it can't work properly.

Can you help explain this, am I right in my understanding? If so, I have to change how I am doing things.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Session, Functions and Includes

Post by Jonah Bron »

Without seeing the code, it's impossible to say. But if it's giving you an undefined function error, it's safe to assume that some file isn't being included.
User avatar
Technical
Forum Commoner
Posts: 81
Joined: Thu Dec 02, 2010 5:30 am

Re: Session, Functions and Includes

Post by Technical »

Post your code, please, so we can tell what is the problem.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Re: Session, Functions and Includes

Post by $var »

I just went about it another way.
I tried by-passing the include altogether but it still failed the captcha.

I think it has to do with Drupal corrupting it somehow.

Thanks anyway!
Post Reply