I want to write a function to -log users in / check log in details- that uses $_POST['first_name '] and $_POST['password'] as parameters. I must be doing something silly. Can someone help me out??
function log_user_in($_POST['first_name'],$_POST['password']) {
if ( !empty($_POST['first_name']) && !empty($_POST['password']) ) {
$first_name = $_POST['first_name'];
$first_name = mysqli_real_escape_string($dbc, $first_name);
$password = $_POST['password'];
$password = mysqli_real_escape_string($dbc, $password);
---mysqli queries----
session_start();
redirect_user('page.php');
} // close if all set
} // close function log user in
I get the feeling, that $_POST['information'] cannot be used as parameters/arguments in functions, I may be wrong, in which case how do I substitute them for variables or something e.g.
function log_user_in ($a, $b) {
if ( !empty($a) && !empty($b) ) {
$first_name = $a;
$first_name = mysqli_real_escape_string($dbc, $first_name);
$password = $b;
$password = mysqli_real_escape_string($dbc, $password);
--- mysqli stuff ---
session_start();
redirect_user('page.php');
} // close if all set
} // close function log_user_in
and then call--
log_user_in($_POST['first_name'],$_POST['password']);
Can you tell me where I'm going wrong and what I can do to improve or give me a better method, thanks people!
J