How to change the background, text or a div color on real time with php, mysql, ajax and jQuery ?

Description:- Hello! In this lesson I’ll show you guys the logic with little example to how to change the background, text or a div color on real time with php, mysql, ajax and jQuery.
Maybe you guys have better logics to shorten my code. If you have then please comment below.

So for this lesson make the following files step by step:-
1. create database and name it “color”
2. create row in database(color) and name it colorname
3. Create 2 columns 
    (i) id
    (ii) colorcode
4. Download jQuery file
5. Create changebg.php
6. Create config.php
7. Create insertcolor.php

1. config.php

pdf of config file

2. changebg.php

pdf of changebg file

3. insertcolor.php

pdf of insertcolor file

*NOTE :- I’m providing you pdf files as my wordpress text editor is not working well copy and paste code and make the php files with the same name of files and then goto your browser after making database and then run the changebg.php file.
Live demo is available here

How to create dynamic, responsive image slider with PHP, mysqli, bootstrap and jQuery ?

Description :- In this lesson I’m gonna provide the code from which you guys can easily make fully Dynamic Carousel  Silder from which you’ll fetch image name from database and images from your img folder.

Establishing Database:-
Now, I know that you all guys know how to create new database and name it slider after this create new table and name it images and make 2 rows
(i) id
(ii) img 
And then insert your image name with extension into the img row .

Now follow some simple steps for setting up everything which we need for this lesson:-
1. Download the bootstrap
2. Download jquery file from jquery.com
2. Create a new folder and rename it as img and put some images in it.
3. Create a new folder and rename it as css and make app.css in the css folder
4. Create an index.php file
5. Create config.php file (the connection file to our database)

1. config.php   (the connection file)

<?php
$con = mysqli_connect("localhost","root","","slider");
if(mysqli_errno($con))
{
 echo mysqli_error(); 
}
?>

2. index.php  (the file where your silder code lives with some jquery lines)

There are some problems with wordpress text editor so I’m providing pdf of index.php copy from pdf and make index.php
Copy code from this link

3. app.css   (lives in css folder)

.

a.carousel-control {
 opacity: 1;
 height: inherit;
 width: inherit;
 background: none;
 text-shadow: none;

}
.prevSlide
{
 color: #f5f5f5;
 font-size: 2em;
 position: absolute;
 top: 50%;
 left: 0;
 background-color:rgba(0,0,0,0.5);
 transform: translate(0,-50%);
 padding: 0 10px;
}
.prevSlide:hover
{
 color:rgba(247,148,30,1);
 background-color:rgba(0,0,0,0.8);
}
.nextSlide
{
 color: #f5f5f5;
 font-size: 2em;
 position: absolute;
 top: 50%;
 right: 0;
 background-color:rgba(0,0,0,0.5);
 transform: translate(0,-50%);
 padding: 0 10px;
}
.nextSlide:hover
{
 color:rgba(247,148,30,1);
 background-color:rgba(0,0,0,0.8);
}

*Note:- My final product screenshot is this except the images in the slider you will get the same result.

Thanks 🙂

slider

index

How to get image from url and insert into database and store image in your local root folder through PHP and mysql?

Description:- Hi ! In this tutorial I’m going to provide you code to get the image from url and then to store in the database as well in your local root directory or in a folder.
You can also include this type of image search thing in your website so that user will get limitless option to upload a picture.
I use rand() function to rename the image name and it will be helpful for you when you make a large website. 

This chapter will complete in 3 different steps:-
1. Make index.php
2. Make a new folder in which your image will store and rename that folder as ‘image’
3. Make a new database and give it a name mukulexp

1. index.php

