0
//Login.php
function display_login_form(){
   //..Code
}

function handle_login(){
   //..Code
}

-------------------------------------------------
//AddSubject.php
//No include any header
function handle_addsub_form(){
    //..Some code
    echo <<<SUCCESSRESPONSE
    <html>
        <head>
            <title>New Subject record inserted</title>
            <link rel="stylesheet" type="text/css" href="./css/mycss.css">
        </head>
        <body>
            <h1 id="white">Creation of Subject</h1>
            <h3 id="white">Created entry for subject $subjectcode $title</h3>

            <br/>
            <a href="XXXXXX">//<=== go to first php function handle_login()
                <span id="white">Home</span>
            </a>
        </body>  
    </html>
SUCCESSRESPONSE;
}

From my code above, i assume everybody understand my question right? how i go to specific function only

Because if i just input It will just go to the first function and i would like to go only specific function and ignore the rest of it. it's possible to do it?

2
  • 1
    I like to read the question before I look at the code. You you mind spelling it out for me, please? Commented Jun 11, 2013 at 11:47
  • nurdglaw I think I understand what she's asking. She needs to check $_POST or $_GET to check whether the form has been submitted, and determine what to show based on that Commented Jun 11, 2013 at 11:49

3 Answers 3

3

You can check if the form was submitted. Something like:

<?php
if(isset($_POST)){
    handle_login();    
} else {
    display_login_form();
}
?>
Sign up to request clarification or add additional context in comments.

5 Comments

You can call any function. Just change the function calls.
i no need to include the header file right? just do it like yours ?
You should edit your question to be a bit more specific on what you want to achieve.
editted. so what should i place inside my <a href> over there?
"Login.php" Login.php should declare the two functions. Then with some logic you can determine what function to call.
0

In PHP you don't "go to" a function, you call it. Your PHP code needs some logic to know which function to call. You can add query string parameters, use a form, there are many ways. You have to write some logic though, it's not a built in feature.

Comments

0

You can pass the name of function you want to execute and put it in switch statement.

$fn = $_REQUEST['fn'];

switch($fn){
   case "handleLogin":
    handleLogin();
   break;
   default:
    echo "function not found";
   break;
}

2 Comments

i should place it at where? inside my <a href?
in the top of ur php file. and in ur a tag ur href should be href='login.php?fn=handleLogin'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.