Category Archives: PHP

This section is related to PHP programming, CSS, HTML, Javascript, AJAX, JQuery.

Restful web services using slim and PHP

I have created a restful webservices using slim framework and PHP. I have created APIs for simulation atm machine.  In my case, ATM machine is PC and PC have uniquie name and password. The PC information is save in a file in jSOn format (serviceconfig.txt);

{“Machines”:[{“name”:”PC1″,”password”:”test”}]}

If you want to add another machine, add it in the above jSon..

And user information is saved in file(2007_1.txt);

{“User”:[{“name”:”Jawad”,”user_id”:”2007″,”pin”:1234,”balance”:49900}]}

If you want to create another user ,you will create another file having name userid_1.txt.

And its mini statement info is a save in userid_2, which is automatically created.

Following work of atm is simulated;

  • Enter a 4 digit user id here to simulate a card scan.

Its is handled with post method with name and password.

http://localhost/atm-services/login

  • Enter PIN screen

It is also handled with post method with name, password, userId and pin.

http://localhost/atm-services/pin

  • Balance check

It is handled with get method.

http://localhost/atm-services/balance/PC1/test/2007/1234

  • Cash withdrawal

It is also handled with post method with name, password, userId, pin and amount to withdraw.

http://localhost/atm-services/cashwithdraw

 

  • PIN change

It is also handled with post method with name, password, userId, pin and changepin.

  • Mini statement

It is handled with get method.

http://localhost/atm-services/ministatement/PC1/test/2007/1234

Code

form Validation Using Javascript

I have created program using javascript to validate the form. the code validate the pattern applied on the textbox and the requird field. Code is as following;

Code

I have create another program which uses Modernizr to detect html 5 feature used in the form. Code is as follow;

Code

Links Preview

Its an ajax project and in this project i have created tool tip using ajax to show the description of the link. I obtain the contents of the page of the link and show it as preview window when mouse move over the link. The project is attached in below link.

Code