I am a beginner but I successfully have set up a Flash-PHP-MySQL login process which functions perfectly.
I want to know what I must add to my PHP Script in order to:
1 - Add 1 to an appropriate column in the row corresponding to the visitor each time the visitor loggins and...
2 - Insert the date of this visit which replaces, of course, the date of the preceeding visit.
I know of course how to insert new columns to my table and I also know how to pass variables from Flash (MX not MX2004) to PHP.
If needed, I can post here the PHP Script I use.
Many thanks in advance for your help!
I think you want to track the users login. Like the no. of times he loged in and the time of last login. For this you just have to run an update query which will update the table where the users login is stored.
u have can run this query just after the user get authenticated by mysql.
I think you have a good understanding of my goals.
However, in order to save time and multiple postings, here are some precisions:
User registration/logging uses from a Flash file three PHP Scripts (which you can download, virus free of course!, at <http://www.germaris.com/files.zip>).
One is for connecting, the other for the functions and the third for operating.
What I really want?
Each time a registered User logs in, it triggers automatically via the script 'user' an incremental update of 1 of its row in the appropriate column of the table (to be created) nammed for example 'hits'. It also triggers an automatic update of its row in another column (also to be created) and nammed for example 'lastVisit'.
Well, there it is...
If you need more explanations or informations, just tell me!
Where would you like to store the information of user log. you have not given any table stucture about this. i think you have to create one table in which you can store the username, last login and the hits of the user. You have to be clear that do u want to stroe each hit of the user of you want only one hit for a day. Or one hit for a session.
Based on this you have to prepare the script and then and insert statement in the registration page where the last login and the hit will be null.
Another query will be an update query that can be your login fuction or the page that calls the login fuction, once the function returns a true value update the table with the latest value.
Hope you got the idea.
If you have any more doubts let me know.
Sorry but, if (as I invited you to) you have downloaded the files (<http://www.germaris.com/files.zip>) there is in the archive a file nammed 'users.sql' which gives you the table structure. I am able, following the solution you'll provide, to add the appropriate columns.
I want to store each hit (number of hits will be high and because of the weight of the file I want to have an eye on the bandwith) for each user.
About the date, each hit will update the date with the hour-minute-second precision (???) if there are multiple hits on the same day, decision will be yours as I'll follow your advices.
The solution I need is an update query which I ask you to write and include in the script nammed 'user.php' within the login function.
When this problem will be solved, I think I'll ask you to rewrite the 'function valid_email($email)' located in the file nammed 'functions.php' and which is disabled because it is not convenient for reasons I'll explain later.
This new question will not be urgent and will be treated as a "bonus" only if you have some free time to dedicate to it ... :-)))
Thank you for the interest you have in my problems!
I have gone through the user.sql, it has only one table stucture and that is users Table, which does not have the fields for the logs. So heres what we would do.
We will create a table like userlog. the fileds would be userid, hit (will be incremented by adding one to it when user logs in) and a time stamp. The time stamp would be better as it will store the exact time with hours & mins.
I am attaching (http://www.rajeshrr.com/beta/test/files.zip) the two files user.php and user.sql. I have added the update code in the user.php and add the create syntax for userlogs table.
Download it and check it. you may have to do little corrections (sometimes). As I have done this in a hurry.
Give me the feedback for this.. tell me is this what you want.
Please try this code. This should work. This is based on your request for single table.
The table structure that you have give is ok. Based on that you can run this code.
$username = trim($username);
$sql = "SELECT * FROM $table WHERE userName = '$username'";
$result = mysql_query($sql);
$row = mysql_fetch_object($result);
$userhit = $row->userHit;
$query = "UPDATE $table SET userHit='$userhit', logTime='time()' WHERE userName='$username'";
mysql_query($query) or die(mysql_error());
echo "User Information Not Found";
Thank you, Rajesh !
It works great at first try, but... only for the hits, not for the time.
Use this instead
$query = "UPDATE $table SET userHit='$userhit', logTime='".time()."' WHERE userName='$username'";
The time function is from php and it will retrun the timestamp. to display you have to use the date() function.
The date() will work like this
$strdate = date("F j, Y, g:i a", time()); // June 30, 2004, 12:16 pm
The output depends on the timestamp you give. And the function will return a
string date ( string format [, int timestamp])
Hope this will be fine.
Feel free to ask any help.