close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Record Insert before page loads to track page visits

Thread began 8/20/2016 6:35 am by eric284736 | Last modified 8/29/2016 2:12 pm by Ray Borduin | 3228 views | 8 replies |

eric284736

Record Insert before page loads to track page visits

Hi Ray,

I have this setup to insert a record when the page loads so I can track the number of times a page is visited. There are four recordsets on this page that are pulling information based on the clientid variable.

What happens now is the clientid is inserted into the profileview table but it does it 5 times. The first insert is with the correct clientid but then it inserts a NULL, 96, 32, 16 as additional records.

I have included the page to see my code.

thx
Eric

Sign in to reply to this post

Ray BorduinWebAssist

Are you sure it is this page doing the inserts?

I'm not sure what would cause it, but you could prevent it by updating the trigger on line 48 to:

if ($rsDetail->getColumnVal("clientid")) {

Sign in to reply to this post
Did this help? Tips are appreciated...

eric284736

Yes this is the page that does the insert to track page views.
I updated line 48 to this:
<?php
if ($rsDetail->getColumnVal("clientid")) {
$InsertQuery = new WA_MySQLi_Query($connBLUR_i);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "profileview";
$InsertQuery->bindColumn("clientid", "i", "".($rsDetail->getColumnVal("clientid")) ."", "WA_DEFAULT");
$InsertQuery->saveInSession("profileview");
$InsertQuery->execute();
$InsertGoTo = "";
if (function_exists("rel2abs")) $InsertGoTo = $InsertGoTo?rel2abs($InsertGoTo,dirname(__FILE__)):"";
$InsertQuery->redirect($InsertGoTo);
}
?>

But now it is adding entries before and after the actual page visited. The attachment shows the actual id inserted for the profile in green. The three entries before and after should not be there. I don't think this is the issue but the field name for the date is "dateview". Is that a reserved word?

thx
Eric

Sign in to reply to this post

Ray BorduinWebAssist

It doesn't seem possible. Are you sure nobody else is visiting the site? The insert gets the value from the recordset and the recordset gets the value from the url. The multiple clientID records could only be inserted if someone visited that url with the associated clientID values.

Whatever the issue is, I'm pretty confident it isn't with the page itself.

Maybe try removing the .js files the page is using to see if they are somehow causing the page refresh.

Another option might be to add a few more fields to the database for debugging. Save the value for <?php echo($_SERVER['REQUEST_URI']); ?>

and the value of <?php echo(__FILE__); ?> and the value of <?php echo(session_id()); ?> during the insert. That would tell you the url of the page when it inserts, the page name doing the insert, and the sesison id of the inserting user.

Maybe that would shed light on it. Something strange is happening, but it is really hard to determine why or how that clientID would change or even could change.

Sign in to reply to this post
Did this help? Tips are appreciated...

eric284736

What is odd is the extra ids it inserts are the same ones 16, 32 and 96.

Another piece of information, I don't think that is causing the problem is I have a URL rewrite setup as such
RewriteRule ^.+-([0-9]+) detail.php?clientid=$1 [NC,L]

How do I capture the additional field in the database that you suggested?

thx
Eric

Sign in to reply to this post

Ray BorduinWebAssist

Create columns to store the information in that table and then set their values to the values I posted above.

Sign in to reply to this post
Did this help? Tips are appreciated...

eric284736

Thanks Ray, I think that has fixed it strangely enough :)

One other question:

I want to add 30 days to a date that is submitted on a form. So one would enter their graduation date in the form and submit the page. On the redirect page it will take the submitted date and add 30 days and display certain information if that date is with in the date +30 days.

My date submitted is pulled from the form like this <?php echo((isset($_POST["graduationdate"]))?$_POST["graduationdate"]:"") ?>

I know how to add it and display the date like this <?php echo date('Y-m-d H:i:s', strtotime( "+30 days")); ?>

Not sure how to add that to the form post date. Any ideas?

thx
Eric

Sign in to reply to this post

eric284736

I am trying this:
<?php
if ("".((isset($_POST["graduationdate"]))?date("m/d/Y", strtotime($_POST["graduationdate"])):"") ."" <= "".date('m/d/Y', strtotime( "+30 days")) ."") { // WebAssist Show If
?>

So if the graduation date is equal to or less than today's date +30 days then they would be able to proceed otherwise they cannot proceed. However the above is not working correctly.

Sign in to reply to this post

eric284736

I got! Thanks anyway! The correct code is:

<?php
if ("".((isset($_POST["graduationdate"]))?date("m/d/Y", strtotime($_POST["graduationdate"])):"") ."" >= "".date('m/d/Y', strtotime( "-30 days")) ."") { // WebAssist Show If
?>

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...