|
Have you looked into using Regular Expressions?
Just because I don't care, doesn't mean I don't understand.
- Homer J. Simpson
|
|
|
|
|
use in this way, first store alpha charcater in string, and then chk character in this string.
function isblank(s)
{
var c;
var chkstring="a,b,c,d,e,f....";
for(var i=0; i < s.length; i++){
var c=s.charAt(i);
if(chkstring.charAt(c) > 0)
{
alert("Can not enter a-z messages here");
return false;
}
}
return true;
}
Himadrish Laha
|
|
|
|
|
You should start by correcting your basic approach: instead of looking for errors in the input you should be testing for correct input and giving an error message if the test fails. See this article on data validation
|
|
|
|
|
How can I count the number of online users on my site? I have implemented my application as follows. Whenever a user logs in, I increment the count field in my database by 1 in Session_Begin and on Session_End I decrement it by 1.Though the code works fine in normal circumstances, I noticed a few anamolies:
1. If the user refreshes his browser, the Session_Begin is called again and the counter is incremented again. To overcome this, I used cookies. The first time the user logs in, I create the cookie. When the user refreshes his browser, it checks if the cookie exists, if it doesnt it treats it as a new request and updates the counter accordingly.
2. The problem arises on log out. Whenever the user refreshes his browser, Session_End is called that many times, and my counter is decremented more than once. How can I get Session_End to run only once for each instance of the browser?
3. I'm using Forms Authentication and on Session_End I want to call FormsAuthentication.SignOut since the user can still access the pages after the session ends,causing a new session to be started. But this function does not work in Session_End.
|
|
|
|
|
How about creating a dynamic array (ArrayList for instance) of the Session IDs? On Session_Begin, add the ID to the array if it doesn't currently exist, on Session_End, remove the Session_ID. TrimToSize each time and use the Count to get the number of active sessions.
I seem to remember a similar solution in traditional ASP using the Dictionary object...
Just because I don't care, doesn't mean I don't understand.
- Homer J. Simpson
|
|
|
|
|
Use application variable instead of session variable. Now U become free from session. Now check if page is refreshed by session variable. If the browser is refreshed and new session start then chk it on higher version browser, or better ie 5.5 and netscape 7.0, and I think this problem will not exist. If still exist then you have nothing to do.
But I am sure the problem will not exist.
Himadrish Laha
|
|
|
|
|
How can I keep track of the number of online users to implement concurrency metering? So far I have implemented as follows:
When a user logs in, I add an entry to a Status table in the database and store a cookie in his machine.Every time he refreshes his browser, it checks if the cookie exists.If it doesnt exist, it treats it as a new login and updates the status table.
Now I need to remove/decrement the status by 1 when the user logs out. I included this code in Session_End. But there is a problem, I need to call this fucntion only when the user closes his browser. If the user leaves his system idle or refreshes his browser again, Session_End is called twice and the status is decremented by 1 two times, which is incorrect.
How should I implement concurrency metering? Is there any other way other than using session, since most users would probably log out by closing the browser instead of clicking the Log Out button.
|
|
|
|
|
Hi all,
I'm a bit of a newbie to HTML, and I'm hoping the answer to this question is easy!
What I'd like to know is, is there a way to create a frame in an HTML file whose content is also specified 'inline', rather than by the src attribute e.g:
<html>
...
...
<frame>
This is the content of the frame
</frame>
...
...
</html>
The reason I ask is that I'm creating a page dynamically with ASP and I'd like the bottom half of the page to be a scrollable frame. It would be a lot easier to create the frame if the ASP code within the frame could access the variables in the top half of the page, which doesn't seem possible if the frame was generated from a seperate .ASP file.
Any suggestions would be greatly appreciated!
TIA,
Pete
|
|
|
|
|
I am a third yr computer student and I have a 6wk project coming up and I was thinking coding a p2p file sharing application, I was just wondering if anyone has any experience in writing any file transfer programs, If anyone could tell me if a simple implementation is difficult or could point me in the right direction of a place where I could find information on writing a simple file sharing p2p app… also I was thinking of writing it in java… anybody any comments??????????
|
|
|
|
|
Hi,
I'm not any kind of expert at P2P, but I'd say that implimenting even a /really/ basic app in 6 weeks would be pretty ambitious, even if you pulled a lot of all-nighters.
However, if you're still thinking about it I'd reccommend looking at the source of one of the open-source Gnutella-based servents. The developer lists for those servents would also be helpful I imagine.
Hope that's some help,
Pete
|
|
|
|
|
It is not a good practise to use others code, specially for exam. But U can take a help. If you need any help to transfer file using ASP technology, then I can help you. You may mail me at himadrish@yahoo.com. I have very good codes which helps you a lot to transfer file over the internet or intranet.
Himadrish Laha
|
|
|
|
|
Hi...
I am using cookies in my website to identify users... every user has username and password... I have an option for making the user remember his name...
Some users where simply able to modify the saved Cookie and change the name to use other user's names!!
The username in that case must be the same number of Characters as the stolen name...
How can Iprevent that in the most simple way?? is there a way to make the cookie more secure and prevent users from editing them??
I will appreciate a quick response from anyone of you...
Regards to all...
|
|
|
|
|
MatrixUndone wrote:
I am using cookies in my website to identify users... every user has username and password... I have an option for making the user remember his name...
Some users where simply able to modify the saved Cookie and change the name to use other user's names!!
The username in that case must be the same number of Characters as the stolen name...
How can Iprevent that in the most simple way?? is there a way to make the cookie more secure and prevent users from editing them??
That isn't really possible - cookies are just a text a file on the end users machine and they should be allowed to edit them if they really want to.
What you really need to do is provide extra checks to ensure that the cookie you wrote was the one that gets sent back later on.
You could use a hash of the username and password (and/or other suitable information) and store that in the cookie as well - this can be rechecked on your end quite simply, and if they don't match, then force the user to log in as normal. Whatever you do, the hash has to be generated from at least some information the "evil" user has not got access to - such as passwords you store in a database on your site.
If you generate a hash from just the cookie information, then an "evil" user can generate it too, using the information he wants in that cookie.
If you're using ASP.NET, investigate Forms Authentication, as this can provide the authentication facilities you're looking for.
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
Dear Ian
Thank for the reply...
is there a way or a simple script that I can use to encrypt cookies??
|
|
|
|
|
As he said, if you are using ASP.NET, you can encrypt your ticket using the machine key configured in your machine.config or Web.config script (the default is randomly generated). See my article, Role-based Security with Forms Authentication[^] for some brief details.
If you're not using ASP.NET, you have to decide whether to use a javascript file to hash the value on the client side, or to use some ASP code (or COM object) to do it on the server. For MD5 hashes, there is a myriad of examples on the 'net. To do this on the client, there's many javascripts you can use. According to a discussion I was checking out the other day (can't remember if it was here or /.), Yahoo! mail does this on the client before sending the password if the user opts to not use HTTPS (HTTP over SSL) - and who knows why anyone wouldn't want to use HTTPS!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath Stewart!
Can you please explain to me more on what should I do?? and if you can write down the JavaScript you're talking about and how to use it with Cookies... I will be grateful!!
Thanks already!
|
|
|
|
|
You should discover this for yourself. Just download one of those javascript files that I gave you a search link for. If you look on those pages, most should contain examples of what to do. Essentially, you just hash the password before you submit a form and send the password hash, or store the password hash in a cookie using client-side javascript. Just make sure your client script and the server use the same hashing algorithm, such as MD5 or SHA1 - both mathematically irreversable (known as a one-way hash or digest).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello, I am getting a contract programmer to do some web development for me (ecommerce site). Should I go for a java, asp.net or windows desktop version? what are the pros/cons of each? or should I go for all 3?
|
|
|
|
|
What you should do is hire me
Seriously, these a pretty broad questions to get answered here.
|
|
|
|
|
yeah, i know it is a very broad queation, but I thought it might open up a broad discussion about the major points. Im tending to steer away from the java platform given that a windows/desktop version is so much more powerful - but then how realsitic is than everyone can 1. load software onto their machine and 2. assume everyone uses windows
|
|
|
|
|
Instead of using onclick , you can use a real <a> tag with javascript: in the href , e.g.:
<a href="javascript:load_musique();">Musique</a>
- Mike
|
|
|
|
|
hooo!! nice, thanks!
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Hello, I've got the following code
test.asp
<%@ language="Javascript" %>
<%
var Connection,Recordset;
Connection = Server.CreateObject("ADODB.Connection");
Connection.Open("thesourcename");
var strSQLQuery = "SELECT * FROM clients WHERE .... "
Recordset = Connection.Execute(strSQLQuery);
Session("test") = Recordset.Fields("user_name");
Response.Redirect("test1.asp");
%>
and I've got another code ...
test1.asp
<%@ language="Javascript" %>
<%
Response.Write(Session("test"));
%>
Someone PLEASE tell me what am I doing WROOOOOOOOONG bacause ASP is driving me crazy. The book sais that the Session object should store the values from page to page.
I get an ADODB.Field no longer available error message. Could someone please tell me why ?????????????????
I've got almost the same code in VBScript and it works ....
WHAT'S WRONG ??
Thank you !
|
|
|
|
|
Apologies for not answering your actual question but don't do what you are doing. You are leaving connection objects to the database open, redirecting to other pages without closing them. That is not good.
Maybe explain what you want to do and we can recommend some better ways of doing it.
regards,
Paul Watson
Bluegrass
South Africa
Brian Welsch wrote:
"blah blah blah, maybe a potato?" while translating my Afrikaans.
Crikey! ain't life grand?
|
|
|
|
|
Don't mind the fact that I'm not closing the recordset and the connection. In real life I do that ...
The problem is that I want the test1.asp script to display the content of the Session("UserName") but I am not succesful because I get an error saying that :
Error Type:
ADODB.Field (0x80020009)
Object is no longer valid.
/meteo/test1.asp, line 3
Here is the code:
test.asp
<%@ language="Javascript" %>
<%
var Connection,Recordset;
Connection = Server.CreateObject("ADODB.Connection");
Recordset = Server.CreateObject("ADODB.Recordset");
Connection.Open("Clienti");
var strSQLQuery = "SELECT * FROM clienti WHERE nume_utilizator = \'" + "radio" +"\'";
Recordset=Connection.Execute(strSQLQuery);
Session("UserName") = Recordset.Fields("nume_utilizator");
Recordset.Close();
Connection.Close();
Response.Redirect("test1.asp");
%>
and test1.asp
<%@ language="Javascript" %>
<%
Response.Write(Session("UserName"));
%>
|
|
|
|