Jump to content

Archived

This topic is now archived and is closed to further replies.

ferrins

sending form data to an external function

Recommended Posts

Hi everybody!
I'm trying to send some form data to a different page where I have all my site's functions.
My form page it's like this:

<form  method="post" action="functions.php?action=checkgroup"> /* is this action right? */
Group Name: <input type="text" name="group">
<input  type="submit" name="submit" value="check">
</form>

Then, in my functions.php page:

function checkgroup(whattheheckshouldIputinhere?){

sql stuff...

return something..

}

Well , so what am I missing? is it something related to GET action and stuff?
If anybody can give me a hand I'd appreciate it!
Thnkx!
(and my register_globas is on)

Share this post


Link to post
Share on other sites
Almost there...

Probably best to have your functions page as just that, nothing else.  Then include it in the rest of your pages.  So your form calls validate.php which looks a little like this.

[code]
<?php
  include_once('functions.php');
  $group = $_GET['group'];
  checkgroup($group);
?>
[/code]

Regards
Rich

Share this post


Link to post
Share on other sites
The way we do it on my server is we have an index.php page which runs all of our Posts.  As HuggieBear said you need to include your functions page with in the other pages.  Then have your form Post to your index.php.  On you index.php have something like this...

if (isset$_POST['submit']){
$var = $_POST['submit'];
checkgroup($var)
}


On your page of functions you should have your check group function look something like this...

function checkgroup($group){

ALL THE CODE YOU WANT...  $group now equals $var from above.

}

I hope I explained it well.  Good Luck

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.