Jump to content

need some help with a log in


makka

Recommended Posts

hello ive been making a basic login just to expand my knowledge a little this is my page that deals with my login but ive come to a hump in the bridge.. i get a error with this page

<?php
if (isset($_POST['submit'])) {
include('config.php');
$query = "SELECT * FROM `users` WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1";
mysql_query($query) or die(mysql_error());
if (mysql_num_rows($query) != 1) { die("You have entered an invalid username or password."); }
else { echo 'it worked'; }
}
?>

 

the error is

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\x\php+mysql\reg\login.php on line 6

so whats up here also what i don't get now is how do i know which user is which once they are logged in lets say i log in and its just a simply script that will redirect me to ball.php

 

every time i click a this one link i will get one more number added to the msql db if i have a column called num in the db

 

if you try to go to ball.php with out being logged in it will redirect you to the index page simple??

Link to comment
https://forums.phpfreaks.com/topic/49429-need-some-help-with-a-log-in/
Share on other sites

<?php
if (isset($_POST['submit'])) {
include('config.php');
$query = "SELECT * FROM `users` WHERE username='".$_POST["username"]."' AND password='".md5($_POST["password"])."' LIMIT 1";

$result=mysql_query($query) or die(mysql_error());

if (mysql_num_rows($result) < 1) { die("You have entered an invalid username or password."); }
else 
{ echo 'it worked'; 
}
}
?>

try this out. cheerss




Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.