Location: PHPKode > scripts > dbStringIt > dbstringit/html/index.php
<?php
include_once '../config.php';
include_once $rootPath . 'classes/dbStringIt.php';

if (isset($_SESSION['uid'])){
   $id = $_SESSION['uid']; //SET WITH YOUR AUTH SCRIPT
}
   // Make a MySQL Connection
$link = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
mysql_select_db(DB_USER) or die(mysql_error());

extract($vars, EXTR_OVERWRITE);


if( ! isset($id)){      //Create user
   mysql_query(" INSERT INTO users (uid) VALUES (NULL) ") or die(mysql_error());
   $id = mysql_insert_id();
   $_SESSION['uid'] = $id;
   mysql_query(" INSERT INTO identity (uid) VALUES ('$id') ") or die(mysql_error());
} else {
   $query  = "SELECT * FROM users WHERE uid = $id";
   $result = mysql_query($query);
   $rowusers = mysql_fetch_array($result, MYSQL_ASSOC);
//   extract($rowusers, EXTR_OVERWRITE);
   $upd = new dbStringIt;
   $updatev = $upd->key_intersect($vars,$rowusers);

   $query  = "SELECT * FROM identity WHERE uid = $id";
   $result = mysql_query($query);
   $rowid = mysql_fetch_array($result, MYSQL_ASSOC);
//   extract($rowid, EXTR_OVERWRITE);
   $upd = new dbStringIt;
   $updatev = $upd->key_intersect($vars,$rowid);
}


if (isset($_POST['submitaddress'] ) ) {

   extract($_POST, EXTR_IF_EXISTS);

   if(isset($id)){      //Update goes here
   $query  = "SELECT * FROM identity WHERE uid = $id";
   $result = mysql_query($query);
   $row = mysql_fetch_array($result, MYSQL_ASSOC);
   $upd = new dbStringIt;
   $updatev = $upd->dbUpdate($_POST,$row);
   $display = true;
   if (isset($updatev)){
      $updatev .= ", last_db_change = NOW()"; // Any editional updates g here
      $result = mysql_query(" UPDATE identity
                              SET $updatev
                              WHERE uid = $id") or die(mysql_error());
   }

   }


}


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <title>Alias</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<?php

echo "
<table>
  <tbody>
    <tr>
      <td>
<FORM  method=\"POST\" target=\"_self\" id=\"form\">
<table class=\"form\" border=\"1\">
  <tfoot>
    <tr>
      <td colspan=\"12\">
         <input class=\"botten\" name=\"reset\" type=\"reset\" value=\"Reset\">
         <input class=\"botten\" type=\"submit\" name=\"submitaddress\" value=\"Submit\">
      </td>
    </tr>
  </tfoot>
  <tbody>
    <tr>
      <td width=\"50%\" colspan=\"6\" class=\"must\">First Name:<br><input  class=\"text\" name=\"First_Name\" value=\"$First_Name\" type=\"text\" size=\"15\"></td>
      <td colspan=\"6\" class=\"must\">Last Name:<br><input class=\"text\" name=\"Last_Name\" value=\"$Last_Name\" type=\"text\" size=\"15\"></td>
    </tr>
    <tr>
      <td colspan=\"12\">Company:<br><input class=\"text\" name=\"Company\" value=\"$Company\" type=\"text\" size=\"30\"></td>
    </tr>
    <tr>
      <td colspan=\"12\">Street:<br><input  class=\"text\" name=\"Street\" value=\"$Street\" type=\"text\" size=\"37\"></td>
    </tr>
    <tr>
      <td colspan=\"6\">City:<br><input  class=\"text\" name=\"City\" value=\"$City\" type=\"text\" size=\"15\"></td>
      <td colspan=\"3\" class=\"must\">ZIP:<br><input type=\"text\" name=\"ZIP\" value=\"$ZIP\" value=\"\" size=\"5\" class=\"text\"></td>
      <td colspan=\"3\">ZIP+4:<br><input type=\"text\" name=\"ZIP4\" value=\"$ZIP4\" size=\"4\" class=\"text\"></td>
    </tr>
    <tr>
      <td colspan=\"6\">Phone:<br><input class=\"text\" name=\"Phone\" value=\"$Phone\" type=\"text\" size=\"15\"</td>
     <td colspan=\"6\">Cell:<br><input  class=\"text\" name=\"Cell\" value=\"$Cell\" type=\"text\" size=\"15\"</td>
    </tr>

  </tbody>
</table>
</form>

</td>
      <td>



</td>
    </tr>
  </tbody>
</table>";


if (isset($id)){
   echo "Your user id is set to: $id <br>";
}

if (isset($_POST)){
   echo "Your vars: <br><pre>";
   print_r($_POST);
   echo "</pre>";
}

if (isset($display)){
   echo "Your last query string: <br>";
   if (isset($updatev)){
      echo " UPDATE identity SET $updatev
             WHERE uid = $id <br>";
   }
}
if (isset($link)){
   //info about last query
   echo mysql_info ( $link);
   // Closing connection
   mysql_close($link);
}
?>
</body>
</html>
Return current item: dbStringIt