$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
mysql_close($link);
Monday, June 30, 2008
Saturday, June 28, 2008
Bulk email sending using sleep function
$between_delay = 10;
$send_delay = 1;
for ( $sent=0; $row = mysql_fetch_array($result); $sent++ ) {
if ( ($sent % $between_delay) == 0 )
sleep( $send_delay );
$emailall = $row[0];
$message = stripslashes($message);
mail("$emailall", "$subject", "$message", "From: $email");
}
Friday, June 27, 2008
PHP Get and Post method Example
<form action="php manual.php" method="post">
Enter your name: <input name="name" type="text">
Enter your age: <input name="age" type="text">
<input type="submit">
</form>
<?php echo $_POST["name"]; ?>
<?php echo $_POST["age"]; ?>
<form action="php tutorial.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
<?php echo $_GET["name"]; ?>
<?php echo $_GET["age"]; ?>
Enter your name: <input name="name" type="text">
Enter your age: <input name="age" type="text">
<input type="submit">
</form>
<?php echo $_POST["name"]; ?>
<?php echo $_POST["age"]; ?>
<form action="php tutorial.php" method="get">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
<?php echo $_GET["name"]; ?>
<?php echo $_GET["age"]; ?>
Thursday, June 26, 2008
PHP String Functions Part II
$str = "My name is O\'Billa?";
echo stripslashes($str);// Outputs: My name is O'Billa?
$str = "My name is O'Billa?";
echo stripslashes($str);// Outputs: My name is O\'Billa?
$str = "Vijay's next film Villu";
$str = strtoupper($str);
echo $str; // Prints VIJAY'S NEXT FILM VILLU
$str = "AJITH'S NEXT FILM AEGAN";
$str = strtoupper($str);
echo $str; // Prints ajith's next film aegan
echo stripslashes($str);// Outputs: My name is O'Billa?
$str = "My name is O'Billa?";
echo stripslashes($str);// Outputs: My name is O\'Billa?
$str = "Vijay's next film Villu";
$str = strtoupper($str);
echo $str; // Prints VIJAY'S NEXT FILM VILLU
$str = "AJITH'S NEXT FILM AEGAN";
$str = strtoupper($str);
echo $str; // Prints ajith's next film aegan
Wednesday, June 25, 2008
PHP String Funcitons
$txt="PHP MYSQL";
echo $txt; // Returns PHP MYSQL (Print the text)
echo strlen("My first coding in PHP"); // Returns 22 (Print the string length)
echo strpos("Hello world","l"); // Returns 2 (Print the string position)
$email = 'ashokseenivas50@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com
$user = strstr($email, '@', true);
echo $user; // prints ashokseenivas50
echo $txt; // Returns PHP MYSQL (Print the text)
echo strlen("My first coding in PHP"); // Returns 22 (Print the string length)
echo strpos("Hello world","l"); // Returns 2 (Print the string position)
$email = 'ashokseenivas50@gmail.com';
$domain = strstr($email, '@');
echo $domain; // prints @gmail.com
$user = strstr($email, '@', true);
echo $user; // prints ashokseenivas50
Wednesday, June 18, 2008
PHP Array Functions
Array Merge
$array1 = array("fruits" => "apple", 2, 4);
$array2 = array("a", "b", "fruits" => "orange", "shape" => "rectangle", 4);
$result = array_merge($array1, $array2);
print_r($result);
Array Combine
$a = array('a', 'b', 'c');
$b = array('d', 'e', 'f');
$c = array_combine($a, $b);
print_r($c);
Array Push
$stack = array("a", "b");
array_push($stack, "c", "d");
print_r($stack);
Array Pop
$stack = array("a", "b", "c", "d");
$fruit = array_pop($stack);
print_r($stack);
$array1 = array("fruits" => "apple", 2, 4);
$array2 = array("a", "b", "fruits" => "orange", "shape" => "rectangle", 4);
$result = array_merge($array1, $array2);
print_r($result);
Array Combine
$a = array('a', 'b', 'c');
$b = array('d', 'e', 'f');
$c = array_combine($a, $b);
print_r($c);
Array Push
$stack = array("a", "b");
array_push($stack, "c", "d");
print_r($stack);
Array Pop
$stack = array("a", "b", "c", "d");
$fruit = array_pop($stack);
print_r($stack);
Thursday, June 12, 2008
.htaccess tutorial
1) Password Protected Directory
AuthUserFile /your/directory/here/.htpasswd
AuthGroupFile /dev/null
AuthName "Secure Document"
AuthType Basic
require user username
2) Password Protectection for a file
AuthName "Restricted File"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
3) Protecting the file types
AuthName "Restricted"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
4) Error Documents
ErrorDocument 400 /error/badrequest.htm
ErrorDocument 401 /error/authorisereqd.htm
ErrorDocument 403 /error/forbidden.htm
ErrorDocument 404 /error/filenotfound.htm
ErrorDocument 500 /error/servererror.htm
5) Redirecting Pages
Redirect /old-directory/oldpage.htm http://domain.com/new-directory/newpage.htm
Redirect /old-directory http://domain.com/new-directory/
6) Default page
DirectoryIndex default.htm
DirectoryIndex default.htm home.cgi sadass.pl otherfile.html
7) Add types and Add handler
AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm
8) Block Users by using IP
order deny,allow
deny from 123.456.789.000
deny from .domain.com
allow from all
AuthUserFile /your/directory/here/.htpasswd
AuthGroupFile /dev/null
AuthName "Secure Document"
AuthType Basic
2) Password Protectection for a file
AuthName "Restricted File"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
3) Protecting the file types
AuthName "Restricted"
AuthType Basic
AuthUserFile /user/home/www/directory/.htpasswd
require valid-user
4) Error Documents
ErrorDocument 401 /error/authorisereqd.htm
ErrorDocument 403 /error/forbidden.htm
ErrorDocument 404 /error/filenotfound.htm
ErrorDocument 500 /error/servererror.htm
5) Redirecting Pages
Redirect /old-directory/oldpage.htm http://domain.com/new-directory/newpage.htm
Redirect /old-directory http://domain.com/new-directory/
6) Default page
DirectoryIndex default.htm
DirectoryIndex default.htm home.cgi sadass.pl otherfile.html
7) Add types and Add handler
AddType text/html .html
AddHandler server-parsed .html
AddHandler server-parsed .htm
8) Block Users by using IP
order deny,allow
deny from 123.456.789.000
deny from .domain.com
allow from all
Monday, June 9, 2008
PHP Secure mail example
$to = 'ashokseenivas50@gmail.com' ;
$subject = 'PHP Technical Questions';
$message = '
Upload Your Resumes: PHP FAQ,
PHP interview questions,
PHP Frequently Asked Questions,
Earn More money from google,
Cricket Updates,
Cinema gossips,
Dating.
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary, Kelly ' . "\r\n";
$headers .= 'From: Blog Creation' . "\r\n";
$headers .= 'Cc: seenivasagaperumal@yahoo.com' . "\r\n";
$headers .= 'Bcc: seenivasagaperumal@yahoo.com' . "\r\n";
mail($to, $subject, $message, $headers);
$subject = 'PHP Technical Questions';
$message = '
Upload Your Resumes: PHP FAQ,
PHP interview questions,
PHP Frequently Asked Questions,
Earn More money from google,
Cricket Updates,
Cinema gossips,
Dating.
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Mary
$headers .= 'From: Blog Creation
$headers .= 'Cc: seenivasagaperumal@yahoo.com' . "\r\n";
$headers .= 'Bcc: seenivasagaperumal@yahoo.com' . "\r\n";
mail($to, $subject, $message, $headers);
Subscribe to:
Posts (Atom)