twilightnights Posted January 30, 2007 Share Posted January 30, 2007 Been messing with this awhile and I can't get it to post at all. The html works without this in it. [code]<?phpsession_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 More sharing options...
twilightnights Posted January 30, 2007 Author Share Posted January 30, 2007 something is wrong with[code]$_SESSION['userID'] = $user_info['userID']; $_SESSION['username'] = $user_info['username'];[/code]everything else works Link to comment https://forums.phpfreaks.com/topic/36406-whats-wrong/#findComment-173201 Share on other sites More sharing options...
boo_lolly Posted January 30, 2007 Share Posted January 30, 2007 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 More sharing options...
twilightnights Posted January 30, 2007 Author Share Posted January 30, 2007 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 databaseand username is username Link to comment https://forums.phpfreaks.com/topic/36406-whats-wrong/#findComment-173212 Share on other sites More sharing options...
twilightnights Posted January 30, 2007 Author Share Posted January 30, 2007 Ack.. had a brace in the wrong spot. thanks for help Link to comment https://forums.phpfreaks.com/topic/36406-whats-wrong/#findComment-173215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.