It remains unclear to me why every1 makes this complicated.
You are clearly new to php but everyone's been there and we all got
help at the time.
Some explained how the web is stateless and this is very true but hard
to explain.
When you see a web page, it has been fetched from the server and it
displays html in your browser. When the page has finished loading, the
server does not care anymore, it's like a fly-by-night operation. The
page only exists, in that state, on your computer, in your temporary,
cached documents stored by your browser.
To change the state of the page, you can either go back to the server
ang get a new page (a request), or you can use client (browser) side
scripting (ecma) such as javascript to modify the page's value without
reloading the page, that is, without fetching a new page from the
server.
AJAX is merly javascript that fetches fresh DATA from the server
through an http request, and uses Javascript and DHTML to update the
cuurent page, without reloading it, with the new data. But it doesn't
sound like you'd want to do that just yet.
Looking at your need, here's a very simple example, you'll need 2
files:
Explanations: your php file can contain all your functions, where each
does different bits.
Active Server Pages (but not necessarily microsoft :) ) such as perl,
php, jsp etc take in parameters, also called name-value pairs.
the name value pairs create a query string for the request (to the web
server). The query string can be sent as POST or GET.
for example:
http://www.myserver.com/index.php?name=bob&[EMAIL PROTECTED]
name value pair: name=bob
query string: name=bob&[EMAIL PROTECTED]
so the format is name=value
name is the parameter name
value is the value assigned to that parameter
A query string is read by php and becomes accessible by php as
variables
For example, I could then access $name and $email in my php scripts
Anyhow you probably know that but just making it clear.
So:

file 1, say file1.htm
<form method="post" action="myPhpFunctions.php">
        <input type="hidden" name="action" value="doAndRedirect">
        <input type="submit" value="Do something in php and come back here">
</form>

and file 2, the myPhpFunctions.php file called by file1.htm:
<?
        // My functions that do things
        function someFunction1($someParameter='') {
                // do something
        }

        function someFunction2($someParameter='') {
                // do something
        }

        function someFunction3($someParameter='') {
                // do something
        }
        // etc...


        // my main program, where I decide what to do
        if ($action ==  "doSomething1") {
                someFunction1();
        } else if ($action ==  "doSomething2") {
                someFunction2();
        } else if ($action ==  "doSomething3") {
                someFunction3();
        } else if ($action == "doAndRedirect") {
                // note: "doAndRedirect" is what I put in the form's hidden 
action
field, so it will execute this
                // You could also just have in your html <a
href="myPhpFunctions.php?action=doAndRedirect">do something and come
back</a>
                someFunction3(); // call some function, remember that you 
variables
will be local once in the function so pass them or use the GLOBAL array
                // and
                header("Location:".$_SERVER["HTTP_REFERER"]); // redirect back 
to the
page that made the request, aka the referer; ie: to file1.htm
        }
?>


Hope this helps ;)
-J


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to