Make your own php image resizer tools.

Today I am going to share a new php script, by which you can resize your image without croping image. You may know that php is a strong programing language, by using it, you can solve your any problem. Now, Let's start our tutorial.



1st, Create 3 file and 2 folder for this.

3 files

  1. resize.php - the main file of resize image.
  2. index.php - for use resize.php
  3. style.css - The file for design (css)

2 folders

  1. uploads - The folder for your uploaded photo which will be resize
  2. images - The folder for save your resized images.

Open your created resize.php file with any notepad like
notepad++
and paste this code to the file.



Save this file by CTRL+S.

Now Open your index.php and paste this code and save the file.

Our job tutorial complete. But is the script looking ugly? No problem, Paste this css code in your created style.css
It is optional, Now my tutorial is complete.

Note: Remove breaking tag from the code, otherwise it returns a false result.

If you found a little bite of help then don't forget to share this post and promote us.
Thanks for reading and staying with us.

How to create captcha image by php

Hello guys, how are you? May god keep better you at this moment. However, We see the captcha varification in many website.

You can create it using php very easily. I have added the php code which will create a captcha image. Let's view the code



Save this code with name "captcha.php". Now run this code in your server. What's you seeing. A box with some text. Now it's time to create the form for use this captcha system.

Create a new file name "index.php" or any name. Paste this code to the file.



Now create another file name "validate.php". This file will use to check the code entered in the form if right or wrong.



Now run the index.php file or other which you create to save the form code.

Now hits bellow share button to share this post with your friends.

PHP email sending script

Php mail sender script

→ send email what you need.
Php have a function to send email and it is mail()
The strocture is mail(to,subject,messege,from);
Okey, now I start my tutorial. First create a html file and save file with this code.



Create a php file named mail.php and save your file with this code.


Now run your html file and send unlimited email.

How to protect a php file with password by php

Hello everybody, How are you? EID  MUBARAK to all. Today I am going to show you how can you protect a php file by php. If you want the file will only show for you or by entering password, then you can follow the tutorial.

For this work, You must know the basic php. Paste this code in your php file

<?php
$view = header(location: #allcode);
$passMain = yourpasswordhere;
echo "<form method='post' action='#allcode'><input type='password' name='pass'/><input type='submit' value='View file'/></form>";
if($pass==$passMain)
{
echo "$view";
}
else
{
echo "Your password is not correct";
}
?>
<div id="allcode">Your file's all code here</div>

Now save your file and run. Here the $passMain variable contains your main password which will unlock the file. So, change the password with your own.
Good bye and again EID MUBARAK


Random number tutorial in php

There are many use of random number. In php, there are a function to create random number and it is rand();
ex:
<?php
echo rand();
?>
It will output a number and refresh the page it will output deferent number.

You can create many random number by using bellow code:

<?php
echo rand(). "\n";
echo rand(). "\n";
echo rand(). "\n";
echo rand(). "\n";
?>

It will output deferent 4 random number.

If we want to get a number between a range then what can we do? Example, if we want get a number between 15 and 30 then we can use this code
<?php
echo rand(15, 30);
?>

Now We can use this in our project by adding some condition.
Ex:

<?php
$rand = rand(1, 3);
if ($rand == 1){
echo "Generated number is 1";
}else if ($rand == 2){
echo "Generated number is 2";
}else {
echo 'Generated number is 3';
}
?>

Good by and wish you EID MUBARAK.

Make Your own PHP Hit Counter


This is a basic site hit counter. What it does is take a few lines of code that open up a file called ( countlog.txt) and changes a simple number in it. First off, what you need to do is make a new ( .php) file in your text editor and place this code in it. The only thing you may need to change is the parts of the code that says ( /countlog.txt ). That’s only if you plan to put your files in a different directory. I put this in the same directory, so I put the ( / ) in front of ( countlog.txt )

<?php
/* counter */
/* opens countlog.txt to read the number of hits */
$data = fopen("/countlog.txt", "r");
$count = fgets($data,1000);
fclose($data);
$count = $count + 1;
echo "$count";
echo "hits";
echo "\n";
/* opens countlog.txt to change new hit number */
$data = fopen("/countlog.txt", "w");
fwrite($data, $count);
fclose($data);
?>

Save the file as ( counter.php ).
Now, on to the next part. Simply make a file named ( countlog.txt ) and put a ( 0 ) in it. Then save. Or, you could put whatever number you want to in the file. This is the number your, counter will start counting from. If your last hit counter was already at 22 hits, why start over? Just type in ( 22 ) in the
( countlog.txt) file!

To include the file in any page in your site all you have to do is include it. Here’s the code.

<?php
include("/counter.php");
?>

Or


<script src="/counter.php" type="javascript/text"/>

You may have to change the path on that as well, depending on what directory you put your file in. Or, you could just put the ( counter.php ) code inside of any page you want. It will work the same.

Popular Posts

Post Category

Blog Statistics

Now online

Page views
Powered by Blogger.