Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Running functions from same page
Old 07-05-2009, 08:37 AM Running functions from same page
lothop's Avatar
Ultra Talker

Posts: 303
Trades: 0
Hey guys,

Im currently making a php program that runs from 1 main function page. People click on a link which is "setoption.php?a=1&b=2"

Once they have been sent to setoption.php. I collect the variables, send them to the main function page, then redirect the user back to the main page after the function has saved their options.

PHP Code:
if ($functionpage->setOption($_GET['a'], $_GET['p'])) {
      
header("Location: index.php?options=changed");
} else {
      
header("Location: index.php?options=error");
        } 
Does it take longer to send the person to a seperate page, then use headers to send them back compared with using index.php to process the option?
If it does? what would be the best way to make index.php process the option?
Eg. Instead of the link being "setoption.php?a=1&b=2" would it be best to have it "index.php?a=1&b=2&function=setoption" then have the function page process the data?

I hope this makes sense.
Cheers,
Lothop
__________________
Websites Created;
warscope.com
ratepayers.org.nz
lothop is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-06-2009, 08:57 AM Re: Running functions from same page
Extreme Talker

Posts: 206
Name: vikas
Trades: 0
why dont use redirect instead of header . Hope It will solve your problem
__________________

Please login or register to view this content. Registration is FREE
Collection of free online books and free ebooks
Please login or register to view this content. Registration is FREE
- Free online pdf books and free pdf eBooks
vikas1234 is offline
Reply With Quote
View Public Profile
 
Old 07-06-2009, 02:14 PM Re: Running functions from same page
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
since its redirecting it back to the index.php anyways you can run the function prior to anything loading in the page..

so pretend you're on about.php

PHP Code:
//about.php
//Your Link
<a href="index.php?a=1&b=2">Set Options</a
PHP Code:
//index.php

//Include The function
include('functionpage.php');

//run the function
if (isset($_GET['a'] && isset($_GET['b'])) $functionpage->setOption($_GET['a'], $_GET['p'])

//Content
<html>
<
head>
</
head>

<
body>
</
body>
</
html

remove the header/redirect in the function

you can even go as far as including the function in every page thus allowing people to set options without actually changing pages...
orionoreo is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Running functions from same page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17978 seconds with 12 queries