25
2009
Create foreign key using Phpmyadmin
The innodb storage engine supports foreign keys in Mysql. To create foreign keys in phpmyadmin : 1. Convert both tables into innodb, if they are not already. 2. View the structure of the table which will have a foreign key. Make the referencing field an INDEX. 3. Now come back to structure view and click Relation view. In the Relation view page the field (which was made an INDEX) can be made a foreign key [...]
1
2009
PHP redirect – go back to previous page
To go back to the previous page the superglobal variable $_SERVER can be used. $_SERVER['HTTP_REFERER'] has the link to the previous page. So to redirect simply :
1
2009
PHP Format numbers to Indian Numerical System
The numerical system used in India differs from the Western system in terms of the placement of the thousands separator. Example : Number -> 1000000 Indian System -> 10,00,000 (Ten Lakh) Western System -> 1,000,000 (1 Million) While echoing numbers in PHP it is possible to format numbers with such separators using functions like number_format. To format a number in the Indian Numerical System the code would be : and the output should be : [...]
30
2009
Create short links using bit.ly from php
bit.ly is a simple url shortner which has an api , which can be called from within php to shorten links. Code : The above function can be used to shorten a big url , as : The function needs an api key. To get your api key simply register at bit.ly then go to My Account and get your api key.
15
2009
Put flash in webpage – html page
Here is the simple code to put flash animation (swf file) on a webpage.
7
2009
Draw – Plot graphs with mootools
Plootr is a useful library based on mootools 1.11 which can be used to plot bar graphs , line graphs and pie charts. It is similar to Plotkit which is based on Mochikit javascript framework. For jQuery framework there is a library Flot. Other libraries include JsCharts , TableToChart etc.
6
2009
Raw Sockets programming on Linux with C
Raw sockets or packets contain user defined IP headers. Its as simple as that. Here we shall consider sending a raw tcp packets. A tcp packets has 3 parts : IP header + TCP header + data The structure of IP Header as given by RFC 791 is : The structure of a TCP header as given by RFC 793 : To create a raw socket : Another option to make sure the kernel uses [...]
3
2009
SYN Flood DOS Attack with C Source Code (Linux)
TCP/IP 3-way handshake is done to establish a connection between a client and a server. The process is : 1. Client –SYN Packet–> Server 2. Server –SYN/ACK Packet –> Client 3. Client –ACK Packet –> Server The above 3 steps are followed to establish a connection between source and destination. SYN Flood DOS attacks involves sending too many SYN packets (with a bad or random source ip) to the destination server. These SYN requests get [...]
2
2009
Get Country City from IP address in PHP
IPInfoDB provides a simple API to get the location of a visitor from his IP address. You need to first register and get an API Key. Then this code can be used : Code: IPinfodb supports json and xml formats for data output. The above code can be seen in action at ipmango.com. Another website GeoIO provides a similar API. You need to first register and get your code. Then you can code like this [...]
1
2009
Parse and Format Dates in PHP
Mysql Database stores dates in the format yyyy-mm-dd : e.g. 2009-04-15 Whereas humans are more used to the formats like dd-mm-yyyy or mm-dd-yyyy e.g. 21-04-2009 And while reading a format like : dd-Month-yyyy is more usable e.g. 21-Mar-2009 Check if a date is valid : If the date is in format dd-mm-yyyy then a simple way to test its validity would be : But the above has an issue that it will report 31-02-2009 as [...]
Subscribe
Recent Posts
- Login into phpmyadmin without username and password
- 10+ tips to localise your php application
- 40+ Techniques to enhance your php code – Part 3
- 40+ Techniques to enhance your php code – Part 2
- 40+ Techniques to enhance your php code – Part 1
- CSSDeck – Collection of Pure CSS Creations
- Execute shell commands in PHP
- Php get list of locales installed on system
- Sound cracking in Ubuntu 11.10
- PHP script to perform IP whois
An article by