Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,852 members, 7,810,280 topics. Date: Saturday, 27 April 2024 at 04:45 AM |
Nairaland Forum / Science/Technology / Programming / Can Someone Kindly Help Me Correct This Error (1423 Views)
Please Kindly Help With This JSON Code / Please Kindly Help With This Html/javascript Problem. / Pls Help Correct This Code (2) (3) (4)
Can Someone Kindly Help Me Correct This Error by xlim: 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...
|
Re: Can Someone Kindly Help Me Correct This Error by xlim: 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
is meant to be
there 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: 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
|
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.
Solution should clearly be:
|
(1) (Reply)
PDF, DOC, DOCX To Text Converter Software / Procedures On How To Build Your Business Website From The Scratch / Pls Help A New Programmer
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 25 |