<?php
// connection to database
$con = mysql_connect("localhost","root","");
mysql_select_db('mukulexp',$con) or die("could not connect");
?>
<?php
if(isset($_REQUEST['subimg']))
{
 // Your file
 $file = $_REQUEST['url'];
 
// Open the file to get existing content
$data = file_get_contents($file);
$newimage=rand()."abc.jpg";
// New file
$new = 'image/'.$newimage;
// Write the contents back to a new file
file_put_contents($new, $data);
mysql_query("Insert into image set name = '$newimage' ");
 echo "<img src='image/$newimage' width='300px' height='250px'/>";
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="url" name="url"/><br/><br/>
<input type="submit" name="subimg" value="submit"/> 
</form>

2. Make a new folder and rename it as image

3. Make a new database and give it a name of mukulexp and then enter in your mukulexp and click on SQL and paste the below code or make the table by yourself and name it image and then make 2 columns in it first id and second name

CREATE TABLE IF NOT EXISTS `image` (
 `id` int(90) NOT NULL AUTO_INCREMENT,
 `name` varchar(4000) NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
--
-- Dumping data for table `image`
--
INSERT INTO `image` (`id`, `name`)

NOTE : – Do all the above point as they are mentioned. Watch video for help
Happy Coding 🙂

How to replace bad/abusive/swear/curse words through php ??

Description:- Hello guys today’s lesson is only for 18+ public because I really don’t want children to learn abusive words on my blog.
Today I’m going to show you how to replace abusive words through php like if someone typed in FUCK it will display like F**K .

<?php

$string = "Hello asshole I heared that you are asslicker too. Fuck off jerk and never show me your buttface.";
$swearWords = array("asshole","buttface","asslicker","jerk","fuck");
$replacer = array("a**hole","b**tface","a**li***r","j**k","f**k");
$filter = str_ireplace($swearWords,$replacer, $string);

echo $filter;
?>

*Note:- You can also use str_replace() but hence str_replace is case sensitive and str_ireplace() is not a case sensitive so it will accept both types of words lowercase or uppercase words.

How to make Fully functional Contact Form in php using mail() function ?

Description: In this example I’m gonna show you guys how to make fully functional contact form in php using mail() function. And in this example we also cover how to change the placeholder color, how to make captcha code and then will verify if the captcha code is same as you typed in.

I make this contact form for the holding page for my client  the kensington dentist, London.

And most important thing is this contact form is build in Zurb Foundation to make it fully responsive you guys can also use twitter bootstrap….

This example includes 4 different files:-
1. index.php   (In which we make our form)
2. send.php   (through which we’ll send the form it includes mail() function)
3. foundation.css  (its a zurb foundation css file to make the form responsive)
4. app.css  (this will be our custom stylesheet where we’ll give styling to input types and to the placeholders)

————————————————————————————————-
1. index.php

<?php
//  For captcha 
$aa = md5( time() * microtime() );
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Contact form</title>
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, user-scalable=0"/>
<link href='http://fonts.googleapis.com/css?family=Lato:100,300,400,700,100italic,300italic,400italic,700italic' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="app.css"/>
<link rel="stylesheet" type="text/css" href="foundation.css"/>
</head>
<body>
   
       
                           
                   
                       
                                                   
                       
                                                    
                    </div>                                         
                       
                                                 
                       
                                                    
                    </div>                 </div>                                 
                   
                                           
                </div>                
                    
                        " readonly />                    
                </div>                
                    
                                                 
                </div>                
                   
                                           
                </div>                 
                   
                       

                       

                   
                </div>             </form>         </div>     </div> </div> </body> </html>

2. send.php

<?php
    if($_REQUEST['captcha'] != $_REQUEST['check'])
       {
            header("Location: index.php?error=The characters you entered didn't match the word verification. Please try again.");
       }
    else
       {
            $myemail = "mukul.soni0007@gmail.com";  /*ENTER THE EMAIL ADDRESS WHERE YOU WANT TO RECIEVE THE MAILS. In this case I set it to my personal gmail account. You can also make it dynamic by using $_REQUEST['the name of the field'] */
           
           $name = $_POST['fname'];
           $sname = $_POST['sname'];
           $subject = "Contact Form Submission";    /* Or you can make it dynamic by using $_POST['name of the field'] */
           $email = $_POST['mail'];
           $message = $_POST['message'];
           $tel = $_POST['tel'];
           
           $message="
           Name : $name $sname
           E-mail : $email
           Subject : $subject
           Telephone : $tel
           Message : 
           $message
           ";
           
           /* Send the message using mail() function */
           if(mail ($myemail, $subject, $message))
           {
           
           /* Redirect visitor to the page you guys want */
           header("Location: index.php?success=Thanks! We'll get back to you soon");
           exit(); 
           }
           else{
           /*If any error then throw an error.*/
               echo "Some error Occured !";
               exit();
           } 
       }
?>

3. foundation.css

You guys will find foundation.css here

4. app.css

.cb
{
    border:1px solid #000;
}
.posts-contact ::-webkit-input-placeholder {
   color: #24292d;
    opacity: 0.7;
}

.posts-contact :-moz-placeholder { 
   color:  #24292d;  
}

.posts-contact ::-moz-placeholder { 
   color:  #24292d;  
}

.posts-contact :-ms-input-placeholder {  
   color:  #24292d;  
}

.posts-contact
{
    
    max-width:504px;
    margin:34px auto;
    margin-bottom:0px;
    
}
#captcha
{
    background-color:#fff;
    font-size: 20px;
    font-weight:bold;
    text-shadow: 2px 0px 5px #5ca8fe;
    font-family:'Lato', sans-serif;
    color:rgba(0,0,0,0.5);
    letter-spacing: 10px;
}
.posts-contact input[type="text"],
.posts-contact input[type="tel"],
.posts-contact input[type="email"],
.posts-contact textarea
{
    background-color:#fff;
    box-shadow: 0px 0px 0px;
    text-shadow: none;
    color:rgba(0,0,0,0.75);
    font-family:'Lato', sans-serif;
    border:1px solid #c7c7c7;
    letter-spacing: 1px;
}
textarea
{
    font-family:'Lato', sans-serif;
}
input[type='submit']
{
    background-color:#75b4e2;
    width:171px;
    height:48px;
    border:1px solid #4484b4;
    color:#fff;
    font-family:'Lato', sans-serif;
    font-weight:bold;
    margin-top:28px;
}
input[type='submit']:hover
{
    cursor:pointer;
}
#error
{
    color:#f00;
    font-size:17px;
    padding: 5px;
    font-family: "Lato",sans-serif;
}
#success
{
    color:#2add37;
    font-size:17px;
    padding:5px;
    font-family: "Lato",sans-serif;
}

Note:-
1. Please whenever you use this contact form please change the email address inside send.php file which is wrapped in $myemail variable otherwise I’ll get all your mails.
2. It is possible that you can not find the mail in your inbox. So don’t forget to check spam folder
3. Keep all 4 files in the same folder.
4. You need a server to check this. Without server its just a static contact form. It will work only online.
If you want to see the live example of this form you can go to my testing server i.e jaiupur4ever .

To watch the video of php mail function