Secure file download in PHP, Security question PHP, PHP MYSQL Interview Question -Books download - PHP solutions guidelines queries update, phpmysqlquestion
Wednesday, November 26, 2008
PHP Code for sending email in HTML view
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";
// wordwrap mail message.
$message=wordwrap($message,70);
mail($to,$subject,$message,$headers);
?>
Show inside directory file and sub directory with PHP code
$dir = opendir("images");
//List files in images directory
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "
";
}
//Resets the directory stream
rewinddir($dir);
//Code to check for changes
closedir($dir);
?>
Code for copy one file to another file with same directory in php
- php
- $text = file_get_contents('client.html');
- $paste = file_put_contents('client2.html',$text);
- if($paste)
- {
- echo "File copied correctly\n";
- } else {
- echo "There was a problem copying the file\n";
- }
- ?>
Wednesday, November 12, 2008
Question: What is the difference between the functions unlink and unset?
Answer:
unlink will delete a file and unset would remove a value from a session variable.
Question: What is meant by urlencode and urldecode?
Question: What is meant by urlencode and urldecode?
Answer:
string urlencode(str) where str contains a string for example “hello world” and the return value will be URL encoded and can be use to append with URLs‚ normaly used to appned data for GET like someurl.com?var=hello%world string urldocode(str) this will simply decode the GET variable’s value for example
echo (urldecode($_GET_VARS[var])) will output “Hello world”
Question: What is the functionality of the function strstr and stristr?
Answer:
string strstr (string str1‚ string str2) this function search the string str1 for the first occurrence of the string str2 and returns the part of the string str1 from the first occurrence of the string str2. This function is case-sensitive and for case-insensitive search use stristr() function.
Example of strstr: $email = ’name@example.com’;
$domain = strstr($email‚ ’@’); echo $domain; // prints @example.com $user = strstr($email‚ ’@’‚ true); echo $user; // prints name ?>
Example of stristr: $email = ’USER@EXAMPLE.com’; echo stristr($email‚ ’e’); // outputs ER@EXAMPLE.com echo stristr($email‚ ’e’‚ true); // outputs US ?>
Question: What are the different types of errors in PHP?
Question: What are the different types of errors in PHP?
Answer:
Three are three types of errors:
1) Fatal errors.
2) Parser errors.
3) Startup errors.
How to solve mysql ERROR 1118 (42000) Row size too large
I had this issue with MYSQL 5.7 . The following worked althoug...
-
Introduction to PHP PDO (PHP Data Objects) 1. What is PDO 2. What Databases does PDO support 3. Where do I begin? 4. Connect to ...
-
SQLSTATE[HY000]: General error MySQL: 1364 Field 'coloum' doesn't have a default value, how to solveWith the root access of the mysql, do the following changes select @@ GLOBAL . sql_mode In my case, I get the following: ONLY_FULL_...
-
I had this issue with MYSQL 5.7 . The following worked althoug...