Jump to content

budimir

Members
  • Posts

    522
  • Joined

  • Last visited

Everything posted by budimir

  1. Well, since I haven't seen your code. I assume you could do something like $sql = "SELECT * FROM pictures ORDER BY id DESC LIMIT 1"; In this way you get last (id) picture in your database and that one is shown. Again, I haven't seen your code so I just asume what you could do.
  2. Try this: <?php foreach ($people as $people_id => "$people_firstname $people_lastname" ) { if ($people_id == $movie_director) { $selected = " selected"; } else { $selected = ""; } ?> <option value="<?php echo $people_id; ?>"<?php echo $selected; ?>> <?php echo $people_firstname; ?></option> <?php } ?> </select>
  3. Post you'er code. It's hard to say anaything this way!
  4. Yes, but CAPTCHA was cracked few weeks ago!!! So, maybe they tested it on you!!!
  5. OK, another thing. Where are your variables declared???? $sql="UPDATE $tbl_name SET username='$username', password='$password', access='$access' WHERE id='$id'"; '$username' ???? '$password' ???? '$access' ???? '$id' ???? You variables are emtpy so nothing gets updated!!!! That's why you get error!!!!
  6. Couple of ideas from me: 1.) You can use CAPTCHA 2.) You can use sleep() to delay entering new info (so it will take a lot longer for that person to do it like that) 3.) You can use IP logging and put delay if a form is submitted twice from same IP () 4.) You can use domain validation for email adress But, there is no good way from preventing a user to enter shit info. You can just slow down entering a lot of shit to DB.
  7. Use this code! It works perfectly!!!! if ($_SESSION['last_reload'] != "" && $_SESSION['last_reload'] < strtotime("-15 minutes")) { header("Location:http://localhost/erp/logoutd.php"); } else { $_SESSION['last_reload'] = time(); } Ofcourse, on logoutd.php you need to have session_destroy();
  8. And your problem is ... ?
  9. Hey guys, How can I display results in columns (3 or more), not in rows??? Instead of this: Name | Last Name | Adress | City | Country I want this: Name Name Name Last Name Last Name Last Name Adress Adress Adress City City City Country Country Country
  10. Try to google for "PHP Login tutorials" There is plenty of good tutorials.
  11. You probably want this: $sql = "SELECT field, SUM(*) as values FROM tablename WHERE NAME = '$testname'"; Try it out...
  12. That did it!!!!! Thanks a lot mjdamato!!! You rock!!!!
  13. Thanks a lot guys!!!! I will try it out and let you know if it worked.
  14. Hey Guys, Can somebody tell me how can I change this script so week starts with Monday not with Sunday. // Shows or hides the date chooser on the page function showChooser(obj, inputId, divId, start, end, format, isTimeChooser) { if (document.getElementById) { var input = document.getElementById(inputId); var div = document.getElementById(divId); if (input !== undefined && div !== undefined) { if (input.DateChooser === undefined) { input.DateChooser = new DateChooser(input, div, start, end, format, isTimeChooser); } input.DateChooser.setDate(Date.parseDate(input.value, format)); if (input.DateChooser.isVisible()) { input.DateChooser.hide(); } else { input.DateChooser.show(); } } } } // Sets a date on the object attached to 'inputId' function dateChooserSetDate(inputId, value) { var input = document.getElementById(inputId); if (input !== undefined && input.DateChooser !== undefined) { input.DateChooser.setDate(Date.parseDate(value, input.DateChooser._format)); if (input.DateChooser.isTimeChooser()) { var theForm = input.form; var prefix = input.DateChooser._prefix; input.DateChooser.setTime( parseInt(theForm.elements[prefix + 'hour'].options[ theForm.elements[prefix + 'hour'].selectedIndex].value) + parseInt(theForm.elements[prefix + 'ampm'].options[ theForm.elements[prefix + 'ampm'].selectedIndex].value), parseInt(theForm.elements[prefix + 'min'].options[ theForm.elements[prefix + 'min'].selectedIndex].value)); } input.value = input.DateChooser.getValue(); input.DateChooser.hide(); } } // The callback function for when someone changes the pulldown menus on the date // chooser function dateChooserDateChange(theForm, prefix) { var input = document.getElementById( theForm.elements[prefix + 'inputId'].value); var newDate = new Date( theForm.elements[prefix + 'year'].options[ theForm.elements[prefix + 'year'].selectedIndex].value, theForm.elements[prefix + 'month'].options[ theForm.elements[prefix + 'month'].selectedIndex].value, 1); // Try to preserve the day of month (watch out for months with 31 days) newDate.setDate(Math.max(1, Math.min(newDate.getDaysInMonth(), input.DateChooser._date.getDate()))); input.DateChooser.setDate(newDate); if (input.DateChooser.isTimeChooser()) { input.DateChooser.setTime( parseInt(theForm.elements[prefix + 'hour'].options[ theForm.elements[prefix + 'hour'].selectedIndex].value) + parseInt(theForm.elements[prefix + 'ampm'].options[ theForm.elements[prefix + 'ampm'].selectedIndex].value), parseInt(theForm.elements[prefix + 'min'].options[ theForm.elements[prefix + 'min'].selectedIndex].value)); } input.DateChooser.show(); } // Gets the absolute position on the page of the element passed in function getAbsolutePosition(obj) { var result = [0, 0]; while (obj != null) { result[0] += obj.offsetTop; result[1] += obj.offsetLeft; obj = obj.offsetParent; } return result; } // DateChooser constructor function DateChooser(input, div, start, end, format, isTimeChooser) { this._input = input; this._div = div; this._start = start; this._end = end; this._format = format; this._date = new Date(); this._isTimeChooser = isTimeChooser; // Choose a random prefix for all pulldown menus this._prefix = ""; var letters = ["a", "b", "c", "d", "e", "f", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; for (var i = 0; i < 10; ++i) { this._prefix += letters[Math.floor(Math.random() * letters.length)]; } } // DateChooser prototype variables DateChooser.prototype._isVisible = false; // Returns true if the chooser is currently visible DateChooser.prototype.isVisible = function() { return this._isVisible; } // Returns true if the chooser is to allow choosing the time as well as the date DateChooser.prototype.isTimeChooser = function() { return this._isTimeChooser; } // Gets the value, as a formatted string, of the date attached to the chooser DateChooser.prototype.getValue = function() { return this._date.dateFormat(this._format); } // Hides the chooser DateChooser.prototype.hide = function() { this._div.style.visibility = "hidden"; this._div.style.display = "none"; this._div.innerHTML = ""; this._isVisible = false; } // Shows the chooser on the page DateChooser.prototype.show = function() { // calculate the position before making it visible var inputPos = getAbsolutePosition(this._input); this._div.style.top = (inputPos[0] + this._input.offsetHeight) + "px"; this._div.style.left = (inputPos[1] + this._input.offsetWidth) + "px"; this._div.innerHTML = this.createChooserHtml(); this._div.style.display = "block"; this._div.style.visibility = "visible"; this._div.style.position = "absolute"; this._isVisible = true; } // Sets the date to what is in the input box DateChooser.prototype.initializeDate = function() { if (this._input.value != null && this._input.value != "") { this._date = Date.parseDate(this._input.value, this._format); } else { this._date = new Date(); } } // Sets the date attached to the chooser DateChooser.prototype.setDate = function(date) { this._date = date ? date : new Date(); } // Sets the time portion of the date attached to the chooser DateChooser.prototype.setTime = function(hour, minute) { this._date.setHours(hour); this._date.setMinutes(minute); } // Creates the HTML for the whole chooser DateChooser.prototype.createChooserHtml = function() { var formHtml = "<input type=\"hidden\" name=\"" + this._prefix + "inputId\" value=\"" + this._input.getAttribute('id') + "\">" + "\r\n <select name=\"" + this._prefix + "month\" onChange=\"dateChooserDateChange(this.form, '" + this._prefix + "');\">"; for (var monIndex = 0; monIndex <= 11; monIndex++) { formHtml += "\r\n <option value=\"" + monIndex + "\"" + (monIndex == this._date.getMonth() ? " selected=\"1\"" : "") + ">" + Date.monthNames[monIndex] + "</option>"; } formHtml += "\r\n </select>\r\n <select name=\"" + this._prefix + "year\" onChange=\"dateChooserDateChange(this.form, '" + this._prefix + "');\">"; for (var i = this._start; i <= this._end; ++i) { formHtml += "\r\n <option value=\"" + i + "\"" + (i == this._date.getFullYear() ? " selected=\"1\"" : "") + ">" + i + "</option>"; } formHtml += "\r\n </select>"; formHtml += this.createCalendarHtml(); if (this._isTimeChooser) { formHtml += this.createTimeChooserHtml(); } return formHtml; } // Creates the extra HTML needed for choosing the time DateChooser.prototype.createTimeChooserHtml = function() { // Add hours var result = "\r\n <select name=\"" + this._prefix + "hour\">"; for (var i = 0; i < 12; ++i) { result += "\r\n <option value=\"" + i + "\"" + (((this._date.getHours() % 12) == i) ? " selected=\"1\">" : ">") + i + "</option>"; } // Add extra entry for 12:00 result += "\r\n <option value=\"0\">12</option>"; result += "\r\n </select>"; // Add minutes result += "\r\n <select name=\"" + this._prefix + "min\">"; for (var i = 0; i < 60; i += 15) { result += "\r\n <option value=\"" + i + "\"" + ((this._date.getMinutes() == i) ? " selected=\"1\">" : ">") + String.leftPad(i, 2, '0') + "</option>"; } result += "\r\n </select>"; // Add AM/PM result += "\r\n <select name=\"" + this._prefix + "ampm\">"; result += "\r\n <option value=\"0\"" + (this._date.getHours() < 12 ? " selected=\"1\">" : ">") + "AM</option>"; result += "\r\n <option value=\"12\"" + (this._date.getHours() >= 12 ? " selected=\"1\">" : ">") + "PM</option>"; result += "\r\n </select>"; return result; } // Creates the HTML for the actual calendar part of the chooser DateChooser.prototype.createCalendarHtml = function() { var result = "\r\n<table cellspacing=\"0\" class=\"dateChooser\">" + "\r\n <tr><th>N</th><th>P</th><th>U</th>" + "<th>S</th><th>C</th><th>P</th><th>S</th></tr>\r\n <tr>"; // Fill up the days of the week until we get to the first day of the month var firstDay = this._date.getFirstDayOfMonth(); var lastDay = this._date.getLastDayOfMonth(); if (firstDay != 0) { result += "<td colspan=\"" + firstDay + "\"> </td>"; } // Fill in the days of the month var i = 0; while (i < this._date.getDaysInMonth()) { if (((i++ + firstDay) % 7) == 0) { result += "</tr>\r\n <tr>"; } var thisDay = new Date( this._date.getFullYear(), this._date.getMonth(), i); var js = '"dateChooserSetDate(\'' + this._input.getAttribute('id') + "', '" + thisDay.dateFormat(this._format) + '\');"' result += "\r\n <td class=\"dateChooserActive" // If the date is the currently chosen date, highlight it + (i == this._date.getDate() ? " dateChooserActiveToday" : "") + "\" onClick=" + js + ">" + i + "</td>"; } // Fill in any days after the end of the month if (lastDay != 6) { result += "<td colspan=\"" + (6 - lastDay) + "\"> </td>"; } return result + "\r\n </tr>\r\n</table><!--[if lte IE 6.5]><iframe></iframe><![endif]-->"; } P.S. I belive it's somewhere in the end of the code. Thanks a lot ...
  15. You will need to use javascript or AJAX. Try to Google for "Javascript onChange Event". That will get you on a right track. Or "Chained select box"... Enjoy
  16. In IE7 try: <?php echo "Hello World!</br>How are you doing today?"; ?>
  17. OK, so let me see if this would be OK. On each page I have included session.php where I keep my session variables. I can put a query for inserting time on this page and each time some other page is openned the time is updated. And to check if user was inactive for 5 minutes I could put. $time_aktiv = 1800; "SELECT * FROM users WHERE lastactive < '$time_aktiv'"; Is this OK??
  18. OOOOHHHH Damn, Do you maybe have any other ideas how to display loged in users???? I don't think this is an effecient way I have come up with... HELP...
  19. OK, So, let's explain in a little bit different way. For each user which is logged in I'm setting a status to ON. That's how I know that user is logged in and then I display it in Online Users. When my user hits logout button the status is set to OFF, also if session is expired and user clicks on something the status is set to OFF and user is redirected to login.php. My problem is, when a user hits X on web browser or he presses ALT + F4. The status is not set to OFF. How can I solve this?? I'm not getting any ideas, I tried different things and I couldn't think of anything efficient. My thought was that with javascript it would be possible to detect when web browser is closing and then redirect to logout.php and set status to OFF.
  20. @F1Fan But won't this logout user at the same moment he leaves current page??? (But he is still on the same site...)
  21. P.S. As much as I was abe to figure out, I'd say it's the part at the end of the code. I tried different combinations, but no success.
  22. OK, So, I have come up with this code! if ($_SESSION['last_reload'] != "" && $_SESSION['last_reload'] < strtotime("-180 minutes")) { header("Location:http://localhost/erp/logoutd.php"); } else { $_SESSION['last_reload'] = time(); } Why is not logging out users when they close browser on X or ALT + F4? It's working fine, when they are inactive and try to click on something...
  23. @ Crayon Velvet OK, so it needs to be in this file. This should be an acutal output. I'm sorry, but I'm not to good with javascript. // Shows or hides the date chooser on the page function showChooser(obj, inputId, divId, start, end, format, isTimeChooser) { if (document.getElementById) { var input = document.getElementById(inputId); var div = document.getElementById(divId); if (input !== undefined && div !== undefined) { if (input.DateChooser === undefined) { input.DateChooser = new DateChooser(input, div, start, end, format, isTimeChooser); } input.DateChooser.setDate(Date.parseDate(input.value, format)); if (input.DateChooser.isVisible()) { input.DateChooser.hide(); } else { input.DateChooser.show(); } } } } // Sets a date on the object attached to 'inputId' function dateChooserSetDate(inputId, value) { var input = document.getElementById(inputId); if (input !== undefined && input.DateChooser !== undefined) { input.DateChooser.setDate(Date.parseDate(value, input.DateChooser._format)); if (input.DateChooser.isTimeChooser()) { var theForm = input.form; var prefix = input.DateChooser._prefix; input.DateChooser.setTime( parseInt(theForm.elements[prefix + 'hour'].options[ theForm.elements[prefix + 'hour'].selectedIndex].value) + parseInt(theForm.elements[prefix + 'ampm'].options[ theForm.elements[prefix + 'ampm'].selectedIndex].value), parseInt(theForm.elements[prefix + 'min'].options[ theForm.elements[prefix + 'min'].selectedIndex].value)); } input.value = input.DateChooser.getValue(); input.DateChooser.hide(); } } // The callback function for when someone changes the pulldown menus on the date // chooser function dateChooserDateChange(theForm, prefix) { var input = document.getElementById( theForm.elements[prefix + 'inputId'].value); var newDate = new Date( theForm.elements[prefix + 'year'].options[ theForm.elements[prefix + 'year'].selectedIndex].value, theForm.elements[prefix + 'month'].options[ theForm.elements[prefix + 'month'].selectedIndex].value, 1); // Try to preserve the day of month (watch out for months with 31 days) newDate.setDate(Math.max(1, Math.min(newDate.getDaysInMonth(), input.DateChooser._date.getDate()))); input.DateChooser.setDate(newDate); if (input.DateChooser.isTimeChooser()) { input.DateChooser.setTime( parseInt(theForm.elements[prefix + 'hour'].options[ theForm.elements[prefix + 'hour'].selectedIndex].value) + parseInt(theForm.elements[prefix + 'ampm'].options[ theForm.elements[prefix + 'ampm'].selectedIndex].value), parseInt(theForm.elements[prefix + 'min'].options[ theForm.elements[prefix + 'min'].selectedIndex].value)); } input.DateChooser.show(); } // Gets the absolute position on the page of the element passed in function getAbsolutePosition(obj) { var result = [0, 0]; while (obj != null) { result[0] += obj.offsetTop; result[1] += obj.offsetLeft; obj = obj.offsetParent; } return result; } // DateChooser constructor function DateChooser(input, div, start, end, format, isTimeChooser) { this._input = input; this._div = div; this._start = start; this._end = end; this._format = format; this._date = new Date(); this._isTimeChooser = isTimeChooser; // Choose a random prefix for all pulldown menus this._prefix = ""; var letters = ["a", "b", "c", "d", "e", "f", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]; for (var i = 0; i < 10; ++i) { this._prefix += letters[Math.floor(Math.random() * letters.length)]; } } // DateChooser prototype variables DateChooser.prototype._isVisible = false; // Returns true if the chooser is currently visible DateChooser.prototype.isVisible = function() { return this._isVisible; } // Returns true if the chooser is to allow choosing the time as well as the date DateChooser.prototype.isTimeChooser = function() { return this._isTimeChooser; } // Gets the value, as a formatted string, of the date attached to the chooser DateChooser.prototype.getValue = function() { return this._date.dateFormat(this._format); } // Hides the chooser DateChooser.prototype.hide = function() { this._div.style.visibility = "hidden"; this._div.style.display = "none"; this._div.innerHTML = ""; this._isVisible = false; } // Shows the chooser on the page DateChooser.prototype.show = function() { // calculate the position before making it visible var inputPos = getAbsolutePosition(this._input); this._div.style.top = (inputPos[0] + this._input.offsetHeight) + "px"; this._div.style.left = (inputPos[1] + this._input.offsetWidth) + "px"; this._div.innerHTML = this.createChooserHtml(); this._div.style.display = "block"; this._div.style.visibility = "visible"; this._div.style.position = "absolute"; this._isVisible = true; } // Sets the date to what is in the input box DateChooser.prototype.initializeDate = function() { if (this._input.value != null && this._input.value != "") { this._date = Date.parseDate(this._input.value, this._format); } else { this._date = new Date(); } } // Sets the date attached to the chooser DateChooser.prototype.setDate = function(date) { this._date = date ? date : new Date(); } // Sets the time portion of the date attached to the chooser DateChooser.prototype.setTime = function(hour, minute) { this._date.setHours(hour); this._date.setMinutes(minute); } // Creates the HTML for the whole chooser DateChooser.prototype.createChooserHtml = function() { var formHtml = "<input type=\"hidden\" name=\"" + this._prefix + "inputId\" value=\"" + this._input.getAttribute('id') + "\">" + "\r\n <select name=\"" + this._prefix + "month\" onChange=\"dateChooserDateChange(this.form, '" + this._prefix + "');\">"; for (var monIndex = 0; monIndex <= 11; monIndex++) { formHtml += "\r\n <option value=\"" + monIndex + "\"" + (monIndex == this._date.getMonth() ? " selected=\"1\"" : "") + ">" + Date.monthNames[monIndex] + "</option>"; } formHtml += "\r\n </select>\r\n <select name=\"" + this._prefix + "year\" onChange=\"dateChooserDateChange(this.form, '" + this._prefix + "');\">"; for (var i = this._start; i <= this._end; ++i) { formHtml += "\r\n <option value=\"" + i + "\"" + (i == this._date.getFullYear() ? " selected=\"1\"" : "") + ">" + i + "</option>"; } formHtml += "\r\n </select>"; formHtml += this.createCalendarHtml(); if (this._isTimeChooser) { formHtml += this.createTimeChooserHtml(); } return formHtml; } // Creates the extra HTML needed for choosing the time DateChooser.prototype.createTimeChooserHtml = function() { // Add hours var result = "\r\n <select name=\"" + this._prefix + "hour\">"; for (var i = 0; i < 12; ++i) { result += "\r\n <option value=\"" + i + "\"" + (((this._date.getHours() % 12) == i) ? " selected=\"1\">" : ">") + i + "</option>"; } // Add extra entry for 12:00 result += "\r\n <option value=\"0\">12</option>"; result += "\r\n </select>"; // Add minutes result += "\r\n <select name=\"" + this._prefix + "min\">"; for (var i = 0; i < 60; i += 15) { result += "\r\n <option value=\"" + i + "\"" + ((this._date.getMinutes() == i) ? " selected=\"1\">" : ">") + String.leftPad(i, 2, '0') + "</option>"; } result += "\r\n </select>"; // Add AM/PM result += "\r\n <select name=\"" + this._prefix + "ampm\">"; result += "\r\n <option value=\"0\"" + (this._date.getHours() < 12 ? " selected=\"1\">" : ">") + "AM</option>"; result += "\r\n <option value=\"12\"" + (this._date.getHours() >= 12 ? " selected=\"1\">" : ">") + "PM</option>"; result += "\r\n </select>"; return result; } // Creates the HTML for the actual calendar part of the chooser DateChooser.prototype.createCalendarHtml = function() { var result = "\r\n<table cellspacing=\"0\" class=\"dateChooser\">" + "\r\n <tr><th>N</th><th>P</th><th>U</th>" + "<th>S</th><th>C</th><th>P</th><th>S</th></tr>\r\n <tr>"; // Fill up the days of the week until we get to the first day of the month var firstDay = this._date.getFirstDayOfMonth(); var lastDay = this._date.getLastDayOfMonth(); if (firstDay != 0) { result += "<td colspan=\"" + firstDay + "\"> </td>"; } // Fill in the days of the month var i = 0; while (i < this._date.getDaysInMonth()) { if (((i++ + firstDay) % 7) == 0) { result += "</tr>\r\n <tr>"; } var thisDay = new Date( this._date.getFullYear(), this._date.getMonth(), i); var js = '"dateChooserSetDate(\'' + this._input.getAttribute('id') + "', '" + thisDay.dateFormat(this._format) + '\');"' result += "\r\n <td class=\"dateChooserActive" // If the date is the currently chosen date, highlight it + (i == this._date.getDate() ? " dateChooserActiveToday" : "") + "\" onClick=" + js + ">" + i + "</td>"; } // Fill in any days after the end of the month if (lastDay != 6) { result += "<td colspan=\"" + (6 - lastDay) + "\"> </td>"; } return result + "\r\n </tr>\r\n</table><!--[if lte IE 6.5]><iframe></iframe><![endif]-->"; } Thanks ...
  24. @xoligy: I don't think a timeout will be OK, because the session is destroyed when a user closes his browser. When he logges back in, he gets new session_id. @Vivid Lust: I think I will need a javascript for detecting when browser is closing. Maybe an unload event or something like that...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.