Jump to content

Ghostu

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Ghostu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks man it worked, the sites dynamic so had to use some extra code like this: [code]$page = $_SERVER['REQUEST_URI']; $host  = $_SERVER['HTTP_HOST']; $extra = $page; header("Location: http://$host/$extra");[/code]
  2. Thanks alot, that works, but one last question how would I use that to direct them back to the page they left the comment on? Thanks again!
  3. I made a comment script where users can type their comment into a form and then press submit to add it to my database. It works fine except for that if a user submits a comment, but then refreshes the page, the POSTDATA is resent and then the comment is posted again. So everytime the page is refreshed the same comment is added. What can I do about this? Heres the script in action: [url=http://photoshopandyou.com/tutorials/view.php?action=view&id=7]http://photoshopandyou.com/tutorials/view.php?action=view&id=7[/url] And the code: [code]//Comments //The date $date = date('F jS, Y g:i a'); //Variables if(isset ($_POST['submit'])) { //Simplifying the variables. $title = $_POST['title']; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; //Checks for empty fields or invalid date. if((empty($title)) OR (empty($name)) OR (empty($email)) OR (empty($message))) { echo "<center><strong>Please fill in all fields!</strong></center>"; } else { //The MySQL query which will insert content into the table. mysql_query("INSERT INTO tutorial_comments (ID, tutorial_id, title, date, name, email, message) VALUES ('', '$id', '$title', '$date', '$name', '$email', '$message')") or die(mysql_error()); echo "<center><strong>Comment added!</strong></center>"; } }[/code] Thanks.
  4. Thanks very much, worked like a charm  ;D Heres my code: [code]//Hit counter //Get visitors IP address $ip = $_SERVER['REMOTE_ADDR']; //Check if the IP has been to tutorial before, if not add the IP to the table, also update hits $fetch = mysql_query("SELECT ip FROM unique_hits WHERE ip = '$ip' AND tutorial_id = '$id'") or die(mysql_error()); if ( mysql_num_rows($fetch) == 0 ) {   mysql_query("INSERT INTO unique_hits (ip, tutorial_id) VALUES('$ip', '$id')") or die(mysql_error());   mysql_query("UPDATE tutorials SET hits = hits+1 WHERE id = $id") or die(mysql_error()); }[/code] I agree about removing old entries from the table, thats a good idea, but I have quick question. I made the field called time as a timestamp, was this the right move and how would I code it to remove IP addresses that are over an hour long? Thanks again for the help!
  5. Hello, Ive been working on a content management system lately. [url=http://photoshopandyou.com/tutorials/]http://photoshopandyou.com/tutorials/[/url] First, a little background on what I have going on here: In my database I have a table called "tutorials". Each tutorial has its own row in the table. I have a page called view.php which is the backend of the site, it runs a query and displays a preview of all the tutorials in the database. The preview has a link to the full view of the tutorial, as well as showing the category, date added, and a small description of the tutorial. What Im trying to do is display the number of unique hits as well. The hit counter you see on the site right now was added by making an extra column in my table called "hits" and using this code: [code]$sql = "UPDATE tutorials SET hits = hits+1 WHERE id = $id"; mysql_query($sql) or die(mysql_error());[/code] This works, but its not a unique counter and updates every time someone even refreshes a page, so as you can imagine it doesnt give a very accurate amount of views. My question is how would I go about turning this into a unique hit counter? Or limit it so a visitor can only add 1 view per hour or something. Ive seen a hit counter like this on other tutorial/article sites, but just havent been able to figure it out. My only idea is to make another column in the table to store the IP addresses that visit each tutorial, but is it even possible to store multiple IP addresses in a single field? So that I can keep track of which addresses visited which tutorial? I made a unique hit counter before using IP addresses, but it made a new row for every IP and thus could only provide a counter for 1 page per table....not good. Are there any better methods of going about this that Im overlooking? Thanks for any help, its much appreciated.
  6. You can also use [code]$today = date('n/j/Y');[/code] Only difference is how its formatted when you print it out. [url=http://www.phpfreaks.com/phpmanual/page/function.date.html]http://www.phpfreaks.com/phpmanual/page/function.date.html[/url]
×
×
  • 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.