Can Someone Kindly Help Me Correct This Error - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Can Someone Kindly Help Me Correct This Error (1716 Views)
| Can Someone Kindly Help Me Correct This Error by xlim(op): 11:19am On Nov 19, 2014 |
<?php // Inialize session session_start(); // Include database connection settings $hostname = 'localhost'; // Your MySQL hostname. Usualy named as 'localhost', so you're NOT necessary to change this even this script has already online on the internet. $dbname = 'zclass'; // Your database name. $username = 'root'; // Your database username. $password = ''; // Your database password. If your database has no password, leave it empty. // Let's connect to host mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!'); // Select the database mysql_select_db($dbname) or DIE('Database name is not available!'); // Retrieve username and password from database according to user's input $userName=mysql_real_escape_string($_POST['name1']); $userSchool=mysql_real_escape_string($_POST['school1']); $userClass=mysql_real_escape_string($_POST['class1']); //*********retrieving data from Database********** $query = "SELECT * FROM member WHERE $userName='name1', $userSchool='school1' and $userClass='class1'"; //$login = mysqli_query("SELECT userName,password FROM 'member' WHERE userName= $_post['username'] AND passWord= $_post['password'])" ;// Check username and password match $res = mysql_query($query); $rows = mysql_num_rows($res); if ($rows==1) { // Set username session variable $_SESSION['userName'] = $_POST['name1']; // Jump to secured page header("Location: post.php" ;} else { // Jump to login page echo "user name and password not found"; } exit; ?>
|
| Re: Can Someone Kindly Help Me Correct This Error by zeroshadow: 11:47am On Nov 19, 2014 |
xlim, you didn't state the problem ![]() luckily for you I have "php eyes" ![]() you didn't even put the form ![]() the bolded part below indicates your problem... you might be getting a database error... or undefined variable error... ![]() //*********retrieving data from Database********** |
| Re: Can Someone Kindly Help Me Correct This Error by xlim(op): 11:51am On Nov 19, 2014 |
zeroshadow:it's actually saying username and password not found |
| Re: Can Someone Kindly Help Me Correct This Error by zeroshadow: 12:02pm On Nov 19, 2014 |
xlim:that's because you're calling the variables wrongly // Retrieve username and password from database according to user's inputis meant to be // Retrieve username and password from database according to user's inputthere could be mistakes in my correction but you are not calling the your variables... you're mixing mysql and mysqli(very bad practice)... my battery is dying.. |
| Re: Can Someone Kindly Help Me Correct This Error by xlim(op): 5:00pm On Nov 19, 2014 |
zeroshadow:thanks so much. will work on that now |
| Re: Can Someone Kindly Help Me Correct This Error by zeroshadow: 5:12pm On Nov 19, 2014 |
xlim:If it doesn't work try putting it in an "if Statement" to check if something was typed if(isset($_POST['name1'])&&isset($_POST['school1'])&&isset($_POST['class1'])){ |
| Re: Can Someone Kindly Help Me Correct This Error by Nobody: 7:05pm On Nov 19, 2014 |
trollin. . . |
| Re: Can Someone Kindly Help Me Correct This Error by Nobody: 11:25am On Feb 08, 2015 |
Heheheheheh using mysql_real_escape in $_post, oh lawd! |
| Re: Can Someone Kindly Help Me Correct This Error by tresz: 7:44pm On Feb 08, 2015 |
xlim:Okay! It's okay to make such mistake when just starting PHP. Well, you made 2 mistakes in the above program. 1. WHERE $userName='name1', $userSchool='school1' and $userClass='class1Solution should clearly be: 1. Uncomment $login, and perform a query on it in place of $res, like $login_query = "SELECT * FROM member WHERE username='$Username' AND password='$password'"; |
Please Kindly Help With This JSON Code • Please Kindly Help With This Html/javascript Problem. • Pls Help Correct This Code • 2 • 3 • 4
I Need HELP With This Python Problem • How Do You Write Programs With Your Mobile Phone • I Need A React Native Developer For A Side Gig (remote Is Welcome)
;