finkrattaz Posted April 20, 2008 Share Posted April 20, 2008 I am sort of having the same problem, but I am trying to get the length of time a user is logged into the page. There are two different pages were are trying to get the time from. If there is a way to get it just have the login time for the page and logout time for the page that will be great. When we look at the data from the database http://stealthtrackervideos.com/Sessions.php it is showing zero and I have it set as an INT. Can someone help determine what could be wrong? Page Code: <?php session_start(); $_SESSION['view_start_time_v1'] = date('h, i, s'); require_once('dbcon2.php'); if(isset($_POST['SUBMITME'])) { $_SESSION['view_stop_time_v1'] = date('h, i, s'); $dbr = new db;$dbr->dbuser(); $in = new customer;$in->inD($_POST['name'],$_POST['city'],$_POST['state'],$_POST['zip'],$_POST['make'],$_POST['model'],$_POST['completevideo'],$_POST['likevideo'],$_POST['purchasedvideo'],$_POST['comments'],1); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="javascript"> function dovalidation() { if(document.getElementById("completevideo").value=="") { alert('Did you watch completed video should not be blank.'); document.getElementById("completevideo").focus(); } } </script> <title>Stealth Safety Security Notification for Vehicles</title> </head> <body bgcolor="#ffffff"> <table width="750" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="250" align="left"><font face="tahoma" size="3" color="black"><b>Welcome: </b><?php echo $_SESSION['LoggedInD']; ?></font></td> <td width="250" align="center"><font face="tahoma" size="3" color="black"><b>Todays Date: </b><?php echo date('m/d/Y');?></font></td> <td width="250" align="right"><a href="Logout.php?flag=1"><font face="tahoma" size="3" color="black"><b>Logout</b></font></a></td> </tr> </table> <hr style="color:#66FF00"> <center><a href="videoPage.php"><font face="tahoma" size="2" color="black">back</font></a></center><p> <center><font face="tahoma" size="3" color="black"><b>STEALTH SAFETY SECURITY NOTIFICATION FOR VEHICLES</b></font></center><p> <table width="640" border="0" align="center" cellpadding="0" cellspacing="0" style="border:3px solid #000000;"> <tr> <td width="640" align="center"> <center> <embed src="http://mattsdesigns.biz/dealership/stealth01.wmv" width="640" height="380"></embed> </center> </td> </tr> </table> <form name="form1" id="form1" action="" method="post" onSubmit="return dovalidation()"> <center><font face="tahoma" size="3" color="red"><b>PLEASE COMPLETE THE FORM!!!</b></font></center><br> <table width="500" border="0" cellspacing="2" cellpadding="2" style="border:1px solid #000000;" align="center"> <tr> <td width="250" align="left" ><font face="tahoma" size="2" color="black">Customer Name:</font></td> <td width="250" align="left"><font face="tahoma" size="2" color="black"><input name="name" type="text" id="name"></font></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">City:</font></td> <td align="left"><font face="tahoma" size="2" color="black"><input name="city" type="text" id="city"></font></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">State:</font></td> <td align="left"><font face="tahoma" size="2" color="black"><input name="state" type="text" id="state"></font></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">Zip Code:</font></td> <td align="left"><font face="tahoma" size="2" color="black"><input name="zip" type="text" id="zip"></font></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">Make:</font></td> <td align="left"><input name="make" type="text" id="make"> </td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">Model:</font></td> <td align="left"><input name="model" type="text" id="model"></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">Did you watch the complete video?</font><br> <font face="tahoma" size="1" color="red">*Answer is Required*</font></td> <td align="left"><font face="tahoma" size="2" color="black"><input name="completevideo" type="radio" value="yes">Yes <input name="rdcompleted" type="radio" value="no">No</font></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">Did you like the product?</font></td> <td align="left"><font face="tahoma" size="2" color="black"><input name="likevideo" type="radio" value="yes">Yes <input name="likevideo" type="radio" value="no">No</font></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">Would you purchase the product?</font></td> <td align="left"><font face="tahoma" size="2" color="black"><input name="purchasedvideo" type="radio" value="yes">Yes <input name="purchasedvideo" type="radio" value="no">No</font></td> </tr> <tr> <td align="left"><font face="tahoma" size="2" color="black">Comments About the Product</font></td> <td align="left"><font face="tahoma" size="2" color="black"><textarea name="comments" cols="30" rows="3"></textarea></font></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr align="center"> <td colspan="2"><font face="tahoma" size="2" color="black"><p><input type="hidden" name="SUBMITME"><input name="submit" type="submit"> - <input name="reset" type="reset"></font></td> </tr> </table> </td> </tr> </table> </form> </body> </html> Connection Code: <?php define('LINKTO','10.6.166.173');define('USR','matts');define('PWD','Jordan0!'); define('SCHEMA','matts'); class conn{ function connect(){$msdc = mysql_connect(LINKTO,USR,PWD) or die(mysql_errno());return $msdc;}} class db extends conn{ function dbuser(){ conn::connect();$dbreturn = mysql_select_db(SCHEMA) or die(mysql_errno());return $dbreturn;}} class customer extends db { function inD($name,$city,$state,$zip,$txtMake,$txtModel,$txtVideoName,$rdcompleted,$rdliked,$rdpurchased,$txtcomments){ $name = customer::errorC($name); $city = customer::errorC($city); $state = customer::errorC($state); $zip = customer::errorC($zip); $txtMake = customer::errorC($txtMake); $txtModel = customer::errorC($txtModel); $txtVideoName = customer::errorC($txtVideoName); $rdcompleted = customer::errorC($rdcompleted); $rdliked = customer::errorC($rdliked); $rdpurchased = customer::errorC($rdpurchased); $txtcomments = customer::errorC($txtcomments); if(empty($rdcompleted)) { echo "<script>alert('Fields are empty');window.history.back(-1);</script>"; } else{ $query = sprintf("INSERT INTO customer (`CustName`, `City`, `State`, `Zip`, `Make`, `Model`, `VideoName`, `CompleteVideo`, `LikeVideo`, `PurchasedVideo`, `Comments`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",$name,$city,$state,$zip,$make,$model,$videoname,$completevideo,$likevideo,$purchasevideo,$comments); echo $query; $qrSet = mysql_query($query); if($qrSet) { echo "<script>alert('Congratulation! You have successfully completed the feedback form');window.location='videoPage.php';</script>"; } } } function errorC($var) { $temsp = trim($var); $temp = mysql_real_escape_string($temsp); return $temp; } } ?> Quote Link to comment Share on other sites More sharing options...
finkrattaz Posted April 20, 2008 Author Share Posted April 20, 2008 I gave the wrong connection code: <?php define('LINKTO','10.6.166.173');define('USR','matts');define('PWD','Jordan0!'); define('SCHEMA','matts'); class conn{ function connect(){$msdc = mysql_connect(LINKTO,USR,PWD) or die(mysql_errno());return $msdc;}} class db extends conn{ function dbuser(){ conn::connect();$dbreturn = mysql_select_db(SCHEMA) or die(mysql_errno());return $dbreturn;}} class customer extends db { function inD($name,$city,$state,$zip,$make,$model,$completevideo,$likevideo,$purchasedvideo,$comments){ $name = customer::errorC($name); $city = customer::errorC($city); $state = customer::errorC($state); $zip = customer::errorC($zip); $make = customer::errorC($make); $model = customer::errorC($model); $completevideo = customer::errorC($completevideo); $likevideo = customer::errorC($likevideo); $purchasedvideo = customer::errorC($purchasedvideo); $comments = customer::errorC($comments); if(empty($completevideo)) { echo "<script>alert('Fields are empty');window.history.back(-1);</script>"; } else{ $query = sprintf("INSERT INTO customer (CustName, City, State, Zip, Make, Model, CompleteVideo, LikeVideo, PurchasedVideo, Comments) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",$name,$city,$state,$zip,$make,$model,$completevideo,$likevideo,$purchasedvideo,$comments); $qrSet = mysql_query($query); if ($_SESSION['view_start_time_v1'] == $_SESSION['view_stop_time_v1']) { // Its still the same hour..so parsing is fine. $total_time_v1 = $_SESSION['view_stop_time_v1'] - $_SESSION['view_start_time_v1']; $total_time_v2 = $_SESSION['view_stop_time_v2'] - $_SESSION['view_start_time_v2']; $vp1_query = sprintf("INSERT INTO session(name, url_viewed, date_viewed,time_viewed) VALUES('%s','%s','%s','%s')", $name, 'VideoPage1',date('m/d/Y'), $total_time_v1); $vp2_query = sprintf("INSERT INTO session(name, url_viewed, date_viewed,time_viewed) VALUES('%s','%s','%s','%s')", $name, 'VideoPage2',date('m/d/Y'), $total_time_v2); mysql_query($vp1_query); mysql_query($vp2_query); } if($qrSet) { echo "<script>alert('Congratulation! You have successfully completed the feedback form');window.location='videoPage.php';</script>"; } } } function errorC($var) { $temsp = trim($var); $temp = mysql_real_escape_string($temsp); return $temp; } } ?> Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 20, 2008 Share Posted April 20, 2008 Don't hijack other people's threads. Do use code tags in your posts. Quote Link to comment Share on other sites More sharing options...
finkrattaz Posted April 20, 2008 Author Share Posted April 20, 2008 I am sorry. Quote Link to comment 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.