PHP - Moved: Users Who Re-visit In Less Than 48 Hours.
This topic has been moved to MySQL Help.
http://www.phpfreaks.com/forums/index.php?topic=322423.0 Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=352669.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=350642.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=341970.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=359217.0 Hello
I am trying to work out how many regular users I have to my site and how long those users tend to be users..
So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id.
I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that...
SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; Good day: Im trying to add a number every time a person visits the page. here is the code Im using. Any help will be appreciated. Code: [Select] <?php $aid = $_GET['aid']; $connection = mysql_connect("localhost", "username", "password"); mysql_select_db("articles", $connection); $query="SELECT visits FROM articles_description WHERE id=$aid"; $result=mysql_query($query); $num=mysql_numrows($result); <?php while ($j < $num) { $visits = $num[0] + 1; } $query = "UPDATE articles_description SET visits = $visits WHERE id = $aid"; if(mysql_query($sql_query)) { echo "Record updated successfully"; $j++; } mysql_close(); ?> hi guys, I'm trying to use a very basic PHP script and i think I've got everything right but I'm not getting any records inserted into my table. here is my script: $dbHost = "ip address"; $dbName= "rptDatabase"; $dbUsername = "username"; $dbPassword = "password"; $ip = $_SERVER['REMOTE_ADDR']; $page = $_SERVER['PHP_SELF']; $referrer = $_SERVER['HTTP_REFERER']; $date = date("m/d/y"); $time = date("h:i:a"); $db = mysql_connect($dbHost, $dbUsername, $dbPassword) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($dbName, $db); $sql = "INSERT INTO tblTraffic (ip, page, referrer, date, time) VALUES ($ip, $page, $referrer, $date, $time)"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); mysql_close($db); can someone tell me what I'm doing wrong? thanks. Edited October 13, 2019 by ajetrumpetHi I'm trying to figure out how to calculate how long since a datevariable I have stored is from whenever the page is loaded.. I currently have a stored datevariable in the format: YYYY-MM-DD H:m:s ... So basically what I wish to accomplish is figuring out whenever i load the page which has stored this variable, how much time has passed. I want it to show up as for example : '10 minutes ago'.. '1 hour 25minutes ago' if it's the same day.. if its more than 1 day old it's enough to show only the number of days.....'1week 3 days ago' etc etc I just discovered that I have a major security flaw with my website. Anyone who logs in to the website can easily access other users information as well as delete and edit other users information just by changing the ID variable in the address bar. I have user ID Session started on these pages but still people can do anything they like with other users information just by editing the address bar. For example if your logged in in the address bar of www.mywebsite.com/delete_mystuff.php?id=5 and change the "5" say to a "9" then you will have access to user#9 information. Every important page that I have has this code: Code: [Select] session_start(); if (!isset($_SESSION['user_id'])) { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { //Else If Logged In Run The Script if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { $id = (int) $_GET['id']; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { $id = (int) $_POST['id']; } else { echo ' No valid ID found, passed in url or form element'; exit(); } What am I doing wrong? Please help if you know how to correct this. Many thanks in advance. I just had a question for you guys. I am building a forum script and I'm currently stumped on the "show unread posts since last visit" feature. Not sure as to how to code it. Should I be using a mysql database to keep track of them or use cookies some how? Thanks in advanced! Im using $time = date('Y-m-d H:i:s'); How can I make a new variable that adds 4 hours on the $time output. Hello I am trying to do a cronjob to check if a user has been online within the past 24 hours. I have a column with "last_login" with this format: "1337593284". How can I do a simple if (last_login+24hours< servertime) { do something... Hi, I have a row In mysql data base called time and the content is filled with the time function time (); I want to know is there a way to achieve this I want the entire column deleted if it has been 24 hours since the time row was filled. I want this to happen automatically I don't really know how to achieve this so any help would be much appreciated thanks. I am trying to make a function that is customizable to delete a query from a database. Here's the function. function checkHashs($hours) { if($getHashs = mysql_query('SELECT * FROM `hash_codes`')) { $dateQ = mysql_query('SELECT MAX(addedon) AS lastVoteDate FROM `hash_codes`') or die(mysql_error()); $getDate = mysql_fetch_assoc($dateQ); $diffrence = time() - strtotime($getDate['lastVoteDate']); echo $diffrence / 60 / 60; if (($diffrence / 60 / 60) >= $hours) { mysql_query('DELETE FROM `hash_codes` WHERE `addedon` = '. ($diffrence / 60 / 60) >= $hours .'') or die(mysql_error()); } } } And I am trying to call it by checkHashs(24); What I am trying to do is make it so when that function is ran it will delete all oh the guerys that have the `addedon` row over X hours(24 hours in this case). Any ideas? in my MySql database i have a field "created_at" = now() for ex: 2011-05-23 11:47:28 i need to add two hours to that so i have 2011-05-23 13:47:28 how will i do this please? i have this so far but it is not correct: $currentTime = time($msg->getCreatedAt()); $timeAfterOneHour = $currentTime+60*60; $date=date("Y-m-d H:i:s",$timeAfterOneHour); please help thank you I have the below code wish I wish to add 12 hours to: Code: [Select] $today = date('D', mktime(0,0,0,date('m'),date('d')+0,date('Y'))); anyone to show how I add 12 hours? Hey Guys. I am writing a function that will output to the user if a store is open or not.
I wrote a fucntions named is_store_open() with a variable called $day which will have the current day of the week assigned to it.
Lets say it is Saturday. it finds the case for "Saturday" and checks the opening time and closing time for Saturday.
The problem that I am facing, is when the store is open past midnight on Saturday. It then won't check the case for saturday.
Instead will check the case for Sunday. Which is not what I want, becuase it will show the store as closed when its open still open on "Saturday"
I wrote a function below that checks to see if the previous day closing hours are greater then the current time. If its true then return true and I guess that should fix the problem.
But when I wrote that it would give me an error saying that $saturday_close is undefined. I'm guessing its becuase its in a switch satement, and it does not equal to that day.
I'm a little bit confused on how to set this up. If anyone has a suggestion I would really apprecaite your help. Thanks!
function is_store_open(){ $set_time = strtotime("tomorrow"); // Lets just sat its Sunday for testing purposes $day = date("l", $set_time); $time_now = mktime("00", "00", "00"); // Now lets say the time now is 12:00am switch ($day) { case "Saturday": $open = "11:00"; $saturday_close = "1:00"; break; case "Sunday"; if($saturday_close > $time_now ){//If the $monday_close hours are greater then the current time return false the store is still open return true; } else { $open = "2:00"; $close = "22:00"; } break; } }// End of function if(is_store_open()) { echo "Oh no! There is still a glitch in the system the store needs to remain open"; } else { echo "The store is still open on Saturday"; } Hi, I have a database where I store times with the Now(); function. What I want is: When the viewer looks at the post, instead of it saying: Posted: 2010-11-14 19:08:14, I want it to say posted: x hours ago, Posted: x days ago, etc. Any help with this would be appreciated! It was suppose to be my day off but here I set in front of the computer trying to figure out some code. I can not get my code to send me the information that is inputted into the fields. The style is what I want but most importantly it has got to work. I'm going to put the PHP code and the HTML code. If you need the CSS code I can post that. I'm not sure if you guys need that though. Hopefully someone out there can help me out. I know it might be a very simple error causing me tons of problems. I just can't figure it out. I'm novice at this stuff. PHP CODE & HTML CODE: <?php if ($_POST["email"]<>'') { $ToEmail = 'Justin@fullloop.net'; $emailSubject = 'contact'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; $MESSAGE_BODY = "Phone: ".$_POST["phone"]."<br>"; $MESSAGE_BODY .= "Your Email: ".$_POST["email"]."<br>"; $MESSAGE_BODY .= "Your Message: ".nl2br($_POST["comment"])."<br>"; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> <html> <body> <?php echo $_POST["name"]; ?>,<br /> Thank you for contacting Full Loop Inspections. We take great pride in our services and we are grateful you are considering us to complete your inspection. An inspector will contact you at <?php echo $_POST["phone"]; ?> or email you at <?php echo $_POST["email"]; ?> . </body> </html> <?php } else { ?> <form id="contacts-form" method="post" action="contact.php"> <fieldset> <div class="field"> <label>Your Name:</label> <input type="text" value="" name="name"/> </div> <div class="field"> <label>Your Phone:</label> <input type="text" value="" name="phone"/> </div> <div class="field"> <label>Your E-mail:</label> <input type="text" value="" name="text"/> </div> <div class="field"> <label>Your Message:</label> <textarea cols="1" rows="1"></textarea> </div> <div class="wrapper"><a href="contact-us.html" onClick="document.getElementById('contacts-form').submit()" class="link1"><em><b>SUBMIT</b></em></a></div> </fieldset> </form> <?php }; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head profile="http://www.w3.org/2005/10/profile"> <link rel="icon" type="image/gif" href="images/favicon.gif" /> <head> <title>Full Loop Inspections | Columbus Ohio #1 Home Inspector | Home Inspectors | Commercial | Mold | Grove City </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="description" content="Certified inspectors performing commercial and home inspections in Columbus, Grove City, Hilliard, Gahanna and surrounding areas" /> <meta name="keywords" content="Columbus home inspectors, Grove City Inspectors, Home Inspections, Home Inspector" /> <meta name="author" content="Full Loop Inspections | Home | Commercial | Mold | Radon | Mold Inspectors - http://www.fullloop.net" /> <link href="style.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script src="js/cufon-yui.js" type="text/javascript"></script> <script src="js/cufon-replace.js" type="text/javascript"></script> <script src="js/Myriad_Pro_400.font.js" type="text/javascript"></script> <script src="js/Myriad_Pro_600.font.js" type="text/javascript"></script> <script src="js/NewsGoth_BT_400.font.js" type="text/javascript"></script> <script src="js/NewsGoth_BT_700.font.js" type="text/javascript"></script> <script src="js/NewsGoth_Dm_BT_400.font.js" type="text/javascript"></script> <script src="js/script.js" type="text/javascript"></script> <!--[if lt IE 7]> <script type="text/javascript" src="js/ie_png.js"></script> <script type="text/javascript"> ie_png.fix('.png, #header .row-2 ul li a, .extra img, #search-form a, #search-form a em, #login-form .field1 a, #login-form .field1 a em, #login-form .field1 a b'); </script> <link href="ie6.css" rel="stylesheet" type="text/css" /> <![endif]--> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-24965394-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();</script> </head> <body id="page5"> <div id="main"> <!-- HEADER --> <div id="header"> <div class="row-1"> <div class="fleft"><a href="home.html"><img src="images/logo.png" alt="full-loop-inspections" /></a></div> <div class="fright"> <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=146395285448812&xfbml=1"></script><fb:like href="http://www.facebook.com/pages/Full-Loop-Inspections/237677882939676" send="true" layout="button_count" width="150" show_faces="true" action="like" font=""></fb:like> <g:plusone size="small"></g:plusone> <ul> <li><a href="home.html"><img src="images/icon1.gif" alt="home-inspections" /></a></li> <li><a href="contact-us.html"><img src="images/icon2-act.gif" alt="contact-a-home-inspector" /></a></li> <li><a href="home-inspectors-service-area.html"><img src="images/icon3.gif" alt="home-inspectors-sitemap" /></a></li> </ul> </div> </div> <div class="row-2"> <div class="left"> <ul> <li><a href="home.html"><span>home</span></a></li> <li><a href="inspection-services.html"><span>inspection services</span></a></li> <li><a href="payments.html"><span>Make Payments</span></a></li> <li><a href="contact-us.html" class="active"><span>contact</span></a></li> <li class="last"><a href="home-inspectors-service-area.html"><span>Service Area</span></a></li> </ul> </div> </div> <div class="row-3"> <div class="inside"> <h2>Columbus Ohio<b>Inspections</b></h2> <p>Full Loop Inspections services Columbus Ohio and surrounding cities. Franklin, Madison, Union, Delaware, Licking, Pickaway and Fairfield counties. Contact us today to set an Inspection appointment. </p> </div> </div> <div class="extra"><img src="images/header-img.png" alt="Columbus-Ohio-Inspectors" /></div> </div> <!-- CONTENT --> <div id="content"><div class="inner_copy">More <a href="http://www.templatemonster.com/">Website Templates</a> at TemplateMonster.com!</div> <div class="box"> <div class="border-bot"> <div class="right-bot-corner"> <div class="left-bot-corner"> <div class="inner"> <div class="box1 alt"> <div class="inner"> <h4><b>Our</b> Contacts</h4> <div class="address"> <p><b>Inspector:</b> Justin Ashley<br /> <b>Telephone:</b>614-256-6505<br /> <b>Address:</b>4690 Helmsbridge Ct<br /> <b>City:</b>Grove City, OH 43123<br /> <b>e-mail:</b><a href="mailto:Justin@Fullloop.net?subject=Online Inspection Referral">Justin@Fullloop.net</a></p> </div> <p class="p0 extra-wrap"><br /> <span class="img-box1"><img src="images/InterNACHI.png" alt="InterNachi-Home-Inspectors" width="81" height="70" /></span><span class="img-box1"><img src="images/Infrared_Certified_Small.png" alt="Thermal-Imaging-home-inspector" width="57" height="70" /></span><span class="img-box1"><img src="images/IAC_Mold_Radon.png" alt="mold-inspector" width="94" height="70" /><img src="images/Columbus-board-of-realtors.jpg" alt="mold-inspector" width="70" height="70" /></span></p> </div> </div> </div> </div> </div> </div> </div> <div class="indent"> <div class="wrapper"> <div class="col-1"> <h3><b>Contact</b> Form</h3> <form id="contacts-form" method="post" action="contact.php"> <fieldset> <div class="field"> <label>Your Name:</label> <input type="text" value="" name="name"/> </div> <div class="field"> <label>Your Phone:</label> <input type="text" value="" name="phone"/> </div> <div class="field"> <label>Your E-mail:</label> <input type="text" value="" name="text"/> </div> <div class="field"> <label>Your Message:</label> <textarea cols="1" rows="1"></textarea> </div> <div class="wrapper"><a href="contact-us.html" onClick="document.getElementById('contacts-form').submit()" class="link1"><em><b>SUBMIT</b></em></a></div> </fieldset> </form> </div> <div class="col-2"> <div class="box2"> <div class="border-top"> <div class="left-top-corner"> <div class="right-top-corner"> <div class="inner"> <h4><b>Property </b>Info</h4> <ul class="news"> <li><a href="full-loop-inspections">Sept 13, 2011</a> <p>When contacting us please provide as much information as you can about the property.</p></li> <li><a href="full-loop-inspections">Sept 13, 2011</a> <p>We will take the time to answer any questions you might have. </p></li> </ul> </div> </div> </div> </div> </div> <div class="box3"> <div class="right-bot-corner"> <div class="left-bot-corner"> <div class="inner"> <center> <p> </p> <p> </p> <p><img src="images/JPicture.jpg" alt="Home-Inspectors-Columbus" /></p> <p> <strong><font color="#FFFFFF">Full Loop Inspections<br /> Certified Home Inspector<br /> Justin Ashley<br /> 4690 Helmsbridge Ct<br /> Grove City, OH 43123<br /> (614)-256-6505</strong><br /><a href="mailto:Justin@Fullloop.net?subject=Inspection"><font color="#000000"> Justin@Fullloop.net</font></a></p> </center> </div> </div> </div> </div> </div> </div> </div> </div> <!-- FOOTER --> <div id="footer"> <div class="footer-nav"> <div class="left"> <ul> <li><a href="home.html">Home</a></li> <li><a href="inspection-services.html">Services</a></li> <li><a href="payments.html">Payments</a></li> <li><a href="contact-us.html">Contact</a></li> <li class="last"><a href="home-inspector-links.html">Links</a></li> </ul> </div> </div> <div class="bottom"><p><a href="http://www.fullloop.net" class="new_window">Full Loop Inspections</a> </p> <p>Servicing <strong>COLUMBUS</strong> - Bexley - Canal Winchester - Dublin - Gahanna - Grandview Heights - Grove City - Hilliard - New Albany - Pickerington - Reynoldsburg - Upper Arlington - Westerville - Whitehall - Worthington and all surrounding cities </p> </div> </div> </div> <script type="text/javascript"> Cufon.now(); </script> </body> </html> |