Jump to content

sending form data to an external function


ferrins

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)
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.