how to store images in database using PHP

Firstly create your fetching_images.php file.

storing_images_using_php

now create add.php file.

In below code automatically create a new folder named inages in your www directory. all the images which you upload from here will store in that images folder.

we can create images using mkdir() function of PHP.

fetching_images_using_php

now create new file for displaying images named display.php

fetching_images_using_php1

You have successfully done image storing process. enjoy.

any query mail me or whatsapp me anytime.

thank you.

Advertisements

formatting using PHP

So you’ve gone though some of the tutorial, and you can make some nifty things in PHP. But the problem is, they all look like plain text. How do you jazz them up?

Formatting with PHP actually isn’t done with PHP, it’s done with HTML. You can do this in two ways. You can add the HTML inside of the PHP… or you can add the PHP inside of the HTML. Either way, make sure your file is saved as a .php or another file type that is allowed to execute PHP on your server.

HTML inside PHP

<?php

echo “<font color=red>Premal Katigar</font>”;

?>

PHP inside HTML

<font color=”red”>

<?php echo “Premal Katigar”; ?>

</font>

Learning conditional statements in PHP

Conditionals allow your program to make choices. Following the same sort of boolean logic you just learned about, the computer can only make two choices; true or false. In the case of PHP this is accomplished using IF : ELSE statements. Below is an example of an IF statement that would apply a senior’s discount.

in following statements if $name is premal then all statements inside breckets should be display.

<?php

$name=”premal”;

if($name=”premal”)

{

echo “Premal Katigar”;

}

else

{

echo “Wrong Statement”;

}

?>

Using Cookies in PHP

A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user’s computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values.

Now Let’s See how to use Cookies.

A cookie is created with the setcookie() function.

Remember one think we have to use cookie before <html> tag.

SYNTAX :

setcookie(name, value, expire, path, domain, secure, httponly);

cookie
cookie

Above code show how to set cookie.

I have set Cookie for 30 days.

cookie
cookie

 

DELETING COOKIES :

main think is that if you want to remove cookie then you have to set it always before 1 hour ahead.

<?php
// set the expiration date to one hour ago
setcookie(“user”, “”, time() – 3600);
?>
<html>
<body>
<?php
echo “Cookie ‘user’ is deleted.”;
?>

</body>
</html>

 

Any Questions feel free to comment & mail me.