Reply
http vs www
Old 05-16-2008, 03:09 AM http vs www
cbeaudin's Avatar
Super Talker

Posts: 126
Name: Clayton Beaudin
Location: Proud to be Canadian
I have a script (newtopic.php) shown below (i only included the important part)

If i go to "http://WWW.mysite.com" everything works fine

If i go to "http://mysite.com" everything works except the mysql_query($posting) gets performed once when the page is loaded and a second time when you leave the page.

This looks as if its probably a server issue rather than a code issue, but i didnt know where else to ask for help. Thanks in advance for any replies.

PHP Code:
       $name=$getid3['userID'];
       
$title=$_POST['title'];
       
$post=$_POST['post'];
       
$day=date("D M d, Y H:i:s");
       
$timegone=date("U") ;
       
$forumID=$_GET['forumID'];
       if(
$_POST['nosmiley'])
       {
         
$nosmiley=1;
       }
       else
       {
         
$nosmiley=0;
       }
       
$name=strip_tags($name);
       
$title=strip_tags($title);       
       
$post=strip_tags($post,'<p><a><b><i><img><u><font>[url][img][url][IMG][FONT][font]<sub><sup><span><li><size>[list][o][size][s][mail]');
       
$sticky=$_POST['sticky'];       
       
$posting="INSERT INTO b_posts (value, author, title, post, timepost, telapsed, postforum, lastpost, nosmilies ) values ('$sticky','$name','$title','$post','$day','$timegone','$forumID','$user','$nosmiley')";
       
mysql_query($posting) or die("could not post");
       
$updates="update b_forums set numtopics=numtopics+1, numposts=numposts+1, lastpost='$day', lastpostuser='$user', lastposttime='$timegone' where ID='$forumID'";
       
mysql_query($updates);
       
$updateuser="update b_users set Posts=Posts+1 where username='$user'";
       
mysql_query($updateuser) or die("Could not update numposts"); 
mysql_close(); 
cbeaudin is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-16-2008, 03:16 AM Re: http vs www
chrishirst's Avatar
Super Moderator

Posts: 13,669
Location: Blackpool. UK
It will be a code issue, just not that code.

At a guess;
there is probably some cookie/session code that is checking for the data having already been sent, but it is only checking if the http hostname has www in it.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-16-2008, 03:50 AM Re: http vs www
cbeaudin's Avatar
Super Talker

Posts: 126
Name: Clayton Beaudin
Location: Proud to be Canadian
Quote:
Originally Posted by chrishirst View Post
It will be a code issue, just not that code.

At a guess;
there is probably some cookie/session code that is checking for the data having already been sent, but it is only checking if the http hostname has www in it.
Thank you for the quick reply.

I know very little about cookies or sessions so i will do some reading before i post more code. If you happen to know any good websites for this off hand it would be appreciated.
cbeaudin is offline
Reply With Quote
View Public Profile
 
Old 05-16-2008, 11:47 PM Re: http vs www
cbeaudin's Avatar
Super Talker

Posts: 126
Name: Clayton Beaudin
Location: Proud to be Canadian
Sorry guys im really stuck, same problem, havent made any progress. Here is the full code.

PHP Code:
<?php
include 'connect.php';
session_start();
include 
"admin/var.php";


$forumID=$_GET['forumID'];
$user=$_SESSION['user'];

$getid="SELECT * from b_users a, b_templates b where b.templateid=a.templateclass and a.username='$user'";
$getid2=mysql_query($getid) or die("could not get user");
$getid3=mysql_fetch_array($getid2);

