Jump to content

Whats wrong?


twilightnights

Recommended Posts

Been messing with this awhile and I can't get it to post at all. The html works without this in it.

[code]
<?php
session_start();

include("dbinfouser.inc.php");
include("dbconnectuser.inc.php");


$user=$_POST['userID'];
$upw=$_POST['upw'];


if($user==null)
{

}
else
{

$query = "SELECT * FROM `$table` WHERE userName='$user'";
$num = mysql_query($query);
$usersfound = mysql_num_rows($num);

    if ($usersfound < 1)
{
  $error = "User $user not found.";

}
  else
{
  $query2 = "SELECT * FROM `$table` WHERE username='$user'";
  $user_info = mysql_fetch_array(mysql_query($query2));
  $pass = $user_info['userPass'];
    if ($pass != $upw)
{
        $error = "Invalid password.  Try again.";
  }
        }
    else

{

$_SESSION['userID'] = $user_info['userID'];
$_SESSION['username'] = $user_info['username'];

}

}

?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/36406-whats-wrong/
Share on other sites

i think this is what you want:
[code]
<?php
session_start();

include("dbinfouser.inc.php");
include("dbconnectuser.inc.php");

$error = "";
if(isset($_POST['userID']) && isset($_POST['upw']){
$user = $_POST['userID'];
$upw = $_POST['upw'];

$query = "SELECT * FROM ". $table ." WHERE userName = ". $user ."";
$num = mysql_query($query);
$usersfound = mysql_num_rows($num);

if($usersfound < 1){
  $error .= "User: ". $user ." not found.<br />\n";
}else{
$query2 = "SELECT * FROM ". $table ." WHERE username = ". $user ."";
while($user_info = mysql_fetch_array(mysql_query($query2))){
$pass = $user_info['userPass'];
if($pass != $upw){
$error .= "Invalid password.  Try again.<br />\n";
}else{
$_SESSION['userID'] = $user_info['userID'];
$_SESSION['username'] = $user_info['username'];
}

}
}
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/36406-whats-wrong/#findComment-173211
Share on other sites

Thanks but I got everything working except this part

[code]
$_SESSION['userID'] = $user_info['userID'];
$_SESSION['username'] = $user_info['username'];
[/code]

When I add this in at the end it won't load.  Everything else works ok.

my userID field is userID in the database

and username is username
Link to comment
https://forums.phpfreaks.com/topic/36406-whats-wrong/#findComment-173212
Share on other sites

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.