matthewst Posted April 11, 2007 Share Posted April 11, 2007 FYI: I inherited this website from the previous computer guy. My php login page <? session_start(); if($submit || $FrontPage) { include('db_con.php'); $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM 123_table WHERE rest_username='$username' AND rest_pass = '$password' AND table_id = '$id'", $db_link); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); if($exists) { $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; echo '<script type="text/javascript"> location="home.php" </script>'; }else{ $login_fail="true"; } } ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive 5"> <title>Admin Page :: Login</title> </head> <body bgcolor="#ffffff"> <div align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">You're loged in!: <? echo $id; ?><br> <br> <? if ($login_fail=="true"){ echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>"; } ?><br> <form name="FormName" action="<?=$PHP_SELF;?>" method="post"> <table border="0" cellpadding="0" cellspacing="2" width="180"> <tr height="19"> <td colspan="2" height="19"> <div align="center"> <font size="3"><b> Login</b></font></div> </td> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" CLASS="formTextbox" size="24"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" CLASS="formTextbox" size="24"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input type="submit" CLASS="formTextbox" name="submit" value="Login"></div> </td> </tr> </table> </form> </font></div> </body> </html> My database has a table called 123_table, in that table are fields named rest_username, rest_pass, contact_fname and table_id My db_con <? $db_hostname = "localhost"; $db_name = "DBNAME"; $db_username = "USERNAME"; $db_password = "PASSWORD"; $db_link = @mysql_connect($db_hostname, $db_username, $db_password); $db_get = mysql_select_db($db_name, $db_link); ?> When I try to login it says "login incorrect, please try again". Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/ Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 Nothing to do with the DB really, you have register_globals off and you are calling the variables like it is on, try this: <?php session_start(); // dunno if the or is correct here... if(isset($_POST['submit'] || isset($_POST['FrontPage']) { include('db_con.php'); // also not suer where $id comes from? $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM 123_table WHERE rest_username='".$_POST['$username']."' AND rest_pass = '".$_POST['password']."' AND table_id = '".$id."'", $db_link); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); if($exists) { $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; echo '<script type="text/javascript"> location="home.php" </script>'; }else{ $login_fail="true"; } } ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive 5"> <title>Admin Page :: Login</title> </head> <body bgcolor="#ffffff"> <div align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">You're loged in!: <? echo $id; ?><br> <br> <? if ($login_fail=="true"){ echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>"; } ?><br> <form name="FormName" action="<?=$PHP_SELF;?>" method="post"> <table border="0" cellpadding="0" cellspacing="2" width="180"> <tr height="19"> <td colspan="2" height="19"> <div align="center"> <font size="3"><b> Login</b></font></div> </td> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" CLASS="formTextbox" size="24"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" CLASS="formTextbox" size="24"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input type="submit" CLASS="formTextbox" name="submit" value="Login"></div> </td> </tr> </table> </form> </font></div> </body> </html> Give that a try. Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227133 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 Still no good With your code I get a parse error on line 5. Parse error: syntax error, unexpected '{' in /Library/Tenon/WebServer/WebSites/SITENAME/admin/rest_site_creation/mgmt_index.php on line 5 Line 4 - 6: // dunno if the or is correct here... if(isset($_POST['submit']) || isset($_POST['FrontPage']) { include('db_con.php'); If I change line 5 to this: if($submit || $FrontPage) { It loads fine but gives me the "login incorrect error". I "played" with the syntax but still can't seem to get it to work. Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227544 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 FYI my login page is owned by www with read write, the group is www read write, and i gave everyone read write jus to be safe [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227557 Share on other sites More sharing options...
trq Posted April 12, 2007 Share Posted April 12, 2007 There is a simple parse error. Change... if(isset($_POST['submit']) || isset($_POST['FrontPage']) { to... if (isset($_POST['submit']) || isset($_POST['FrontPage'])) { Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227571 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 changed that, now i get a different error Parse error: syntax error, unexpected T_IF in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/mgmt_index.php on line 6 line 6: if (isset($_POST['submit']) || isset($_POST['FrontPage'])) { Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227590 Share on other sites More sharing options...
trq Posted April 12, 2007 Share Posted April 12, 2007 Can we see the code a few lines before this? Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227594 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 change to <?php session_start(); // dunno if the or is correct here... if(isset($_POST['submit']) || isset($_POST['FrontPage'])) { include('db_con.php'); // also not suer where $id comes from? $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM 123_table WHERE rest_username='".$_POST['$username']."' AND rest_pass = '".$_POST['password']."' AND table_id = '".$id."'", $db_link); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); if($exists) { $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; echo '<script type="text/javascript"> location="home.php" </script>'; }else{ $login_fail="true"; } } } ?> EDIT: was missing the end } Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227597 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 here is what the code looks like now <?php session_start(); error_reporting(E_ALL) if($submit || $FrontPage) { include('db_con.php'); $sql = "SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password' AND table_id = '$id'"; echo 'DEBUG: '.$sql.'<br />'; $User_Exists = mysql_query($sql) or die(mysql_error()); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); var_dump($row); $username = $_POST['username']; $password = $_POST['password']; $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='".$_POST['$username']."' AND rest_pass = '".$_POST['password']."', $db_link); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); if($exists) { $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; echo '<script type="text/javascript"> location="home.php" </script>'; }else{ $login_fail="true"; } } ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive 5"> <title>Admin Page :: Login</title> </head> <body bgcolor="#ffffff"> <div align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">Please log in: <? echo $id; ?><br> <br> <? if ($login_fail=="true"){ echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>"; } ?><br> <form name="FormName" action="<?=$PHP_SELF;?>" method="post"> <table border="0" cellpadding="0" cellspacing="2" width="180"> <tr height="19"> <td colspan="2" height="19"> <div align="center"> <font size="3"><b> Login</b></font></div> </td> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" CLASS="formTextbox" size="24"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" CLASS="formTextbox" size="24"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input type="submit" CLASS="formTextbox" name="submit" value="Login"></div> </td> </tr> </table> </form> </font></div> </body> </html> i removed id from the query and added som debugging Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227602 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 change $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='".$_POST['$username']."' AND rest_pass = '".$_POST['password']."', $db_link); to $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='".$_POST['$username']."' AND rest_pass = '".$_POST['password']."'", $db_link); end " Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227604 Share on other sites More sharing options...
trq Posted April 12, 2007 Share Posted April 12, 2007 Well, now the code youve posted doesn't even contain the line... if (isset($_POST['submit']) || isset($_POST['FrontPage'])) { which you said was the one giving the error. The only error I can see in the code youve posted is, once again, youve switched back to... if($submit || $FrontPage) { which will not work on most (if not all) servers. And, your second query is foobared. $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='".$_POST['$username']."' AND rest_pass = '".$_POST['password']."'", $db_link); Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227605 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 added the quote techie, still no good sorry thorpe I have two versions of the same page open trying different syntax in each one i get the same line 6 error in both pages Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227621 Share on other sites More sharing options...
trq Posted April 12, 2007 Share Posted April 12, 2007 Your missing the closing ; on this line... error_reporting(E_ALL) Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227639 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 made a little progress. when the page loads it gives me an error: Notice: Undefined variable: login_fail in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/mgmt_index.php on line 51 line 51: <? if ($login_fail=="true"){ when i login with a user and pass that is in the database it just reloads the page but when I try it with a user and pass that are not in the database it says incorrect login , please try again <?php error_reporting(E_ALL); session_start(); include('db_con.php'); if(isset($_POST['submit'])) { $sql = "SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'"; echo 'DEBUG: '.$sql.'<br />'; $User_Exists = mysql_query($sql) or die(mysql_error()); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); var_dump($row); $username = $_POST['username']; $password = $_POST['password']; $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'", $db_link); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); if($exists > 0) { $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; echo '<script type="text/javascript"> location="home.php" * * * </script>'; }else{ $login_fail="true"; print_r($_SESSION); print_r($_POST); } } ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive 5"> <title>Admin Page :: Login</title> </head> <body bgcolor="#ffffff"> <div align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">Please log in: <br> <br> <? if ($login_fail=="true"){ echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>"; } ?><br> <form name="FormName" action="<?=$PHP_SELF;?>" method="post"> <table border="0" cellpadding="0" cellspacing="2" width="180"> <tr height="19"> <td colspan="2" height="19"> <div align="center"> <font size="3"><b> Login</b></font></div> </td> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" CLASS="formTextbox" size="24"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" CLASS="formTextbox" size="24"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input type="submit" CLASS="formTextbox" name="submit" value="Login"></div> </td> </tr> </table> </form> </font></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227655 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 still playing with the syntax. I'm not sure if the problem is on line 51 or if it is really between 32 and 36 lines 32 - 36: }else{ $login_fail="true"; print_r($_SESSION); print_r($_POST); } Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227724 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 add $login_fail="true"; at the top (before the if) Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227746 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 it displays login incorrect even on a fresh load when using a user and pass in the database i get this error: DEBUG: SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='test' AND rest_pass = 'test' array( { [0]=> string(6) "100565" ["table_id"]=> string(6) "100565" [1]=> string(4) "test" ["rest_username"]=> string(4) "test" [2]=> string(4) "test" ["rest_pass"]=> string(4) "test" [3]=> string(13) "Paul & Sharon" ["contact_fname"]=> string(13) "Paul & Sharon" } Warning: Cannot modify header information - headers already sent by (output started at /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/mgmt_index.php:10) in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/mgmt_index.php on line 29 when i use a user an pass not in the database i get this error: DEBUG: SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='sdfsf' AND rest_pass = 'sdfwer' bool(false) Array ( [track_id] => 100565 [track_name] => Paul & Sharon ) Array ( [username] => sdfsf [password] => sdfwer [submit] => Login ) here is the code as it is now: <?php error_reporting(E_ALL); session_start(); include('db_con.php'); $login_fail="true"; if(isset($_POST['submit'])) { $sql = "SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'"; echo 'DEBUG: '.$sql.'<br />'; $User_Exists = mysql_query($sql) or die(mysql_error()); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); var_dump($row); $username = $_POST['username']; $password = $_POST['password']; $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'", $db_link); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); if($exists > 0) { $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; $login_fail = false; header("Location: home.php"); exit; }else{ $login_fail="true"; print_r($_SESSION); print_r($_POST); } } ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive 5"> <title>Admin Page :: Login</title> </head> <body bgcolor="#ffffff"> <div align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">Please log in: <br> <br> <? if ($login_fail=="true"){ echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>"; } ?><br> <form name="FormName" action="<?=$PHP_SELF;?>" method="post"> <table border="0" cellpadding="0" cellspacing="2" width="180"> <tr height="19"> <td colspan="2" height="19"> <div align="center"> <font size="3"><b> Login</b></font></div> </td> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" CLASS="formTextbox" size="24"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" CLASS="formTextbox" size="24"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input type="submit" CLASS="formTextbox" name="submit" value="Login"></div> </td> </tr> </table> </form> </font></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227831 Share on other sites More sharing options...
MadTechie Posted April 12, 2007 Share Posted April 12, 2007 well your $username = $_POST['username']; $password = $_POST['password']; need to be directly after the if(isset($_POST['submit'])) { Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227836 Share on other sites More sharing options...
matthewst Posted April 12, 2007 Author Share Posted April 12, 2007 almost there, currently looks like this: <?php //error_reporting(E_ALL); session_start(); include('db_con.php'); $login_fail="false"; if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; //$sql = "SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'"; //echo 'DEBUG: '.$sql.'<br />'; //$User_Exists = mysql_query($sql) or die(mysql_error()); //$exists = mysql_num_rows($User_Exists); //$row = mysql_fetch_array($User_Exists); //var_dump($row); $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'", $db_link); $exists = mysql_num_rows($User_Exists); $row = mysql_fetch_array($User_Exists); if($exists > 0) { $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; echo '<script type="text/javascript"> location="home.php" </script>'; }else{ $login_fail="true"; } } ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive 5"> <title>Admin Page :: Login</title> </head> <body bgcolor="#ffffff"> <div align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">Please log in: <br> <br> <? if ($login_fail=="true"){ echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>"; } ?><br> <form name="FormName" action="<?=$PHP_SELF;?>" method="post"> <table border="0" cellpadding="0" cellspacing="2" width="180"> <tr height="19"> <td colspan="2" height="19"> <div align="center"> <font size="3"><b> Login</b></font></div> </td> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" CLASS="formTextbox" size="24"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" CLASS="formTextbox" size="24"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input type="submit" CLASS="formTextbox" name="submit" value="Login"></div> </td> </tr> </table> </form> </font></div> </body> </html> with a user and pass not in the database it displays login incorrect with a user and pass in the database it takes me to index.php which doesn't exist (i think home.php is supposed to generate index.php with the current users credentials) let me give you the long story. this site is for people who are "members" of a sales group. the bosses thaought it would be a good idea for each sales rep to have there own website. we (the it dept) thought it would be better if they used a simple templet. at the time all this went down i was just a pc tech. now i've been thrust into the fast moving world of website stuff. I'm going to go beat my head against the wall for a while. If anyone can have a look at this and tell me how to fix it I will forever refer him/her as the the royal highness of php [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227900 Share on other sites More sharing options...
per1os Posted April 12, 2007 Share Posted April 12, 2007 Alright man your code was bugging the crap out of me. I revamped it. Basically on BOOLs (TRUE/FALSE) you do not need "" around them when you are using them like you are, it just causes extra "work" as to say. I changed them to be what they are...boolean and not a string. This way in if statements you can just do if($bool) means if $bool is true than do that or if (!$bool) if $bool is false. Instead of the $bool == "true" makes the code nicer. I also moved the mysql_Fetch_array into the if exists portion, because if there are no rows no reason to waste time trying to fetch an array right? I also changed the javascript, because I think your syntax was off to a header, which should be faster. You will need to change the www.yoursite.com to yoursite. Here it is <?php session_start(); include('db_con.php'); // you do not need "'s around true or flase, php handles just fine as a bool type. $login_fail=false; if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; //$sql = "SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'"; $User_Exists = mysql_query("SELECT table_id, rest_username, rest_pass, contact_fname FROM abc_tables WHERE rest_username='$username' AND rest_pass = '$password'", $db_link); $exists = mysql_num_rows($User_Exists); if($exists > 0) { $row = mysql_fetch_array($User_Exists); $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; header("Location: http://www.yoursite.com/home.php"); die(); }else { $login_fail=true; } } ?> <html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <meta name="generator" content="Adobe GoLive 5"> <title>Admin Page :: Login</title> </head> <body bgcolor="#ffffff"> <div align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">Please log in: <br> <br> <? // no need to == it to true. if ($login_fail){ echo "<b><font color='#cc0033' face='Verdana, Arial, Helvetica, sans-serif'>Login Incorrect, please try again</font></b>"; } ?><br> <form name="FormName" action="<?php print $_SERVER['PHP_SELF'];?>" method="post"> <table border="0" cellpadding="0" cellspacing="2" width="180"> <tr height="19"> <td colspan="2" height="19"> <div align="center"> <font size="3"><b> Login</b></font></div> </td> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" CLASS="formTextbox" size="24"></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="password" CLASS="formTextbox" size="24"></td> </tr> <tr> <td colspan="2"> <div align="center"> <input type="submit" CLASS="formTextbox" name="submit" value="Login"></div> </td> </tr> </table> </form> </font></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-227924 Share on other sites More sharing options...
matthewst Posted April 13, 2007 Author Share Posted April 13, 2007 Frost you kick so much friggin a$$. You probably have to stay out side because no man made structure can contain your amount of awesome! Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-228700 Share on other sites More sharing options...
matthewst Posted April 13, 2007 Author Share Posted April 13, 2007 Techie and Thorpe...you guys ROCK! Thanks for all the help. I think I'm starting to get the hang of this thanks to you two. Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-228703 Share on other sites More sharing options...
matthewst Posted April 13, 2007 Author Share Posted April 13, 2007 On to noobie problem number two. After a successful login (thanks to phpfreaks, mad techie, thorpe, and frost) my users are presented with an "administration" type panel page (home.php). The top of the page is supposed to say "Welcome to your administration panel ID:" then it is suppose to display there id. It is not. Line 110 of home.php: <font face="Verdana, Arial, Helvetica, sans-serif">Welcome to your administration panel ID: <? echo $id; ?><br> I believe it is trying to get the id from a veriable in id.php id.php: <?php session_start(); include('db_con.php'); $_SESSION['track_id'] = $row['table_id']; $_SESSION['track_name'] = $row['contact_fname']; ?> When a user logs in the system is supposed to store their table_id (which is the same as their rest_id). Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-228718 Share on other sites More sharing options...
matthewst Posted April 13, 2007 Author Share Posted April 13, 2007 I turned on error reporting and got this Notice: A session had already been started - ignoring session_start() in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/id.php on line 2 Notice: Undefined variable: row in /Library/Tenon/WebServer/WebSites/www.ABCAdvertising.net/admin/rest_site_creation/id.php on line 4 Notice: Undefined variable: row in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/id.php on line 5 Notice: Undefined variable: id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 43 Notice: Undefined variable: set_style_id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 50 Welcome to your administration panel ID: Notice: Undefined variable: id in /Library/Tenon/WebServer/WebSites/admin/rest_site_creation/home.php on line 110 It's not storing the veriable in the id.php What am I missing? Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-228735 Share on other sites More sharing options...
MadTechie Posted April 13, 2007 Share Posted April 13, 2007 session_start(); MUST! be used before any other output to the screen either move it to the start or use ob_flush(); Quote Link to comment https://forums.phpfreaks.com/topic/46639-solved-why-isnt-php-seeing-the-database/#findComment-228869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.