In my login.php page I have this:
$allowed_operations = array('foo', 'lorem');
if(isset($_GET['p'])
&& in_array(isset($_GET['p']), $allowed_operations)){
switch($_GET['p']){
case 'foo':
// Code for 'foo' goes here
break;
case 'lorem':
// Code for 'lorem' goes here
break;
}
}
Where if I call the url http://example.com/login.php?p=foo the function foo is called.
Is it possible I can call this url without adding a href http://example.com?p=foo in my html markup?
For example something likes this:
<?php
if (array_key_exists("login", $_GET)) {
$p = $_GET['p'];
if ($p == 'foo') {
header("Location: login.php?p=foo"); // This doesn't work
// And if I remove the ?p=foo,
// it redirect to the page but
// the 'foo' function is not called
}
}
?>
and my html:
<a href="?login&p=foo">Login Foo</a> <br />