Remember Me option

Well , I was making a small login script which authenticates the user name and the password . I had completed it .. not a big task .. But , then I thought why not put up a Remember me option . The one which when checked , remembers your user id or password depending upon the implementation .

I made one which remembers the user name , so you dont have to type the user id every time you login .

This is the screenshot of the login page .

rem me

I am only giving the code for the Remember Me part.

Here’s the code :

This displays the checkbox . This should be inside a form.

<input type="checkbox" name="Rem" />Remember Me

This creates the cookie named ‘remember’ . Write this code where you process the form .

< ?php
 setcookie('remember',$_POST['user'],time() +60*60*24*30 );

I have set the cookie to expire in 30 days from the current time . You can set whatever you wish

time() displays the amount of seconds since epoch i.e  00:00:00 UTC on January 1, 1970

60*60*24*30 is the number of seconds in 30 days .

Now , to display the user name , if the remember me option was selected . This should be where you display the form . (the same file in which you had writtenthe remember me option ) .

< ?php
 echo "<input name =\"user\" type=\"text\" id=\"user\" value=".$_COOKIE['remember']."/>";


Note : I have made the remember me option only for the user name . If you want the password to also be remembered, then set another cookie for password in the same way .

As always , comments are most welcome !!!

1st Year @ MIT – PART 4

The first question that comes to your mind will be “Where is part 1, 2 and 3?” For all those ignorant readers part 1 is here . But, still part 2 and 3 is left. Well, you can’t find them on the blog because I am still writing them. So, the question now arises why PART-4 before the other two parts. To understand the answer, let me first tell you how the 1st year is divided into 4 parts (2 semesters +???).

PART 1: First Semester (16 July – 5 Dec)

PART 2: Holidays after the first semester (6 Dec – 11 Jan)

PART 3: Second Semester (12Jan – 29th May)

PART 4: Holidays after the Second semester (30th May – 19th July)

Many of you would disagree with my division of the year into different parts but in an engineering student’s life, this is how it is. So bear with me!

Now , coming to the point , the reason of releasing part 4 before the other two is simply because PART 4 is still fresh in my mind … I will have to go deeper into my mind for the other two parts (lolzzz…..)

First Three days ( May 29 , 30 and 31 ) : 29th May was the last working day which also coincided with  my Engineering Graphics Exam .. and more importantly my BIRTHDAY.. (I would describe my experiences of E.G. in detail in PART 3 )..  My birthday celebrations were mixed with packing woes ( I had to pack all my stuff and lock it up in the common room ) … but despite the busy schedule, my friends had time for the coveted “Birthday Bums “.

Rajdhani Express, boarding time, 6.50 am, May 30th : As I got late packing my stuff, we planned to go on for a night out, and thus ordered pizzas. We went on to play scrabble for like 4-5 hours and then it was departing time. It was the first time, that there was no one else on my ticket but still I knew a couple of friends on the same train. As soon as I boarded, we were given breakfast in which I noticed a considerable drop of quality from earlier. I won’t go into much of the details except that I slept most of the time, read a novel and played cards. I knew few people in my compartment and made friends with the rest. I reached Hazrat Nizzamudin on 31st May at around 2.30 pm, the train was late by around 3 hrs (I hope Mamta Banerjee does something for these delays). Then, I went up to the wrong gate of the station (the Nizzamudin station has two gates).

I reached my home finally at 4 pm and then had a hearty lunch (the famous Mummy ka khaana). In the evening, I went to Nirula’s to have my favorite ice cream (Butterscotch flavor).

June: June went off pretty peacefully without much major events. I had started to become an internet addict thanks to the free Wi-Fi by my neighbors. I was online most of the time. Chatted almost daily with five different people, increasing my contacts manifolds. Well, it was great saying “hi” to the same person five times a day (Aamir and Prateek would understand it much better). I also honed up my skills of programming (learnt JS, PHP, CSS, and HTML). Then, came the 10th of June the R-DAY (results came out). I was very anxious about my result this time because of EG. I got to know my result when I was in a dentist’s chair (imagine getting to know your result when a doctor is operating upon you). So, the question arises what’s my GPA (Grade Point Average), a modest 8.38 and CGPA 8.77