if(
$getid3[status]>=2)
{
$getforuminfo="SELECT * from b_forums where ID='$forumID'";
$getforuminfo2=mysql_query($getforuminfo) or die("COuld not get forum info");
$getforuminfo3=mysql_fetch_array($getforuminfo2);

if(isset(
$_POST['submitpost']))
 {
    if(!
$_POST['title'] || !$_POST['post'] || !$_GET['forumID'])
      {
        print 
"<table class='maintable'>";
        print 
"<tr class='headline'><td><center>New Topic</center></td></tr>";
        print 
"<tr class='forumrow'><td><center>";
        print 
"One of the required fields was not filled in, please go back and try again";
        print 
"</td></tr></table>";
      }
    else
      {
       
$name=$getid3['userID'];
       
$title=$_POST['title'];
       
$post=$_POST['post'];
       
$day=date("D M d, Y H:i:s");
       
$timegone=date("U") ;
       
$forumID=$_GET['forumID'];
       if(
$_POST['nosmiley'])
       {
         
$nosmiley=1;
       }
       else
       {
         
$nosmiley=0;
       }
       
$name=strip_tags($name);
       
$title=strip_tags($title);       
       
$post=strip_tags($post,'<p><a><b><i><img><u><font>[url][img][url][IMG][FONT][font]<sub><sup><span><li><size>[list][o][size][s][mail]');
       
$sticky=$_POST['sticky'];       
       
$posting="INSERT INTO b_posts (value, author, title, post, timepost, telapsed, postforum, lastpost, nosmilies ) values ('$sticky','$name','$title','$post','$day','$timegone','$forumID','$user','$nosmiley')";
       
mysql_query($posting) or die("could not post");
       
$updates="update b_forums set numtopics=numtopics+1, numposts=numposts+1, lastpost='$day', lastpostuser='$user', lastposttime='$timegone' where ID='$forumID'";
       
mysql_query($updates);
       
$updateuser="update b_users set Posts=Posts+1 where username='$user'";
       
mysql_query($updateuser) or die("Could not update numposts");
       
mysql_close();

       print 
"<table class='maintable'>";
       print 
"<tr class='headline'><td><center>New Topic</center></td></tr>";
       print 
"<tr class='forumrow'><td><center>";
       print 
"Thanks for posting... Redirecting to forum index <META HTTP-EQUIV = 'Refresh' Content = '2; URL =index.php?forumID=$forumID'>";
       print 
"</td></tr></table>";
      }
  }


 else
  {

  print 
"HTML for form to input the data";
 
 }

}

else
{

    die();

}
 
?>
Connect.php
PHP Code:
<?php
$db 
mysql_connect("*****""*******""******") or die("Could not connect.");
if(!
$db
    die(
"no db");
if(!
mysql_select_db("clayton_forum",$db))
     die(
"No database selected.");
if(!
get_magic_quotes_gpc())
{
  
$_GET array_map('mysql_real_escape_string'$_GET); 
  
$_POST array_map('mysql_real_escape_string'$_POST); 
  
$_COOKIE array_map('mysql_real_escape_string'$_COOKIE);
}
else
{  
   
$_GET array_map('stripslashes'$_GET); 
   
$_POST array_map('stripslashes'$_POST); 
   
$_COOKIE array_map('stripslashes'$_COOKIE);
   
$_GET array_map('mysql_real_escape_string'$_GET); 
   
$_POST array_map('mysql_real_escape_string'$_POST); 
   
$_COOKIE array_map('mysql_real_escape_string'$_COOKIE);
}
?>
cbeaudin is offline
Reply With Quote
View Public Profile
 
Old 05-17-2008, 11:09 PM Re: http vs www
evilhuman's Avatar
Junior Talker

Posts: 3
Name: Tom
Quote:
mysql_query($posting) gets performed once when the page is loaded and a second time when you leave the page.
I'm curious about this. Is there any Javascript involved that might be called as you leave the page, triggered due to the slightly different URL, which is remotely calling this page again?

Long shot but I thought I'd ask.
evilhuman is offline
Reply With Quote
View Public Profile Visit evilhuman's homepage!
 
Old 05-19-2008, 03:18 PM Re: http vs www
cbeaudin's Avatar
Super Talker

Posts: 126
Name: Clayton Beaudin
Location: Proud to be Canadian
There was Javascript at one point but i took it out as soon as i started having problems.

After messing around with code for hours i finally narrowed it down a lot further.

I found out that it didnt only happen when i left the page but also every time i switched back and forth between tabs if firefox.

I found out that this problem only happens in firefox (not in IE). Then i found out it only happens on this computer, not my laptop.

After i learned this i decided to remove "Display Page Validation" from the web developers tool bar if FF.

So far EVERYTHING WORKS so im keeping my fingers crossed that the page validation toolbar was just refreshing the page without telling me i was resubmitting a form....

Thanks again for everyones help!

Last edited by cbeaudin : 05-19-2008 at 03:21 PM.
cbeaudin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to http vs www
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14778 seconds with 12 queries