How and where to add code to login page

I have a login page which uses the Dreamweaver Login Behavior.  I want to add code to:
     Check the status of the person loging in (status is the last field in the mySQL authentication table).
          a.     If the person is already logged in, display an error message, and reject the attempt.
          b.     If the person is NOT currently logged in, set his status accordingly, and log him in.
Since the behavior is generated code, and well above my head, I don't know what code to enter, and where to enter it.  Here's the code for the form:
<?php require_once('Connections/login.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;   
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  return $theValue;
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "WOTCPg1.php";
  $MM_redirectLoginFailed = "loginerror.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_login, $login);
  $LoginRS__query=sprintf("SELECT UserID, Password FROM authentication WHERE UserID=%s AND Password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  $LoginRS = mysql_query($LoginRS__query, $login) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;      
    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    header("Location: " . $MM_redirectLoginSuccess );
  else {
    header("Location: ". $MM_redirectLoginFailed );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function setFocus()
document.getElementById("username").focus();
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Log-in to IOD</title>
<style type="text/css">
<!--
#apDiv3 {
position:absolute;
left:5px;
top:101px;
width:760px;
height:612px;
z-index:2;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
color: #009;
text-align: center;
background-image: url(images/grid_gray.gif);
border: medium ridge #009;
#apDiv1 {
position:absolute;
left:94px;
top:227px;
width:629px;
height:282px;
z-index:3;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: none;
color: #009;
text-align: center;
#apDiv2 {
position:absolute;
left:178px;
top:248px;
width:564px;
height:254px;
z-index:3;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: none;
color: #009;
text-align: left;
border: medium groove #036;
#apDiv4 {
position:absolute;
left:178px;
top:245px;
width:566px;
height:242px;
z-index:3;
border: medium groove #009;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 14pt;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
text-transform: capitalize;
color: #009;
.SubmitButton {
color: #009;
-->
</style>
</head>
<body onLoad="setFocus()" >
<span style="position:absolute; left:3px; top:2px; width:758; height:89;"><img src="sitebuilder/preview/sitebuilder/clipart/bars/regular/horizontal/sleekLines_blue.gif" width="760" height="90" alt="" /></span>
<div id="e2" style="position:absolute; left:13px; top:14px; width:670px; height:32;"><span class="text"><b><span style="font-size: 22px"><font color="#FFFFFF">Sign-in to Information On Demand</font></span><font color="#FFFFFF" size="4"><span style="font-size:22px;line-height:26px;"><br soft="soft" />
</span></font></b></span></div>
<div id="apDiv3">
  <p><span style="text-align: center; text-decoration: underline; color: #009; text-transform: capitalize; font-variant: normal; font-weight: bold; line-height: normal; font-style: normal; font-size: 18pt; font-family: Arial, Helvetica, sans-serif;">Customer Sign-In</span><span style="position:absolute; left:12px; top:23px; width:151px; height:65;"><img src="sitebuilder/images/redInfoOnDemandLogo-150x65.jpg" width="149" height="65" alt="" /></span></p>
</div>
<div id="apDiv4">
<form ACTION="<?php echo $loginFormAction; ?>" id="login" name="login" method="POST">
    <p>     </p>
    <p>User Name:<br /><input name="username" type="text" id="username" tabindex="1" size="30" maxlength="30" />
    </p>
    <p>User's Password:<br />
      <input type="password" name="password" id="password" tabindex="2" />
    </p>
    <p>
      <input name="submit" type="submit" class="SubmitButton" id="submit" tabindex="3" style="color:#009; font-weight:bold" value="Sign-in" />
   <input type="reset" name="reset" id="reset" value="Reset" tabindex="4" style="color:#009; font-weight:bold">
    </p>
  </form>
</div>
<br />
</div>
</body>
</html>
Here's the code for the script "included" in the first line of the page:
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_login = "localhost";  // Change to "mysql" when uploaded to Yahoo
$database_login = "infoondemand";
$username_login = "root";   // Change to "creacontech" when uploaded to Yahoo
$password_login = "raisin4312";
$login = mysql_pconnect($hostname_login, $username_login, $password_login) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Could someone help me with this?  I'd very much appreciate any assistance.

I should have warned you ealier that I don't know PHP very well, but if I can help nail down the process then hopefully one of the PHP experts can jump in.
I'm still a little fuzzy on what is going on.  If Susie and Rodunda both have their own UserIDs and Passwords, then they can both be logged in at the same time, insert records til their hearts content and there will be abolutely no confict at all. The only issue here that may present a problem is if one of them attameps to update a record while the other one is looking at it, or getting ready to make their own modifications.
Also, if Susie and Rodunda have their own user accounts with their own credentials, how is it that one would try to log in using the others' credentials?
At any rate, and hopefully to get closer to a solutions for you, When a user is successfully authenticated, the session variable MM_Username is created.  So, simpy by checking for the existence of this session variable can tell you if that use is logged in or not.  This check can be placed before any of the login script so that it doesn't interfere with the behavior generated code. And you can choose what to do depending on the condition that exists - such as redirecting immediately to another page, or displaying or hiding a certain region on the page.
Keep in mind that when the page first loads, thel login code is placed in an IF statement that checks the form action, so at first it's ignored and loads the form.  When the form is submitted, the IF conditino is met and the code executes.  To update the database with a "Logged in or out" value, you first have to place a recordset just after the IF statement that checks the form action, wirte another IF statement to check the value of the field, and then redirect to a logout page or continue with the login.
If you continue with the login, you'll need an Update statement to change the field in the database just before the successful redirect.  If you've redirected to a log out page, you'll also need s similar update statement there.
To write the recordset code, you can use DW's wizard and just move the code to where it needs to go. But the DW's update code depend on predeifned recordsets and form actions, so you'll need to find a script or hand code it, I wouldn't recommend trying to use DW's code and then modify it.
So, what do you think, are we getting closer?

Similar Messages

  • How and where can I get the hotjava source code?

    Hello.
    I would like to get the hotjava source code..
    How and where can I have it?
    Thanks for your help.

    Ah, Lion manuals are online only.  I'll have to wait until I get my MBP then.  I hope that works for Apple?  But it won't stop me from asking some questions.
    Is there a great deal of difference between Leopard and Lion?

  • How InDesign comes to know about any changes on document, but not saved. As it shows * on the name of document when it is opened and any changes. And after saving * symbol is get removed from the name of document. How and where indesign@ handles this?

    How InDesign comes to know about any changes on document, but not saved. As it shows * on the name of document when it is opened and any changes.
    And after saving * symbol is get removed from the name of document. How and where indesign@ handles this?

    Are you just asking because you want to know, or do you have a problem you need to solve? I don't know how to write a program, but I think what your are describing is not an unusual thing for a  program to do. The * tells you that changes have been made since the last save, and the program reserves a portion of memory for undo functions. I suppose a coder could tell you how it works, but I don't think it would help an average user to know, but that's just my opinion.

  • I shaved my gift card and was ineligible. how and where do I power it uses?

    I shaved my gift card and was ineligible. how and where do I power it use?

    See iTunes Store: Invalid, inactive, or illegible codes.
    tt2

  • How and where can I combine several pdf files?

    I have written a Guide Book for Music Teachers in Word, converted it into a pdf file and would now like to insert sheet music files written with Sibelius Notation Program which have also been converted into pdf files, since they are otherwise not compatible with Word. How and where can these diverse pdf files be combined?

    First, make sure you open Acrobat, and not Adobe Reader.  It's a common mistake.
    From Acrobat, use File | Create | Combine Files into a Single PDF:
    On the next panel you can select the files you want to combine, rearrange them, etc., and finally click Combine.
    P.S. your menu may look slightly different, as we may not be using the same Acrobat version.

  • How and where can I submit a bug report to Nokia ?

    How and where can I submit a bug report to Nokia ? I haven't found any Nokia's webpage where it is explained.

    wait for the next nokia beta test program (they usually annouce it on this forum) and enrol
    then you will have access to the developers to report bugs
    the last beta test finished end of November.. so it will be a while b4 the next beta test
    cheers
    Nokia N95 8GB, 6234, 6101, N-Gage Classic, 8250, 3350, 3315

  • How and where can I order a new set of installation discs?

    I forgotten the administrator's password for my iMac and also lost the original installation discs, just wondering how and where to order a new set.
    There's no Apple store in my city, or near by.

    Apple Store Customer Service at 1-800-676-2775 or visit online Help for more information.
    To contact product and tech support visit online support site.

  • How and where can i do a "User GRANT to SYSADM,SYSCTRL,.." ?

    Hello all,
    the first time we installed a new SAP-System with sapinst on DB2/LUW V9.
    SAP works. (As yet we "drove" DB2 only on z/os)
    SAP Created four db2 User : DB2<SID>, <SID>ADM, SAP<SID> and SAP<SID>DB!
    They all have no "Grant" privilege?
    How and where can i do a User grant to SYSADM,SYSCTRL,.. ,
    there's no admin?
    Thanks a lot!
    Markus

    Hi Markus,
    in addition to explicit GRANTs DB2 LUW has the concept of privileges.
    db2<dbsid> is instance owner and part of the SYSADM group db<dbsid>adm.
    <sapsid>adm is part of the SYSCTRL group db<dbsid>ctl.
    sap<sapsid> is part of the SYSMAINT group db<dbsid>mnt.
    In addtion to that <sapsid>adm is DBADM. This right is explicitly granted during the installation with SAPInst.
    The relationship between OS group and privilege is controlled by the database manager configuration parameters SYSADM, SYSCTRL and SYSMAINT.
    The rights of these privileges are described in the DB2 documentation.
    Regards, Jens

  • How and where can I write a subject matter in a reply I am doing,

    How and where can I write a subject matter in a reply I am doing, I dont want the original subject matter and all I can see is the person to whom I am sending it and cc on the right?

    What are you actually asking about use of webmail ?
    *[[Problems with email and how to find help]]

  • I just updated my iPhone 4s iOS to iOS 8 and but can no longer find personal hotspot, How and where can I find it on my iPhone 4s

    I just updated my iPhone 4s iOS to iOS 8 and but can no longer find personal hotspot, How and where can I find it on my iPhone 4s.
    Usually I share my internet with other device with ios7 but now that I have ios8 on my iPhone 4s I can no longer find the personal hotspot. How can I share internet with other device using ios8 on my iPhone 4s?
    THanks

    Settings>Cellular>Personal Hotspot. The carrier has to support this for you. This is where you should find the setting to turn it on or off.

  • I want to create a "Play All" chapter marker that will play the video from start to finish in addition to the standard chapters I have-I guess I can auto start the DVD but would prefer a button-how and where would I put this "play all" marker??

    I want to create a "Play All" chapter marker that will play the video from start to finish in addition to the standard chapters I have…I guess I can auto start the DVD but would prefer a button…how and where would I put this "play all" marker?? Thanks..

    The start chapter button is a play the whole movie button regardless of how many other markers you have.
    Once a DVD starts playing it continues to the end.
    Chapters marker simply gives the viewer a place to start playback whether it be the start, middle or near the end.
    Al

  • Why I need a code for rent a film and where ist the code? (I dont have a card)

    Why I need a code for rent a film and where ist the code? (I dont have a card)

    it's unclear what you mean
    you say you dont have a card which I guess is you don't have a creditcard
    in which case the other option is to pay by a giftcard which include a code which you put in
    because to rent you have to pay otherwise it's not really renting

  • In iphone4, How and where to save a file attached in mail

    hey, i have started using iPhone. presently using iPhone4. How and where can i save files attached in mail.

    Photos attached to an email can be saved to the Camera Roll in the Photos app on your phone. Tap and hold on a photo in the email until you get a choice to Save Image.
    Other documents require a suitable app.
    PDFs can be saved in the free iBooks app available in the App Store.
    Word docs can be saved in Pages or other apps that support text files.
    Etc.
    To save a document tap on the doc. You will either be able to view the contents or get a choice to open in some other app,

  • I want to use my grey Mac G4 desktop to Skype. How and where do I connect a microphone

    I want to use my grey Mac G4 desktop to Skype. How and where do I connect a microphone. Is it possible?

    G4 Macs have no built video/webcams or microphones.
    The best solutions are USB devices.
    First, you need to determine the version of Skype that you can use. The newest Skype version 5 can only run on Macs with a min. OS X version of OS 10.5.8 Leopard.
    Tthe older version of Skype that can run in your Mac is Skype 2.8 found here.
    http://www.skype.com/intl/en/get-skype/on-your-computer/macosx/2-8/
    There are not a lot of webcams or microphones that work with both Macs and Skype.
    Here is the only webcam, from Logitech, that I was using on my previous G4 that was both PC and Mac compatible, but the requirements say you need 1.0 Ghz CPU and OS X 10.5.8 Leopard.
    http://www.logitech.com/en-us/webcam-communications/webcams/hd-webcam-c615
    Logitech also has a few Mac compatible USB headset audio/microphones, but don't mention Skype compatibilty.
    You would need to buy and try to test.
    Plantronics makes only one or two models that will work with Macs and general Internet Telephony and include Skype, also.
    Here is one here.
    http://www.plantronics.com/us/product/audio-345?skuId=sku4920019&mftr=&prodfind= trutrue
    Good Luck!

  • I have Amazon instant video app, and recently downloaded a movie. How and where can I find it?

    I have Amazon instant video app, and recently downloaded a movie. How and where can I find it?

    Your downloaded movie should be in the library tab of the Amazon instant video app.

Maybe you are looking for

  • How to add fields in a z table

    hi experts ! i have to add a new fields to an already existing Z table. how can i add field? do i have to delete all other entries and create new ones so that the entry in the new field also gets created.? akanksha

  • Reminders on iCloud, and iCal on Mac

    I'm currently trying to get to grips with iCloud across all my devices, home Macbook (running Mountain Lion) work MacPro (running Lion) and iPhone (iOS6). My problem is with the duplication of events in iCal. I use Reminders as my to do list and I us

  • Color on a MBpro

    Even though my mac meets minimal hardware requirements declared by FCP, I cannont run Color properly; I can start the app, but cannot import any clips, or anything else... I'm running it on a MB Pro 2,4ghz i5, 4gb ram, 500 gb hdd. When starting the a

  • Problem dialling certain digits with Lumia 800

    In order to find out how much pre-paid phone credit I have with my carrier, I can dial #123#, which works with my SIM in my iPhone (unlocked) and I get a response giving my available credit. However, when I try to dial this combination of digits with

  • Have new itunes 6.0.5 but empty will ipod erase?

    the itunes 6.0.5 is empty and if i plug in my ipod will it erase my ipod? xp   Windows XP   xp   Windows XP