Many would think of it as a very good one. I am not boasting but being ambitious I expect more of myself.

One of the major things that happened was that I got a Learner’s License made and started learning driving. Well, it was cool to be in the driving seat.

Me and my school friends had two reunions this time around. Even after two I could only meet up half my class. It was great to meet my friends after a gap of six months. We played cricket, TT, pool, carom and HIDE N SEEK (that too in the biggest mall in NOIDA, The Great India Place). I suggest all my readers to try playing hide n seek in a mall; believe me its great fun running around with all the onlookers staring.

July: The onset of July saw to an enhancement of my driving skills (took a couple of U – turns etc.). I met up with my friends once again. But this time at the heart of Delhi, Connaught Place. This was our third reunion which saw an increase in the boys to girl ratio by a great deal (there were 3 girls and 4 boys, a number never seen before).  We spent a lot of time hunting for an eating place (imagine we couldn’t find an eatery in CP!!!).The most important outing of this month was the visit to my school .. It was a great time meeting all the teachers after you have passed out … I have to mention here , the change of attitude one sees when we meet our teachers after passing out .. Almost every teacher of mine told us that ours was the best and the most disciplined batch they had ever taught, but during school , I remember hearing the opposite  .. The only irritating thing was that I had to repeat the answer to “what I was studying ?” almost 15 times … I managed to watch ICE AGE 3 with my friends .. Also , I went a couple of times with my family for a outing …

As only 12 days have passed there is nothing more to add. But we friends plan to watch the much awaited movie Harry Potter – 6, first day first show and be the guinea pigs of reporters.

After such a roller coaster of events in these holidays I am really looking forward to the re-opening of college. Ah yes , I would be a senior …

PS : This is the first time that a post on this blog by me has been edited by someone . I am grateful to Anirudh ( for editing ) and Prateek  ( for critical comments ) for their help …


Well , I was working on a small site … in which I had to save passwords of many users ..  Till  a week ago , I used to save the passwords simply as a string which means anybody having the access to the database could have viewed the password .. which is a serious security breach but I had not paid any attention to it … till the time my friend (Manu ) told me to use MD5 for hashing the password.. I searched on google about it … it was very simple … But ,I am still writing this post so that people beginning with php could benefit ..

Here is the syntax :

string md5 ( string $str [, bool $raw_output= false ] )

It returns the hash as a 32-character hexadecimal number.

Here is the detailed description

So , when you check the user if he has logged in using the correct password , you do like this :

[sourcecode language=’css’]
include ‘includes/mysqlconnect.php’; // include mysql connections here
$sql=”SELECT * FROM user WHERE Username='”.$user.”‘”;
if($password==md5($_POST[‘pass’])) // pass is the name of the variable which contains the password
echo “Correct password”; // you have established the fact that the user has entered the correct password

In this small code , I compare the password entered by the user in a previous page which is passed on to this code by POST with a variable name ‘pass’ . I first select the password of the particular user then store it into a variable named password and then compare it with the md5 hash of the POST variable ..

Now , suppose if you have already saved many passwords into your database ( this happened with me ), then how to go about it ..One option is that you can ask all your users to reregister .. but that would surely be a waste of time ..

So , I wrote about a php script for it .. ( I am sure all experienced coders would find this very easy )

[sourcecode language=’css’]
include ‘fm2/includes/mysqlconnect.php’; // the mysql connections
$sql=”SELECT * FROM user “;

$sql2 = “UPDATE `info`.`user` SET `Password` = ‘”.$password.”‘  WHERE `Username` = ‘”.$row[‘Username’].”‘”;

Simply save this as .php extension and run the file .. Remember to include the mysql connections  ..

Here , you take the data of all the users from the database and then md5 each password then save it to the database …

Interested people could read on to know that breaking a md5 is almost impossible … click here

