//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?
You can check if the form was submitted. Something like:
<?php
if(isset($_POST)){
handle_login();
} else {
display_login_form();
}
?>
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.
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;
}