Jump to content

Recommended Posts

 

heres whats happenin

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in  on line 23

 

 

<?php

 

$host = localhost;

$dbuser =  tritusco_jeff;

$dbpass = ***********;

$dbname = tritusco_users;

 

$connection = mysql_connect($host, $dbuser, $dbpass);

 

 

$db = mysql_select_db(prefix_dbname, $connection);

 

$sql = "SELECT id FROM user

WHERE email='$_POST'

AND pass='$_POST[pass]'";

 

$result = mysql_query($sql);

$num = mysql_num_rows($result);

if ($num > 0) {

//CHECK IF USER AND PASS ARE CORRECT

$id = mysql_fetch_assoc($result);

 

setcookie ("auth", "yes", time()+3600);

setcookie ("id", $id['id']);

setcookie ("email", $id['email']);

 

header ("Location: main.php");

 

}else{

 

};

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/69264-ned-help-with-login-script/
Share on other sites

There is a problem with your query. Try to catch the error like this.

 

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

 

fixed it but it wont select the user from database and log in...  i have it so it encryptys the password when they sign up would that have ne thing to do with it?

show the code that encrypt user pass !

 

 

its in $sql

 

 

<?php

 

 

 

$host = localhost;

$dbuser =  tritusco_jeff;

$dbpass = '*****';

$dbname = tritusco_users;

 

$dbconn = mysql_connect($host, $dbuser, $dbpass);

if (!$dbconn) {

  exit('<p>Unable to connect to the' .

  'databse server at this time.</p>');

  } else {

  }

if (!mysql_select_db($dbname)) {

  exit('<p>Unable to locate the users '.

  'database at this time</p>');

  }

$db = mysql_select_db($dbname, $dbconn);

 

//grab data from form

 

$fname = $_POST['fname'];

$lname = $_POST['lname'];

$email = $_POST['email'];

$pass = $_POST['pass'];

$passconf = $_POST['passconf'];

 

 

 

//if else (else if)

if($fname == false || $lname == false || $email == false || $pass == false){

echo "Please fill in all fields.";

};

if($pass != $passconf){

echo "Passwords do not match.";

}else {

$db = mysql_select_db($dbname, $dbconn);

$sql = "INSERT INTO user (date, time, fname, lname, email, pass, level) VALUES (CURDATE(), CURTIME(), '$fname', '$lname', '$email', ENCRYPT('$pass'), 'u')";

 

};

if (mysql_query($sql)) {

  echo '<p>Thanks for registering on CollegeBookTrade.com</p>';

} else {

  echo mysql_error ();

  }

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.