Login authentication [help]

Hi,i’m new to php and also studying it through an ebook…There is this code i wrote but whenever i run this script i get ‘Undefined Index in line 7’. here is the code:-

<?php $uname=""; $pword=""; $error_message=""; $num_rows="0"; if ($_SERVER['REQUEST_METHOD'] == 'POST'){ $uname = $_POST['username']; $pword = $_POST['password']; $uname=htmlspecialchars($uname); $pword=htmlspecialchars($pword); } $user_name="root"; $password=""; $database="login"; $server="127.0.0.1"; $db_handle=mysql_connect($server,$user_name,$password); $db_found=mysql_select_db($database); if ($db_found) { $SQL="SELECT * FROM login WHERE ID=13"; $result=mysql_query($SQL); $num_rows=mysql_num_rows($result); if ($result) { if ($num_rows > 0) { session_start(); $_SESSION['login']="1"; header("Location:127.0.0.1:8080/images/"); } else { session_start(); $_SESSION['login']=""; header("Location: baseform.php"); } } else { $error_message="Error loggin in!"; } mysql_close($db_handle); } else { $error_message="Error loggin in!"; } ?> Login Page Username: Password:

Submit:

<?php print $error_message;?>

pls,help me,and also make ur solution eqsy for a newbie like me…thanks.

Interesting an ebook you say? Hmm, I guess it shows that ebooks are getting old, for it is teaching you mysql instead of mysqli or PDO. My recommendation is to swallow the money you spent on the ebook and delete it, then get an updated ebook that doesn’t teach depreciated code. That’s my advice, but I’m sure you will get someone to help you muddle your way through the code and in the process learn code that is not only going to be depreciated but obsolete very soon. Not that I like tooting my own how, but look at my signature if you want to learn how to write a basic registration/login script using PDO (or even mysqli).

Thanks,though,u made a point but is there any other ebook or software that could teach one better,bcos,w3school’s format in teaching php is kinda complicated for beginners.

Sponsor our Newsletter | Privacy Policy | Terms of Service