php - find out the error in this code -
this question has answer here:
- reference - error mean in php? 29 answers
<form action="" method="post"> username <input type="text" name="user"><br> password <input type="password" name="pwd"><br> <input type="submit" name="login" value="login"> <?php login(); ?> </form>
this code give error that
fatal error: call undefined function login() in /var/www/trainees/bhupender/cms/admin.php on line 10.
this function.php files coding
function login() {
if(!isset($_post['username'])) return; global $link; $query = "select * `b_user` username = '{$_post['username']}' , password = '{$_post['password']}'"; $result = mysqli_query($link, $query); $no_of_results = mysqli_num_rows($result); echo $no_of_results; if($no_of_results === 1){ $row = mysqli_fetch_array($result,mysqli_assoc); $row['id']; $_session['user_id'] = $row['id']; header('location: manage.php'); exit; } else { header('location: index.php'); exit; }
}
why don't use
<?php function login() { //function body } if($_post) { login(); } ?>
and html;
<form action="" method="post"> username <input type="text" name="user"><br> password <input type="password" name="pwd"><br> <input type="submit" name="login" value="login"> </form>
Comments
Post a Comment