I hope this little piece of code helps someone …

PS: If anyone has anything more to share on saving passwords , he/she is most welcome .. Use the comments section or the contact me page ..
BTW , I discovered how to post codes in wordpress ..


As suggested by ankur and djays , you could make your password more secure using sha and salt ..
First generate the salt ( as given by djays in the comments)
[sourcecode language=’css’]
$salt = substr(str_pad(dechex(mt_rand()),8,’0′,STR_PAD_LEFT),-8);
$secured = $salt . hash(’sha256′,$password.$salt);
Then save both the salt and the secured in your database .

When ever you wish to authenticate the user , select the salt and the password for the particular user and then generate the $secured using :
$secured = $salt . hash(’sha256′,$password.$salt);
Now , compare the $secured and the password from the database . If they match , then the user has entered the correct password .

Book Review: Where Are The Children?

Hey all!!! Well this is my first post on a blog, so I would request you all to look at it as a piece of work by an amateur for I may not have the charisma of writing as all the co-authors of the blog. And here today, I decided to write on book I recently read about an author rarely known in India, Mary Higgins Clark.

Browsing through my bookshelf I stumbled upon this book which my brother had got some years back, from a book exhibition at a discount (which you generally get for old stupid books that no one reads). As I was getting bored and had nothing to do in my holidays so I started to read through the pages of the book titled “Where Are the Children?” Soon enough I found myself engrossed with the book and couldn’t help myself turning the pages as a 5 year old would do while reading ‘Alice in Wonderland’.

The story of the book revolves around a female character, named Nancy Harmon, who is a mother of two children. The story gives a jumpy start when the two children go missing and the mother is blamed for the loss. The plot unravels in due time (I am not spoiling any suspense as all that I am going to mention is already mentioned in the back cover of the book) that she already had lost her two children in a similar fashion, who were later found dead, from her previous marriage who were of the same age as missing children and she has faced charges against her for the same. Being unable to withstand the shame and trauma she went in for a new life and her life changes into a dramatic horror when she sees the past being repeated at her.

Mary creates a nail biting suspense about what the real mystery about the missing children is, co relating the perfect timings in which the two incidents took place in the course of years. She brilliantly portrays the effect and drama that media creates and plays with the emotions of its audience. She takes the reader to the edge of the seat by narrating multiple scenes side by side (a style I have seen in Dan Brown, but obviously he came in much later than her) and thus taking the story to a level of excitement never experienced before. I had not read better display of children’s thoughts and action before I read her piece of art. She handles multiple characters with an ease and doesn’t seem to falter anywhere. Though the story sometimes may feel that it is going too fast to absorb, but isn’t that what you really want form a mystery thriller?!!

To sum up I would say that you must try the novel and give the bestseller author of USA a chance in India. I didn’t mention it earlier but the novel is already in its 75th reprint and the author claims a great fan following in US and is listed in bestselling authors. Have a nice time reading it!!


Well , I was browsing through the various features of WordPress … . I came across Ratings … I then added the rating feature to all things possible .. ( Posts , Pages , Comments ) . It will be a five star rating …

So , people start rating my blog… This would really help me improve the content…

Thanks in advance…..

1st Year @ MIT – PART 1

The Long awaited post finally comes … Initially , I wanted to write this post just right after the first year exams .. but as usual circumstances did not permit me…(a very strong statement)… So , now coming to the topic ..

Well , if I had to describe the first year of college in one line , it would be ” one of the most memorable year and a year of change  ” .. the usual one liner .. But , its true , I have changed a lot during this year , my close friends(those who have known me since school) would have surely noticed .. To start with , I have made quite a lot of friends , some of them very close too….

Lets split up the first year into different parts :

