Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logging into Site

Status
Not open for further replies.

Sitehelp

Technical User
Feb 4, 2004
142
GB
Ok I am really stuck. I have posted this question b4 but I am still puzzled how to get this going. Basically I have a MYSql Database, I want the users details crossed checked against the database and then if correct have them logged in through sessions. However, I can do one or another but I cannot get the users details to cross check against the Database AND then log them in through sessions. I think its the layout of my code but I cant work out what goes where, I have been told its Header etc.. then content. I have tried this but I must be doing something wrong. Here is the code (sorry its a little long):

<?php require_once('../Connections/MARTIN.php'); ?>
<?php
mysql_select_db($database_MARTIN, $MARTIN);
$query_Connect = &quot;SELECT * FROM clientinfo&quot;;
$Connect = mysql_query($query_Connect, $MARTIN) or die(mysql_error());
$row_Connect = mysql_fetch_assoc($Connect);
$totalRows_Connect = mysql_num_rows($Connect);
?>
<?php session_start(); ?>
<?php
$sql = &quot;SELECT ClientID, cpassword, CDept FROM clientinfo
WHERE ClientID='$ClientID'
AND cpassword='$Password'
AND Cdept = '$CDept'&quot;;

$result = mysql_query($sql)
or die(&quot;Error: MySQL said &quot;.mysql_error());
$num = mysql_num_rows($result);
$row = mysql_fetch_assoc($result);

if ($num == 1)
header(&quot;location: Logged In/WelcomeUserPage.php&quot;);
?>
<html>
<head>
<title>HomePage</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body>
<p align=&quot;center&quot;><img src=&quot;Sites%20Title%20Border.png&quot; width=&quot;799&quot; height=&quot;89&quot;></p>
<form action = &quot;&quot;>
<div align=&quot;left&quot;>
<p align=&quot;center&quot;><font color=&quot;Black&quot; size=&quot;5&quot;>Welcome to IT Help-OnLine</font></p>
<p align=&quot;center&quot;>&nbsp;</p>
</div>
<blockquote>
<blockquote>
<p align=&quot;center&quot;> Please enter your <i>Client ID</i> and <i>Password</i>
below. <br>
Client ID:<font color=&quot;#FFFFFF&quot;>::</font>
<input text type=&quot;text&quot; size=&quot;20&quot;
maxlength=&quot;20&quot; name=&quot;ClientID&quot;>
<br>
Password:
<input text type=&quot;Password&quot; size&quot;15&quot;
maxlength=&quot;20&quot; name=&quot;Password&quot;>
</p>
<p align=&quot;center&quot;> Department
<select name=&quot;CDept&quot; size=&quot;1&quot; id=&quot;CDept&quot;>
<option value=&quot;Unknown&quot;>Select</option>
<option value=&quot;Unknown&quot;>-----</option>
<option value=&quot;XRay&quot;>XRay</option>
<option value=&quot;Computing&quot;>Computing</option>
<option value=&quot;Renal&quot;>Renal</option>
<option value=&quot;Cardio&quot;>Cardio</option>
<option value=&quot;Heart Center&quot;>Heart Center</option>
<option value=&quot;Medical Health&quot;>Medical Health</option>
<option value=&quot;Diabetes&quot;>Diabetes</option>
<option value=&quot;Histology&quot;>Histology</option>
<option value=&quot;Ward 1-12&quot;>Ward 1-12</option>
<option value=&quot;Ward 13-20&quot;>Ward 13-20</option>
</select>
<br>
<br>
<input type = &quot;submit&quot; value=&quot;Click To Submit&quot;>
<input type = &quot;reset&quot; value=&quot;Reset&quot;>
<?php
//$Home_Page='Welcome back';
session_register('Home_Page');
?>
</p>
</blockquote>
</blockquote>
</form>
<div align=&quot;center&quot;>
<p><br>
</p>
<p>If you are a new user please click <a href=&quot;New User Details/NewUserDetails.php&quot; target=&quot;_top&quot;>here</a>.
</p>
<p>Administrators log on <a href=&quot;Staff&Admin%20Login%20Page/Staff&Admin%20Login%20Page.php&quot;>here</a>
</p>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href=&quot;mailto:mkennelly@hotmail.com&quot;>Email</a> us here</p>
</body>
</html>
<?php
mysql_free_result($Connect);
?>

Cheers for this as this is a very important section of my site. Thanks!
 
We discussed this in thread434-775341

I asked you a question about code I gave you and you never answered my question.

Now you are starting over again with the same code you posted in that previous thread.


Here are the problems as I see them.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top