Jump to content

login system problem


wrathican

Recommended Posts

hi im having a problem with my login system

heres my login page:

<?php
//
session_start();

include '../include/switch.inc';
include '../include/misc.inc';
include '../include/opendb.inc';



$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
   $userId = $_POST['txtUserId'];
   $password = $_POST['txtPassword'];

   // check if the user id and password combination exist in database
   $sql = "SELECT user_name FROM cy_user WHERE user_name = '$userId' AND user_pass = PASSWORD('$password')";

   $result = mysql_query($sql);

   if (mysql_num_rows($result) == 1) {
      // the user id and password match,
      // set the session
      $_SESSION['db_is_logged_in'] = true;

      // after login we move to the main page
      header('Location: cms.php');
      exit;
   } else {
      $errorMessage = 'Sorry, wrong user id / password';
   }
}

?>



<HTML>
<HEAD>
<TITLE>CycleYorkshire.co.uk: Content Management System</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../cy.css">
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0><center>
<!-- ImageReady Slices (layout_concept3.psd) -->
<TABLE WIDTH=800 BORDER=0 CELLPADDING=0 CELLSPACING=0>
  <!--DWLayoutTable-->
<TR>
	<TD height="301" COLSPAN=2 valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
	    <TD width="800" height="11" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_01.gif" WIDTH=800 HEIGHT=11 ALT=""></TD>
	</tr>
	  <tr>
	    <TD height="290" valign="top">
		  <a href="index.php"><IMG SRC="../images/cycleyorkshirebase_02.gif" ALT="" WIDTH=800 HEIGHT=290 border="0"></a></TD>
	</tr>
    </table>		</TD>
    </TR>

<TR>
	<TD width="216" height="751" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
	    <TD width="200" height="23" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_03.gif" WIDTH=200 HEIGHT=23 ALT=""></TD>
	    <td width="16" rowspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	      <!--DWLayoutTable-->
	      <tr>
	        <td width="16" height="751"> </td>
          </tr>
	      </table>		    </td>
	  </tr>
	  <tr>
	    <TD height="420" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	      <!--DWLayoutTable-->
	      <tr>
	        <?php include '../include/navicms.inc'; ?>
	  </tr>
	      
          </table></TD>
      </tr>
	  <tr>
	    <TD height="58" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_26.gif" WIDTH=200 HEIGHT=58 ALT=""></TD>
      </tr>
	  <tr>
	    <TD height="19" valign="top"><p><?php //get the 'this weekend' and display 
		$query = "SELECT * FROM cy_weekend";
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result,MYSQL_NUM))
		{
		$body = $row[1];
		}
		echo $body;?></p></TD>
      </tr>
	  <tr>
	    <TD height="231" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_30.gif" WIDTH=200 HEIGHT=231 ALT=""></TD>
      </tr>
    </table></TD>
	<TD width="584" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
	    <TD height="19" colspan="2" valign="top"><h1>Please login to the CMS</h1></TD>
	</tr>
	  <tr>
	    <TD height="19" colspan="2" valign="top"><p>Please enter login details below:<br />
  <br />
Username:<br />  <form action="login.php" method="post">
  <input type="text" name="textfield" />
  <br />
Password:<br />
  <input type="password" name="textfield2" />
  <br />
  <br />  
  <input type="submit" name="Submit" value="Submit" /></form></p></TD>
	</tr>
	  <tr>
	    <TD height="1"> </TD>
	    <TD></TD>
      </tr>
	  </table></TD>
    </TR>
<TR>

</center>
</BODY>
</HTML>

when i submit the form i just see the form again.... it should redirect me to another page but it doesnt... and i dont get any errors

Link to comment
https://forums.phpfreaks.com/topic/58048-login-system-problem/
Share on other sites

Change ur code to this and try it:

 

<?php
session_start();

include '../include/switch.inc';
include '../include/misc.inc';
include '../include/opendb.inc';

$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
   $userId = $_POST['txtUserId'];
   $password = $_POST['txtPassword'];

   // check if the user id and password combination exist in database
   $sql = "SELECT user_name FROM cy_user WHERE user_name = '$userId' AND user_pass = PASSWORD('$password')";

   $result = mysql_query($sql);

   if (mysql_num_rows($result) == 1) {
      // the user id and password match,
      // set the session
      $_SESSION['db_is_logged_in'] = true;

      // after login we move to the main page
      header('Location: cms.php');
      exit;
   } else {
      $errorMessage = 'Sorry, wrong user id / password';
   }
}
else {
?>



<HTML>
<HEAD>
<TITLE>CycleYorkshire.co.uk: Content Management System</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../cy.css">
</HEAD>
<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0><center>
<!-- ImageReady Slices (layout_concept3.psd) -->
<TABLE WIDTH=800 BORDER=0 CELLPADDING=0 CELLSPACING=0>
  <!--DWLayoutTable-->
<TR>
	<TD height="301" COLSPAN=2 valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
	    <TD width="800" height="11" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_01.gif" WIDTH=800 HEIGHT=11 ALT=""></TD>
	</tr>
	  <tr>
	    <TD height="290" valign="top">
		  <a href="index.php"><IMG SRC="../images/cycleyorkshirebase_02.gif" ALT="" WIDTH=800 HEIGHT=290 border="0"></a></TD>
	</tr>
    </table>		</TD>
    </TR>

<TR>
	<TD width="216" height="751" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
	    <TD width="200" height="23" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_03.gif" WIDTH=200 HEIGHT=23 ALT=""></TD>
	    <td width="16" rowspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	      <!--DWLayoutTable-->
	      <tr>
	        <td width="16" height="751"> </td>
          </tr>
	      </table>		    </td>
	  </tr>
	  <tr>
	    <TD height="420" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	      <!--DWLayoutTable-->
	      <tr>
	        <?php include '../include/navicms.inc'; ?>
	  </tr>
	      
          </table></TD>
      </tr>
	  <tr>
	    <TD height="58" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_26.gif" WIDTH=200 HEIGHT=58 ALT=""></TD>
      </tr>
	  <tr>
	    <TD height="19" valign="top"><p><?php //get the 'this weekend' and display 
		$query = "SELECT * FROM cy_weekend";
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result,MYSQL_NUM))
		{
		$body = $row[1];
		}
		echo $body;?></p></TD>
      </tr>
	  <tr>
	    <TD height="231" valign="top">
		  <IMG SRC="../images/cycleyorkshirebase_30.gif" WIDTH=200 HEIGHT=231 ALT=""></TD>
      </tr>
    </table></TD>
	<TD width="584" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
	  <!--DWLayoutTable-->
	  <tr>
	    <TD height="19" colspan="2" valign="top"><h1>Please login to the CMS</h1></TD>
	</tr>
	  <tr>
	    <TD height="19" colspan="2" valign="top"><p>Please enter login details below:<br />
  <br />
Username:<br />  <form action="login.php" method="post">
  <input type="text" name="textfield" />
  <br />
Password:<br />
  <input type="password" name="textfield2" />
  <br />
  <br />  
  <input type="submit" name="Submit" value="Submit" /></form></p></TD>
	</tr>
	  <tr>
	    <TD height="1"> </TD>
	    <TD></TD>
      </tr>
	  </table></TD>
    </TR>
<TR>

</center>
</BODY>
</HTML>
<?php
}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/58048-login-system-problem/#findComment-287776
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.