Jump to content

Tech Questions


Sasun

Recommended Posts

I want to count the number of clicks on a certain link and store in a db table. Could someone tell me how to do it? Its an email link, so web access log wouldn't record the click.

I am looking something like a piece of javascript or jsp code.

Edited by Sasun
Link to comment
Share on other sites

just call the page back with a query value like http://......../page.php?email=yes

 

then you can either look at the logs with that page with the query value or better yet have code in the page to record it directly to the DB.

 

You also will need a java script code to open up a new page with the mailto so it opens up the email form

Link to comment
Share on other sites

just call the page back with a query value like http://......../page.php?email=yes

 

then you can either look at the logs with that page with the query value or better yet have code in the page to record it directly to the DB.

Azat jan, thanks . Actually I am relying on the mail client on the user's computer, if they have one. So, here is an example page :

http://www.armport.com/Outside/Other/OutOt...ails.jsp?ID=482

My goal is to count how many times people click on the email link.

 

I don't have an email form (like FormMail.cgi, etc) because those are not safe. That is why for now I have the simplest way.

 

I like the first solution (calling back the page with ...email=yes), that is simple :)

 

You also will need a java script code to open up a new page with the mailto so it opens up the email form

Why can't I have an email form on the same page, rather than opening it with a java script? Or open a regular page with an email form? Would java script help avoid security issues like people wanting to send spam email using my email script?

Link to comment
Share on other sites

Sasun jan :) you can du this teh hard way or just pay me and Azat $1 a click and we will count it for you :)

 

 

 

Azat k@pav aper :) tes hesa marta mi hat MBZ 600 enq arnum / aper k@pela :)

MosJan Jan, not so fast :) Wait until I become a millionaire B)

Link to comment
Share on other sites

I want to count the number of clicks on a certain link and store in a db table.  Could someone tell me how to do it? Its an email link, so web access log wouldn't record the click.

I am looking something like a piece of javascript or jsp code.

You can use

     Email: <A HREF="http://www.armport.com/Outside/Other/OutOtherDetails.jsp?ID=482&email=test@test.com">test@test.com</A>

 

Your script will record the click and redirect the user to "mailto:test@test.com" which will popup the mail client window.

 

As for formmail.cgi - if you configure it properly it's not as insecure as you think.

Link to comment
Share on other sites

You mean this?

 

test@test.com

 

It doesn't open an email window.

Yes I meant that but you need to make some changes on your OutOtherDetails.jsp script as well in order to make this work.

 

- Parse the URL to find out if the GET request contains any 'email=test@test.com' pair

- If it contains 'email=test@test.com' then increase the click counter for that email address in your database

- Redirect the user by forcing the user's browser to open 'mailto:test@test.com' URL which will popup the window of user's email client software. I'm not very familiar with JSP but I guess it'll look somthing like 'response.sendRedirect('mailto:test@test.com')'

 

BTW, while you're trying to 'protect' your website from being used by spammers to send out spam through a misconfigured email script you leave your members' email accounts unprotected in front of the same spammers and their email harvesting software and they can easily collect these addresses and start using them in their email campaigns.

Link to comment
Share on other sites

Yes I meant that but you need to make some changes on your OutOtherDetails.jsp script as well in order to make this work.

 

- Parse the URL to find out if the GET request contains any 'email=test@test.com' pair

- If it contains 'email=test@test.com' then increase the click counter for that email address in your database

- Redirect the user by forcing the user's browser to open 'mailto:test@test.com' URL which will popup the window of user's email client software. I'm not very familiar with JSP but I guess it'll look somthing like 'response.sendRedirect('mailto:test@test.com')'

 

Oh, I see. So it involves more work than I hoped :) Thanks Garo, I may try that, or ....

 

BTW, while you're trying to 'protect' your website from being used by spammers to send out spam through a misconfigured email script you leave your members' email accounts unprotected in front of the same spammers and their email harvesting software and they can easily collect these addresses and start using them in their email campaigns.

 

... or I will go for a better solution that doesn't expose the email addresses. I tried that formmail.cgi. They say they have made it very safe, but that works only if the send-to email is under my domain name. That way the spammers will not be able to send to other email addresses. So I gave up on this one. Then I tried some servlet which didn't work at all, and I gave up on that too. As a result, yes, probably the people who are using armport.com are getting a lot of spam :) But that is life... :) I don't know JSP or CGI or else very well, so it's a problem to write my own email script, so I need a ready made something to use. Maybe I will try to look for a php module.

 

But anyway, thanks :)

Link to comment
Share on other sites

Oh, I see. So it involves more work than I hoped

I think the whole code will be 5-10 lines if your existing script already has some routines to send sql queries to your database (to update the counter). But if you don't know programming then it's a different story. I could help you with this but unfortunately I can not do it at this moment.

Link to comment
Share on other sites

Garo, thanks for your interest in this. Actually I know programming but not much in JSP or anything web related. One year ago I learned just about enough to put together the website and quickly forgot (well, not all of it) for not using afterwards. But I remember I have routines to access the database - I know what you mean.

I am thinking to give a try to a JSP Tag I found on the web which is supposed to behave like a FormMail. That way the users will not curse me for receiving spam, and I will be able to count more precisely how many times they are contacted. After all, if someone clicks an email link that doesn't mean they will go ahead and send an email.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...