First day : I arrived a day late thus missing the orientation programme..I reached Manipal at around 8 pm ( via Rajdhani from delhi then a taxi to Manipal from the udupi ) .. Me n my frnd ( Anirudh ) both of us entered the coll when it was pitch dark…. We went directly to the K Block ( my hostel) .. the caretaker ( rather Vasu anna..).. and he gave us our room keys .. we completed sum formalities.. The first impression I had when I entered my room .. “how would I stay here for one whole year ” .. the room was arnd 9 feet by 9 feet .. no bathroom (there was a common bathroom  , no ac , no tv … just a table , a chair , a bed , a godrej almirah attached to the wall ..Then we had dinner in Apurva mess ,the food was a lot better .. After settling in the room ( buying some things , unpacking etc ) to my astonishment , I had a good night sleep…

First week : I woke up at arnd 6 daily ( its too early for me) .. had a good bath … then I went to the college and back to hostel like a good college boy .. Just had random chats in the college with classmates and got to know the teachers , make a good impression ( the impression helped me a lot .. to escape fines..).. In the evenings , me and my hostel mates all sat together .. then had a good nice long chat which extended up to wee hours in the morning ..We chatted about almost anything ranging from where have come from to our ranks in the recent exams .. from our school to our crushes .. It was like narrating your story to entirely new people… Very soon we had to got to know each other as if we had known each other from years ( Its strange that we get to know people very easily by having a long conversation .. ).. Eventually , I made many friends during the course of the first week …

First month : The first month was pretty cool , not at all hectic .. I had developed a bad habit of sending sms for everything right from calling people for mess even when they stayed only a couple of metres away ( Thanks to Airtel’s 100 free sms daily).. My mobile bill would have surely soared up a lot if not for the free sms .. During the first month , I learnt a lot about the college , about the various clubs , activities etc.. ( I was amazed by the number of clubs MIT had) ..Most of the month went off in eagerly waiting for our laptop ( For those of who dont know , MIT gives a laptop to each and every student ) .. But still we managed to watch a quite a lot of movies ( on a friend’s laptop who was kind enough to let us use ).. I was starting to get a hang of the college also …  I also had the chance to witness a birthday in the first month of the college . We just went out for dinner ( rather snacks ) . BTW , it was my friend AATIF’s birthday .We had our sessionals just after the first month ..

The next few months ( August , September , October ) : Finally , I received my laptop  in the last week of August , LENOVO R61 .. I was the first one to receive it in the entire hostel .. The first privilege of belonging to Computer Science ..I experimented quite a lot with MY FIRST LAPTOP . Then , I had my sessionals , the results were not as expected but were ok overall .. I attended quite a lot club meetings .. Me n my friends went on a trip ( Freshers Day out ) to nearby places organised by Rotract . .. It was fun indeed .. learnt a couple of words (  like bakchodi etc) .. Also , we had a IITian teaching us ( guess what ??) Ethics .. it was a subject which was ideal for easing off tension .. Initially , I liked the teacher and what he preached .. Infact , I went to his house every Saturday along with my friend Ankit to attend a informal type of gathering .. We just chanted Hare Rame Hare Krishna  and then had dinner which was made and served by our seniors … ( I must admit here that the food was very good )..  I even thought many of the people came here just for the food.. I attended a workshop by LUG MANIPAL .. on Mobivision … then eventually made a small application using Python with my classmate Appan . (had great help from seniors like OS and Shubendra bhaiya ( a forum NOKIA Champion)). Then , the second sessionals arrived which passed off without much problem except low marks ..Then the biggest Techfest ( I ever attended ) arrived , TECHTATVA 08 .. I took part in many events but to my utter disappointment not won a single one even though I had qualified for the last round of every competition ..Infact I came third in TECHOPS ( the first and second were both seniors ).. I had taken part in too many competitions ( the maximum one could because of time constraints ) .. There was a time when I had to choose between two competions ( MOBIVISION and AMAZING TECH RACE ) . I had reached the finals of both the competitions but I chose MOBIVISION for I had coded a application for it .. But , finally I lost both .. So , I am eagerly waiting for this year’s Techtatva to WIN .. After that , we had Dhol Baje ( a cultural event by Rotract ) .. I had helped quite a lot by volunteering.. I had also set up my first info desks in the college for the publicity of the club..

More in my next post ..