Wishing you all a Happy & Prosperous New Year 2011...
PHP Tutorial, PHP Help, Javascript Tutorial, Javascript Help, MySQL Tutorial, MySQL Help,Personal Wishes, Images,Download Tutorials,MySQL Downloads,Download Softwares.
Thursday, December 30, 2010
Tuesday, December 7, 2010
Display Errors and Log errors in PHP
HTACCESS code to display errors(i.e Warnings & Fatal Errors) while running a PHP file in server is shown below.
php_flag display_errors off
HTACCESS code to log errors in Log file is php_flag log_errors. To off the Log files in the server we need to write the HTACCESS code as shown below.
php_flag log_errors off
To off the Errors displayed & also to OFF the log files the following HTACCESS code is used.
Options +FollowSymlinks
php_flag display_errors off
php_flag log_errors off
php_flag display_errors off
HTACCESS code to log errors in Log file is php_flag log_errors. To off the Log files in the server we need to write the HTACCESS code as shown below.
php_flag log_errors off
To off the Errors displayed & also to OFF the log files the following HTACCESS code is used.
Options +FollowSymlinks
php_flag display_errors off
php_flag log_errors off
Saturday, October 16, 2010
Sending Mails with Attachment in PHP
Here is the code for sending for mails with Attachments in PHP.
$email_from = "Anil Kumar"; // Who the email is from
$email_subject = "Email with Attachment"; // The Subject of the email
$email_message = "Is the File Attached."; // Message that the email has in it
$email_to = "anilbuddha@gmail.com"; // Who the email is too
$headers = "From: ".$email_from;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";
/********************************************** First File ********************************************/
$fileatt = "../reports/users.pdf"; // Path to the file
$fileatt_type = "application/pdf"; // File Type
$fileatt_name = "users"; // Filename that will be used for the file as the attachment
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}\n";
unset($data);
unset($file);
unset($fileatt);
unset($fileatt_type);
unset($fileatt_name);
$ok = mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
echo "Email With Attachment has been Sent Successfully";
} else {
echo "Sending Email with Attachment has Failed. Please check the Code Added";
}
$email_from = "Anil Kumar"; // Who the email is from
$email_subject = "Email with Attachment"; // The Subject of the email
$email_message = "Is the File Attached."; // Message that the email has in it
$email_to = "anilbuddha@gmail.com"; // Who the email is too
$headers = "From: ".$email_from;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$email_message . "\n\n";
/********************************************** First File ********************************************/
$fileatt = "../reports/users.pdf"; // Path to the file
$fileatt_type = "application/pdf"; // File Type
$fileatt_name = "users"; // Filename that will be used for the file as the attachment
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}\n";
unset($data);
unset($file);
unset($fileatt);
unset($fileatt_type);
unset($fileatt_name);
$ok = mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
echo "Email With Attachment has been Sent Successfully";
} else {
echo "Sending Email with Attachment has Failed. Please check the Code Added";
}
Friday, October 15, 2010
Upload Large Files with PHP
When we want to upload large files in PHP we would be changing the file max size limit in PHP ini file.
This can be done in our local system but when we need this is in Server where our Project is maintained it is not possible. So here is the Rewrite Rule in HTACCESS for PHP where we can change the maximum file size limit.
Rewrite Rule for Maximum File size is shown below.
This can be done in our local system but when we need this is in Server where our Project is maintained it is not possible. So here is the Rewrite Rule in HTACCESS for PHP where we can change the maximum file size limit.
Rewrite Rule for Maximum File size is shown below.
php_value upload_max_filesize 20M
HTACCESS code to run PHP in HTML file
Using HTACCESS we can run the PHP code in an HTML file.
The REWRITE rule to write in HTACCESS file is shown below.
AddType application/x-httpd-php .html .htm
The REWRITE rule to write in HTACCESS file is shown below.
AddType application/x-httpd-php .html .htm
Monday, September 27, 2010
Date Validation using Javascript
Here is the validation for date using javascript.
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31;
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
if (i==2){this[i] = 29;}
}
return this;
}
function isDate(dtStr){
var daysInMonth = DaysArray(12);
var pos1=dtStr.indexOf(dtCh);
var pos2=dtStr.indexOf(dtCh,pos1+1);
var strMonth=dtStr.substring(0,pos1);
var strDay=dtStr.substring(pos1+1,pos2);
var strYear=dtStr.substring(pos2+1);
strYr=strYear;
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
}
month=parseInt(strMonth);
day=parseInt(strDay);
year=parseInt(strYr);
if (pos1==-1 || pos2==-1){
alert("The date format should be : mm/dd/yyyy");
return false;
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month");
document.form1.month.focus();
return false;
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day");
document.form1.day.focus();
return false;
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
return false;
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date");
return false;
}
return true;
}
To check the given string is a Date or not, the date format should be checked as shown below.
var dt = document.form1.month.value +'/' +document.form1.day.value +'/'+ document.form1.year.value;
if (isDate(dt)==false){
return false;
}
The date format to be passed is MM/DD/YYYY.
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31;
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
if (i==2){this[i] = 29;}
}
return this;
}
function isDate(dtStr){
var daysInMonth = DaysArray(12);
var pos1=dtStr.indexOf(dtCh);
var pos2=dtStr.indexOf(dtCh,pos1+1);
var strMonth=dtStr.substring(0,pos1);
var strDay=dtStr.substring(pos1+1,pos2);
var strYear=dtStr.substring(pos2+1);
strYr=strYear;
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1);
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1);
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1);
}
month=parseInt(strMonth);
day=parseInt(strDay);
year=parseInt(strYr);
if (pos1==-1 || pos2==-1){
alert("The date format should be : mm/dd/yyyy");
return false;
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month");
document.form1.month.focus();
return false;
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day");
document.form1.day.focus();
return false;
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear);
return false;
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date");
return false;
}
return true;
}
To check the given string is a Date or not, the date format should be checked as shown below.
var dt = document.form1.month.value +'/' +document.form1.day.value +'/'+ document.form1.year.value;
if (isDate(dt)==false){
return false;
}
The date format to be passed is MM/DD/YYYY.
Sunday, September 26, 2010
Rewrite condition for domain.com to www.domain.com using HTACCESS
Redirecting from domain.com to www.domain.com is mostly helpful as part of SEO. The rule for rewriting the site is shown below.
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Just change the domain name to your site name to use the rewrite rule.
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Just change the domain name to your site name to use the rewrite rule.
Sunday, September 5, 2010
Maryada Ramana MP3 Ringtone
The latest mp3 background music from Maryada Ramana. Download it
Click Here to Download the ringtone.
Click Here to Download the ringtone.
Friday, September 3, 2010
Get the Meta Content using Javascript
Here is the code for retrieving the Meta Keywords, Description using Javascript.
var destination = window.location.href;
var meta_title = '',meta_description = '';
var meta = document.getElementsByTagName("meta");
for( var x in meta )
{
if(/^title$/i.test(meta[x]["name"]))
meta_title = meta[x]["content"];
if(/^description$/i.test(meta[x]["name"]))
meta_description = meta[x]["content"];
}
var destination = window.location.href;
var meta_title = '',meta_description = '';
var meta = document.getElementsByTagName("meta");
for( var x in meta )
{
if(/^title$/i.test(meta[x]["name"]))
meta_title = meta[x]["content"];
if(/^description$/i.test(meta[x]["name"]))
meta_description = meta[x]["content"];
}
Wednesday, September 1, 2010
PHP Interview Questions and Answers
Here are some of the PHP interview Questions with answers which may help you.
1. What are the differences between GET and POST methods in form submitting, give the case where we can use get and we can use post methods?
Answer: On the server side, the main difference between GET and POST is where the submitted is stored. The $_GET array stores data submitted by the GET method. The $_POST array stores data submitted by the POST method.
On the browser side, the difference is that data submitted by the GET method will be displayed in the browser's address field. Data submitted by the POST method will not be displayed anywhere on the browser.
GET method is mostly used for submitting a small amount and less sensitive data. POST method is mostly used for submitting a large amount or sensitive data.
2. Who is the father of php and explain the changes in php versions?
Answer: Rasmus Lerdorf for version changes go to http://php.net/
Marco Tabini is the founder and publisher of php|architect.
3. How can we submit from without a submit button?
Answer: We can use a simple JavaScript code linked to an event trigger of any form field.
In the JavaScript code, we can call the document.form.submit() function to submit the form.
4. How many ways we can retrieve the date in result set of mysql Using php?
Answer: As individual objects so single record or as a set or arrays.
5. What is the difference between mysql_fetch_object and mysql_fetch_array?
Answer: MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array.
6. What is the difference between $message and $$message?
Answer: They are both variables. But $message is a variable with a fixed name. $$message is a variable who's name is stored in $message. For example, if $message contains "var", $$message is the same as $var.
7. How can we extract string 'abc.com ' from a string 'http://info@a...' using regular _expression of php?
Answer: We can use the preg_match() function with "/.*@(.*)$/" as
the regular expression pattern. For example:
preg_match("/.*@(.*)$/","http://info@abc.com",$data);
echo $data[1];
8. How can we create a database using php and mysql?
Answer: PHP: mysql_create_db()
Mysql: create database;
9. What are the differences between require and include, include_once?
Answer: File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
10. Can we use include ("abc.php") two times in a php page "makeit.php"?
Answer: Yes we can include..
11. What are the different tables present in mysql, which type of table is generated when we are creating a table in the following
syntax: create table employee(eno int(2),ename varchar(10)) ?
Answer: Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. InnoDB
5. ISAM
6. BDB
MyISAM is the default storage engine as of MySQL 3.23.
12. Functions in IMAP, POP3 AND LDAP?
Answer: Please visit:
http://fi2.php.net/imap
http://uk2.php.net/ldap
13. How can I execute a php script using command line?
Answer: Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program. Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.
14. Suppose your ZEND engine supports the mode <? ?> Then how can u configure your php ZEND engine to support <?php ?> mode ?
Answer: If you change the line: short_open_tag = off in php.ini file. Then your php ZEND engine support only <?php ?> mode.
15. Shopping cart online validation i.e. how can we configure the paypals?
16. What is meant by nl2br()?
Answer: nl2br -- Inserts HTML line breaks before all newlines in a string
string nl2br (string); Returns string with '<br />' inserted before all newlines.
For example: echo nl2br("god bless\n you") will output "god bless
\n you" to your browser.
For Free Download,Click Here
1. What are the differences between GET and POST methods in form submitting, give the case where we can use get and we can use post methods?
Answer: On the server side, the main difference between GET and POST is where the submitted is stored. The $_GET array stores data submitted by the GET method. The $_POST array stores data submitted by the POST method.
On the browser side, the difference is that data submitted by the GET method will be displayed in the browser's address field. Data submitted by the POST method will not be displayed anywhere on the browser.
GET method is mostly used for submitting a small amount and less sensitive data. POST method is mostly used for submitting a large amount or sensitive data.
2. Who is the father of php and explain the changes in php versions?
Answer: Rasmus Lerdorf for version changes go to http://php.net/
Marco Tabini is the founder and publisher of php|architect.
3. How can we submit from without a submit button?
Answer: We can use a simple JavaScript code linked to an event trigger of any form field.
In the JavaScript code, we can call the document.form.submit() function to submit the form.
4. How many ways we can retrieve the date in result set of mysql Using php?
Answer: As individual objects so single record or as a set or arrays.
5. What is the difference between mysql_fetch_object and mysql_fetch_array?
Answer: MySQL fetch object will collect first single matching record where mysql_fetch_array will collect all matching records from the table in an array.
6. What is the difference between $message and $$message?
Answer: They are both variables. But $message is a variable with a fixed name. $$message is a variable who's name is stored in $message. For example, if $message contains "var", $$message is the same as $var.
7. How can we extract string 'abc.com ' from a string 'http://info@a...' using regular _expression of php?
Answer: We can use the preg_match() function with "/.*@(.*)$/" as
the regular expression pattern. For example:
preg_match("/.*@(.*)$/","http://info@abc.com",$data);
echo $data[1];
8. How can we create a database using php and mysql?
Answer: PHP: mysql_create_db()
Mysql: create database;
9. What are the differences between require and include, include_once?
Answer: File will not be included more than once. If we want to include a file once only and further calling of the file will be ignored then we have to use the PHP function include_once(). This will prevent problems with function redefinitions, variable value reassignments, etc.
10. Can we use include ("abc.php") two times in a php page "makeit.php"?
Answer: Yes we can include..
11. What are the different tables present in mysql, which type of table is generated when we are creating a table in the following
syntax: create table employee(eno int(2),ename varchar(10)) ?
Answer: Total 5 types of tables we can create
1. MyISAM
2. Heap
3. Merge
4. InnoDB
5. ISAM
6. BDB
MyISAM is the default storage engine as of MySQL 3.23.
12. Functions in IMAP, POP3 AND LDAP?
Answer: Please visit:
http://fi2.php.net/imap
http://uk2.php.net/ldap
13. How can I execute a php script using command line?
Answer: Just run the PHP CLI (Command Line Interface) program and provide the PHP script file name as the command line argument. For example, "php myScript.php", assuming "php" is the command to invoke the CLI program. Be aware that if your PHP script was written for the Web CGI interface, it may not execute properly in command line environment.
14. Suppose your ZEND engine supports the mode <? ?> Then how can u configure your php ZEND engine to support <?php ?> mode ?
Answer: If you change the line: short_open_tag = off in php.ini file. Then your php ZEND engine support only <?php ?> mode.
15. Shopping cart online validation i.e. how can we configure the paypals?
16. What is meant by nl2br()?
Answer: nl2br -- Inserts HTML line breaks before all newlines in a string
string nl2br (string); Returns string with '<br />' inserted before all newlines.
For example: echo nl2br("god bless\n you") will output "god bless
\n you" to your browser.
More Interview Questions, Download the document, Click Here for PHP interview Question
Tuesday, August 31, 2010
80's South Indian Film Stars
Hi Friends,
Here is the pic taken of the 80's South Indian Film Stars when they united in a special get together event held on Aug 29 (i.e. Sunday) night in Chennai. The event organised by Suhasini Maniratnam and hosted by Lissy Priyadarshan.
All together the event was attended by around 29 actors and was called as Evergreen 80s. From the Telugu industry, Chiranjeevi, Venkatesh, Bhanuchandar, Naresh, Suresh, Ramya krishna and Suman were present. From the Tamil industry, the actors attended the event were superstar Rajnikanth, Sharat Kumar, Arjun, Mohan, Karthik, Prabhu, Suhasini, Radhika, Poornima, Radha, Kushbu, Ambika and Nadiya. From the Malayalam, Mohan Lal and Shobhan were present while from Kannada industry, Sumalatha and Ambarish attended the event.
This is nice to see all the south Indian film stars in a single pic.
Download the pic, here is the link for download, Click here
Here is the pic taken of the 80's South Indian Film Stars when they united in a special get together event held on Aug 29 (i.e. Sunday) night in Chennai. The event organised by Suhasini Maniratnam and hosted by Lissy Priyadarshan.
All together the event was attended by around 29 actors and was called as Evergreen 80s. From the Telugu industry, Chiranjeevi, Venkatesh, Bhanuchandar, Naresh, Suresh, Ramya krishna and Suman were present. From the Tamil industry, the actors attended the event were superstar Rajnikanth, Sharat Kumar, Arjun, Mohan, Karthik, Prabhu, Suhasini, Radhika, Poornima, Radha, Kushbu, Ambika and Nadiya. From the Malayalam, Mohan Lal and Shobhan were present while from Kannada industry, Sumalatha and Ambarish attended the event.
This is nice to see all the south Indian film stars in a single pic.
Download the pic, here is the link for download, Click here
Saturday, August 28, 2010
Joomla - Most popular open source
Joomla, is the most popular open source software in PHP. It is free for publishing. It uses PHP for coding & MySQL for storage i.e. Database.
Want to learn Joomla, & publish the Site. Here is the free tutorial. Download Joomla Tutorial & have a fun learning.
For download, Click Here
Want to learn Joomla, & publish the Site. Here is the free tutorial. Download Joomla Tutorial & have a fun learning.
For download, Click Here
Sunday, August 22, 2010
HTACCESS code to redirect to 404 page
htaccess in Linux server is used for rewriting the URL & also used for redirecting to a Pre-defined error page(404 error page) when there is no file or page in the site.
Here is the rule for redirecting to Error page(404 page -- i.e. Page Not found)
Ex;- ErrorDocument 404 http://www.yoursitename.com/error404.php
Ex:- ErrorDocument 404 http://www.yoursitename.com/error404.html
we can define any filename for redirecting, in the above example, I've given an error404.php or error404.html as examples
Here is the rule for redirecting to Error page(404 page -- i.e. Page Not found)
Ex;- ErrorDocument 404 http://www.yoursitename.com/error404.php
Ex:- ErrorDocument 404 http://www.yoursitename.com/error404.html
we can define any filename for redirecting, in the above example, I've given an error404.php or error404.html as examples
Friday, August 20, 2010
Function for taking MySQL Backup in PHP
Here is the function for taking backup of a MySQL database without any external tool for MySQL.
$host ---> Hostname
$user ----> Username
$pass ----> Password
$name ----> Database name
If we need the total database, just put the value of $tables as * or else pass only the tables you want with comma separated.
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host,$user,$pass);
mysql_select_db($name,$link);
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);
//$return.= 'DROP TABLE '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
$s_file = 'db-backup-'.time().'-'.'.sql';
//save file
$handle = fopen($s_file,'w+');
fwrite($handle,$return);
fclose($handle);
header("Location:".$s_file);
exit;
}
$host ---> Hostname
$user ----> Username
$pass ----> Password
$name ----> Database name
If we need the total database, just put the value of $tables as * or else pass only the tables you want with comma separated.
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host,$user,$pass);
mysql_select_db($name,$link);
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);
//$return.= 'DROP TABLE '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
$s_file = 'db-backup-'.time().'-'.'.sql';
//save file
$handle = fopen($s_file,'w+');
fwrite($handle,$return);
fclose($handle);
header("Location:".$s_file);
exit;
}
Monday, August 16, 2010
Download PHP Manual
PHP is the powerful server side scripting language, popularly known as Hypertext Preprocessor.
PHP is also called as Personal Home Page.
Download the PHP Manual here. For Free Download, Click Here
PHP is also called as Personal Home Page.
Download the PHP Manual here. For Free Download, Click Here
Friday, August 13, 2010
Download MySQL Tutorial
Here is PDF document for MySQL Tutorial...
MySQL is the world's most popular open source database because of its fast performance, high reliability, ease of use, and dramatic cost savings. Want to learn MySQL, download the pdf document & enhance your database skills..
Free Download, Click Here
MySQL is the world's most popular open source database because of its fast performance, high reliability, ease of use, and dramatic cost savings. Want to learn MySQL, download the pdf document & enhance your database skills..
Free Download, Click Here
Monday, August 9, 2010
Post your Status in Twitter using PHP
t$twitter_api_url = "http://twitter.com/statuses/update.xml";
$twitter_data = "status=Visit http://anilkajadoo.blogspot.com/ for PHP tips and tutorials!";
$twitter_user = "your_user_name";
$twitter_password = "your_password";
The $twitter_data variable contains the message to be posted to Twitter, which you must ensure is 140 characters or less before posting. You could use strlen() function to do so when you ready the data to be sent, and truncate it if it’s too long by using substr() function. The status= before the message is the POST variable, the parameter for the API.
To send the request, we will use cURL, which is included on most servers. First we initiate cURL and pass it the URL we will be sending the request to:
$ch = curl_init($twitter_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $twitter_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "{$twitter_user}:{$twitter_password}");//Twitter Username & Password are used to post the status
$twitter_data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
All that’s left really is to see whether it worked or not. Since we have our handy $httpcode variable, we can just run a conditional statement to see if the response code is equal to 200 (which means everything went okay).
if ($httpcode != 200) {
echo "The tweet wasn't posted correctly. ";
}
$twitter_data = "status=Visit http://anilkajadoo.blogspot.com/ for PHP tips and tutorials!";
$twitter_user = "your_user_name";
$twitter_password = "your_password";
The $twitter_data variable contains the message to be posted to Twitter, which you must ensure is 140 characters or less before posting. You could use strlen() function to do so when you ready the data to be sent, and truncate it if it’s too long by using substr() function. The status= before the message is the POST variable, the parameter for the API.
To send the request, we will use cURL, which is included on most servers. First we initiate cURL and pass it the URL we will be sending the request to:
$ch = curl_init($twitter_api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $twitter_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "{$twitter_user}:{$twitter_password}");//Twitter Username & Password are used to post the status
$twitter_data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
All that’s left really is to see whether it worked or not. Since we have our handy $httpcode variable, we can just run a conditional statement to see if the response code is equal to 200 (which means everything went okay).
if ($httpcode != 200) {
echo "The tweet wasn't posted correctly. ";
}
Create a Tiny URL using PHP
Function to create a tiny URL for the site using PHP....
function get_tiny_url($url){
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
//Test the Function.......
$new_url = get_tiny_url('http://anilkajadoo.blogspot.com/');
//The tinyURL has been generated & just print it below
echo $new_url;
function get_tiny_url($url){
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
//Test the Function.......
$new_url = get_tiny_url('http://anilkajadoo.blogspot.com/');
//The tinyURL has been generated & just print it below
echo $new_url;
Tuesday, August 3, 2010
Monday, August 2, 2010
Get the Page title of a webpage using PHP
Below is the function for getting the Title of the webpage using PHP
function getMetaTitle($content){
$pattern = "|<[\s]*title[\s]*>([^<]+)<[\s]*/[\s]*title[\s]*>|Ui";
if(preg_match($pattern, $content, $match))
return $match[1];
else
return false;
}
$url = $siteurl; //Enter the Site URL which we want to get the Page Title
$content = file_get_contents($url);
$title = getMetaTitle($content);
$tags = get_meta_tags($siteurl); // To get the meta content, description, keywords of the given URL....
$tags is a array of all meta data
To get the Meta Keywords, Description we will use the get_meta_tags which is a predefined function in PHP. To retrieve the values we need to use $tags['keywords'] for Keywords & for Description $tag['description']
function getMetaTitle($content){
$pattern = "|<[\s]*title[\s]*>([^<]+)<[\s]*/[\s]*title[\s]*>|Ui";
if(preg_match($pattern, $content, $match))
return $match[1];
else
return false;
}
$url = $siteurl; //Enter the Site URL which we want to get the Page Title
$content = file_get_contents($url);
$title = getMetaTitle($content);
$tags = get_meta_tags($siteurl); // To get the meta content, description, keywords of the given URL....
$tags is a array of all meta data
To get the Meta Keywords, Description we will use the get_meta_tags which is a predefined function in PHP. To retrieve the values we need to use $tags['keywords'] for Keywords & for Description $tag['description']
Saturday, July 31, 2010
Check Domain availability Using PHP
How to Check Domain Availability using PHP
<?php
function checkDomainAvailability($domain_name){
$server = 'whois.crsnic.net';
// Open a socket connection to the whois server
$connection = fsockopen($server, 43);
if (!$connection) return false;
// Send the requested doman name
fputs($connection, $domain_name."\r\n");
// Read and store the server response
$response_text = ' :';
while(!feof($connection)) {
$response_text .= fgets($connection,128);
}
// Close the connection
fclose($connection);
// Check the response stream whether the domain is available
if (strpos($response_text, 'No match for')) return true;
else return false;
}
$domainname = 'anilbuddha.com';
if(checkDomainAvailability($domainname)) echo 'Domain : '.$domainname.' is Available';
else echo 'Domain : '.$domainname.' is Already Taken';
?>
<?php
function checkDomainAvailability($domain_name){
$server = 'whois.crsnic.net';
// Open a socket connection to the whois server
$connection = fsockopen($server, 43);
if (!$connection) return false;
// Send the requested doman name
fputs($connection, $domain_name."\r\n");
// Read and store the server response
$response_text = ' :';
while(!feof($connection)) {
$response_text .= fgets($connection,128);
}
// Close the connection
fclose($connection);
// Check the response stream whether the domain is available
if (strpos($response_text, 'No match for')) return true;
else return false;
}
$domainname = 'anilbuddha.com';
if(checkDomainAvailability($domainname)) echo 'Domain : '.$domainname.' is Available';
else echo 'Domain : '.$domainname.' is Already Taken';
?>
Wishing all my Friends a Happy Friendship Day
Friendship is not about finding similarities, it is about respecting differences. You are not my friend coz you are like me, but because i accept you and respect you the way you are.
Wishing All my Friends a Happy Friendship Day......
Tuesday, July 27, 2010
Download DonSeenu Songs
Download the latest Songs of Don Seenu
Starring Ravi teja, Shreya saran.
For Download, Click Here
Source: southmp3.net
Starring Ravi teja, Shreya saran.
For Download, Click Here
Source: southmp3.net
Gmail Type Chat using PHP & Jquery
Need Gmail type chat using PHP & Jquery....
Here is the applicaion, download the file here.
For file download, click here
Here is the applicaion, download the file here.
For file download, click here
Saturday, July 24, 2010
Resize Image using PHP
Problem to resize a big image while uploading using PHP, here is the code for resizing the image using a simple class. To download the file, Click here
The Class For resizing an image is shown below.
Class resize
{
// *** Class variables
private $image;
private $width;
private $height;
private $imageResized;
function __construct($fileName)
{
// *** Open up the file
$this->image = $this->openImage($fileName);
// *** Get width and height
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
}
## --------------------------------------------------------
private function openImage($file)
{
// *** Get extension
$extension = strtolower(strrchr($file, '.'));
switch($extension)
{
case '.jpg':
case '.jpeg':
$img = @imagecreatefromjpeg($file);
break;
case '.gif':
$img = @imagecreatefromgif($file);
break;
case '.png':
$img = @imagecreatefrompng($file);
break;
default:
$img = false;
break;
}
return $img;
}
## --------------------------------------------------------
public function resizeImage($newWidth, $newHeight, $option="auto")
{
// *** Get optimal width and height - based on $option
$optionArray = $this->getDimensions($newWidth, $newHeight, $option);
$optimalWidth = $optionArray['optimalWidth'];
$optimalHeight = $optionArray['optimalHeight'];
// *** Resample - create image canvas of x, y size
$this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);
// *** if option is 'crop', then crop too
if ($option == 'crop') {
$this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight);
}
}
## --------------------------------------------------------
private function getDimensions($newWidth, $newHeight, $option)
{
switch ($option)
{
case 'exact':
$optimalWidth = $newWidth;
$optimalHeight= $newHeight;
break;
case 'portrait':
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
$optimalHeight= $newHeight;
break;
case 'landscape':
$optimalWidth = $newWidth;
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
break;
case 'auto':
$optionArray = $this->getSizeByAuto($newWidth, $newHeight);
$optimalWidth = $optionArray['optimalWidth'];
$optimalHeight = $optionArray['optimalHeight'];
break;
case 'crop':
$optionArray = $this->getOptimalCrop($newWidth, $newHeight);
$optimalWidth = $optionArray['optimalWidth'];
$optimalHeight = $optionArray['optimalHeight'];
break;
}
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
}
## --------------------------------------------------------
private function getSizeByFixedHeight($newHeight)
{
$ratio = $this->width / $this->height;
$newWidth = $newHeight * $ratio;
return $newWidth;
}
private function getSizeByFixedWidth($newWidth)
{
$ratio = $this->height / $this->width;
$newHeight = $newWidth * $ratio;
return $newHeight;
}
private function getSizeByAuto($newWidth, $newHeight)
{
if ($this->height < $this->width)
// *** Image to be resized is wider (landscape)
{
$optimalWidth = $newWidth;
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
}
elseif ($this->height > $this->width)
// *** Image to be resized is taller (portrait)
{
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
$optimalHeight= $newHeight;
}
else
// *** Image to be resizerd is a square
{
if ($newHeight < $newWidth) {
$optimalWidth = $newWidth;
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
} else if ($newHeight > $newWidth) {
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
$optimalHeight= $newHeight;
} else {
// *** Sqaure being resized to a square
$optimalWidth = $newWidth;
$optimalHeight= $newHeight;
}
}
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
}
## --------------------------------------------------------
private function getOptimalCrop($newWidth, $newHeight)
{
$heightRatio = $this->height / $newHeight;
$widthRatio = $this->width / $newWidth;
if ($heightRatio < $widthRatio) {
$optimalRatio = $heightRatio;
} else {
$optimalRatio = $widthRatio;
}
$optimalHeight = $this->height / $optimalRatio;
$optimalWidth = $this->width / $optimalRatio;
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
}
## --------------------------------------------------------
private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight)
{
// *** Find center - this will be used for the crop
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
$crop = $this->imageResized;
//imagedestroy($this->imageResized);
// *** Now crop from center to exact requested size
$this->imageResized = imagecreatetruecolor($newWidth , $newHeight);
imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight);
}
## --------------------------------------------------------
public function saveImage($savePath, $imageQuality="100")
{
// *** Get extension
$extension = strrchr($savePath, '.');
$extension = strtolower($extension);
switch($extension)
{
case '.jpg':
case '.jpeg':
if (imagetypes() & IMG_JPG) {
imagejpeg($this->imageResized, $savePath, $imageQuality);
}
break;
case '.gif':
if (imagetypes() & IMG_GIF) {
imagegif($this->imageResized, $savePath);
}
break;
case '.png':
// *** Scale quality from 0-100 to 0-9
$scaleQuality = round(($imageQuality/100) * 9);
// *** Invert quality setting as 0 is best, not 9
$invertScaleQuality = 9 - $scaleQuality;
if (imagetypes() & IMG_PNG) {
imagepng($this->imageResized, $savePath, $invertScaleQuality);
}
break;
// ... etc
default:
// *** No extension - No save.
break;
}
imagedestroy($this->imageResized);
}
## --------------------------------------------------------
}
The Class For resizing an image is shown below.
Class resize
{
// *** Class variables
private $image;
private $width;
private $height;
private $imageResized;
function __construct($fileName)
{
// *** Open up the file
$this->image = $this->openImage($fileName);
// *** Get width and height
$this->width = imagesx($this->image);
$this->height = imagesy($this->image);
}
## --------------------------------------------------------
private function openImage($file)
{
// *** Get extension
$extension = strtolower(strrchr($file, '.'));
switch($extension)
{
case '.jpg':
case '.jpeg':
$img = @imagecreatefromjpeg($file);
break;
case '.gif':
$img = @imagecreatefromgif($file);
break;
case '.png':
$img = @imagecreatefrompng($file);
break;
default:
$img = false;
break;
}
return $img;
}
## --------------------------------------------------------
public function resizeImage($newWidth, $newHeight, $option="auto")
{
// *** Get optimal width and height - based on $option
$optionArray = $this->getDimensions($newWidth, $newHeight, $option);
$optimalWidth = $optionArray['optimalWidth'];
$optimalHeight = $optionArray['optimalHeight'];
// *** Resample - create image canvas of x, y size
$this->imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
imagecopyresampled($this->imageResized, $this->image, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $this->width, $this->height);
// *** if option is 'crop', then crop too
if ($option == 'crop') {
$this->crop($optimalWidth, $optimalHeight, $newWidth, $newHeight);
}
}
## --------------------------------------------------------
private function getDimensions($newWidth, $newHeight, $option)
{
switch ($option)
{
case 'exact':
$optimalWidth = $newWidth;
$optimalHeight= $newHeight;
break;
case 'portrait':
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
$optimalHeight= $newHeight;
break;
case 'landscape':
$optimalWidth = $newWidth;
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
break;
case 'auto':
$optionArray = $this->getSizeByAuto($newWidth, $newHeight);
$optimalWidth = $optionArray['optimalWidth'];
$optimalHeight = $optionArray['optimalHeight'];
break;
case 'crop':
$optionArray = $this->getOptimalCrop($newWidth, $newHeight);
$optimalWidth = $optionArray['optimalWidth'];
$optimalHeight = $optionArray['optimalHeight'];
break;
}
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
}
## --------------------------------------------------------
private function getSizeByFixedHeight($newHeight)
{
$ratio = $this->width / $this->height;
$newWidth = $newHeight * $ratio;
return $newWidth;
}
private function getSizeByFixedWidth($newWidth)
{
$ratio = $this->height / $this->width;
$newHeight = $newWidth * $ratio;
return $newHeight;
}
private function getSizeByAuto($newWidth, $newHeight)
{
if ($this->height < $this->width)
// *** Image to be resized is wider (landscape)
{
$optimalWidth = $newWidth;
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
}
elseif ($this->height > $this->width)
// *** Image to be resized is taller (portrait)
{
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
$optimalHeight= $newHeight;
}
else
// *** Image to be resizerd is a square
{
if ($newHeight < $newWidth) {
$optimalWidth = $newWidth;
$optimalHeight= $this->getSizeByFixedWidth($newWidth);
} else if ($newHeight > $newWidth) {
$optimalWidth = $this->getSizeByFixedHeight($newHeight);
$optimalHeight= $newHeight;
} else {
// *** Sqaure being resized to a square
$optimalWidth = $newWidth;
$optimalHeight= $newHeight;
}
}
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
}
## --------------------------------------------------------
private function getOptimalCrop($newWidth, $newHeight)
{
$heightRatio = $this->height / $newHeight;
$widthRatio = $this->width / $newWidth;
if ($heightRatio < $widthRatio) {
$optimalRatio = $heightRatio;
} else {
$optimalRatio = $widthRatio;
}
$optimalHeight = $this->height / $optimalRatio;
$optimalWidth = $this->width / $optimalRatio;
return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
}
## --------------------------------------------------------
private function crop($optimalWidth, $optimalHeight, $newWidth, $newHeight)
{
// *** Find center - this will be used for the crop
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
$crop = $this->imageResized;
//imagedestroy($this->imageResized);
// *** Now crop from center to exact requested size
$this->imageResized = imagecreatetruecolor($newWidth , $newHeight);
imagecopyresampled($this->imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newWidth, $newHeight , $newWidth, $newHeight);
}
## --------------------------------------------------------
public function saveImage($savePath, $imageQuality="100")
{
// *** Get extension
$extension = strrchr($savePath, '.');
$extension = strtolower($extension);
switch($extension)
{
case '.jpg':
case '.jpeg':
if (imagetypes() & IMG_JPG) {
imagejpeg($this->imageResized, $savePath, $imageQuality);
}
break;
case '.gif':
if (imagetypes() & IMG_GIF) {
imagegif($this->imageResized, $savePath);
}
break;
case '.png':
// *** Scale quality from 0-100 to 0-9
$scaleQuality = round(($imageQuality/100) * 9);
// *** Invert quality setting as 0 is best, not 9
$invertScaleQuality = 9 - $scaleQuality;
if (imagetypes() & IMG_PNG) {
imagepng($this->imageResized, $savePath, $invertScaleQuality);
}
break;
// ... etc
default:
// *** No extension - No save.
break;
}
imagedestroy($this->imageResized);
}
## --------------------------------------------------------
}
Paypal Integration
How to Integrate with Paypal for our application is shown below.
<form method='post' action='https://www.paypal.com/cgi-bin/webscr' id="test">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="businessaccount@mail.com" />
<input type="hidden" name="cbt" value="* * * Return to Bearmanor Media Bizland * * *">
<input type="hidden" name="item_name" value="{ item_name }" /><!--change the { item name } give the item name which you want to show on paypal -->
<input type="hidden" name="amount" value="{total_amount_}" /><!--change the {total_amount_} give the total amount which you want to show on paypal -->
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="{return url}" /><!--change the {return url} give the url to which it should redirect after completing the payment -->
<input type="hidden" name="cpp_header_image" value="{bannerimage}" /><!--change the {bannerimage} give the url of banner if you have otherwise change it to empty such as value="" -->
<input type="hidden" name="notify_url" value="">
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="custom" value="{order_id}" />
<input type="hidden" name="cancel_return" value="{Cancel page(Ex:-http://www.mysite.com/CancelPayment.php}" />
<input type="image" id='submit' src="paynow.jpg" border="0" alt="Make payments with PayPal - it's fast, free and secure!" />
</form>
<form method='post' action='https://www.paypal.com/cgi-bin/webscr' id="test">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="businessaccount@mail.com" />
<input type="hidden" name="cbt" value="* * * Return to Bearmanor Media Bizland * * *">
<input type="hidden" name="item_name" value="{ item_name }" /><!--change the { item name } give the item name which you want to show on paypal -->
<input type="hidden" name="amount" value="{total_amount_}" /><!--change the {total_amount_} give the total amount which you want to show on paypal -->
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="rm" value="2">
<input type="hidden" name="return" value="{return url}" /><!--change the {return url} give the url to which it should redirect after completing the payment -->
<input type="hidden" name="cpp_header_image" value="{bannerimage}" /><!--change the {bannerimage} give the url of banner if you have otherwise change it to empty such as value="" -->
<input type="hidden" name="notify_url" value="">
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="custom" value="{order_id}" />
<input type="hidden" name="cancel_return" value="{Cancel page(Ex:-http://www.mysite.com/CancelPayment.php}" />
<input type="image" id='submit' src="paynow.jpg" border="0" alt="Make payments with PayPal - it's fast, free and secure!" />
</form>
Tuesday, July 20, 2010
Showing Current Date & Time using Javascript
Insert the Below code anywhere into the body section where you need to see the Current date & time
<script>
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}
</script>
<span id="clock"></span>
& in the Body tag, we need to add an onLoad Function as shown below.
<body onload="goforit()">
For more Scripts...visit dynamicdrive
<script>
var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}
</script>
<span id="clock"></span>
& in the Body tag, we need to add an onLoad Function as shown below.
<body onload="goforit()">
For more Scripts...visit dynamicdrive
Sunday, July 18, 2010
Loading Image Before the Page Loads using Javascript
Below is the code used to show the Loading image before the page loads.
To implement this you will need to:
1. Every time your page loads a "init()" function will load.
<body onLoad="init()">
2. Define a div named "loading" right after <body> section.
<div id="loading" style="position:absolute; width:100%; text-align:center; top:300px;">
<img src="loading.gif" border=0></div>
The loading.gif image should be an animated gif that suggests that the page is still loading.
3. Place this javascript code right after you define the div.
<script>
var ld=(document.all);
var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
if (ns4)
ld=document.loading;
else if (ns6)
ld=document.getElementById("loading").style;
else if (ie4)
ld=document.all.loading.style;
function init()
{
if(ns4){ld.visibility="hidden";}
else if (ns6||ie4) ld.display="none";
}
</script>
& to See the Demo, Click Here
Subscribe to:
Posts (Atom)