Form Validation Using JavaScript

How to Validate HTML Form Using Javascript? I had a form where I needed to put a condition “Either email or phone number should be inserted”. A name was compulsory to add, so  I have added ‘required’ keyword in name field. But for Email and phone number validation I used javascript code. Following is the […]

Read More

Dynamic Charts Using PHP

Some people say that in PHP we cannot create charts. Others say that for creating chart we need to use plugins. But, I have found an easy solution of creating dynamic charts , without using any plugins in PHP. I have written this code to display the number of inquiries received by a college and […]

Read More

Find Unique Values After using UNION in select query

It was a scenario when I had to fetch data from 3 databases. Fetching data was not tough as I had used UNION in the select query but the tough part for me was finding the distinct/unique name from all the 3 databases. I tried different ways to fetch the distinct name from the database […]

Read More

Open/Load/View HTML file in TEXTAREA and update using PHP

What we are doing here is ‘edit an HTML on the user side’. For example, I have a file called manual.html. I have uploaded that file on CPANEL and only I have the accessing the CPANEL. Now, If someone wants to make changes in the manual, what would he/she do?They would need to ask me […]

Read More

Create a simple widget|On image click pop-up window

To create pop-up window on image click following code should be used: Here I have used css to animate the image. If animation is not required “.element{” style should be removed DEMO:http://nkworlds.com/ [click on the smiley at the left hand side corner of the page]  ======================================================= <!DOCTYPE html> <html> <head> <style> /* The Modal (background) […]

Read More

Search for a word/text within all PHP files of a directory

<?php $path = getcwd(); // replace with the directory path [if you know the directory already] $filename=filepath($path); function filepath($dir){ $count_size = 0; $count = 0; $dir_array = scandir($dir); foreach($dir_array as $key=>$filename){ if($filename!=”..” && $filename!=”.”){ echo $filename; echo “<br>”; $file = $filename; $searchfor = ‘ajax’; // the following line prevents the browser from parsing this as […]

Read More

file_get_contents alternative:PHP

If file_get_contents is not working, you can use CURL. <?php //$message=file_get_contents(SERVER_PATH.’admin/emails/’.); $curlSession = curl_init(); $template_file_name=email_template.html; //replace with your filename curl_setopt($curlSession, CURLOPT_URL, SERVER_PATH.’admin/emails/’.$template_file_name); curl_setopt($curlSession, CURLOPT_BINARYTRANSFER, true); curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true); $message= curl_exec($curlSession); curl_close($curlSession); echo $message; ?>

Read More

Call more than one file using curl:PHP

Following is the script to call multiple files using curl. <?php // create both cURL resources $ch1 = curl_init(); $ch2 = curl_init(); $ch3 = curl_init(); // set URL and other appropriate options curl_setopt($ch1, CURLOPT_URL, “http://path/to/file1.php”); curl_setopt($ch1, CURLOPT_HEADER, 0); curl_setopt($ch2, CURLOPT_URL, “http://path/to/file2.php”); curl_setopt($ch2, CURLOPT_HEADER, 0); curl_setopt($ch3, CURLOPT_URL, “http://path/to/file3.php”); curl_setopt($ch3, CURLOPT_HEADER, 0); //create the multiple cURL handle […]

Read More

CURL with parameters:PHP

Following is the script used for passing parameters using CURL: <?php // create curl resource  $ch = curl_init(); // is cURL installed yet? if ($ch){   //     echo (‘ cURL is  installed!’); }       // set url       echo $set_url = curl_setopt($ch, CURLOPT_URL, “http://your/file/path/filename.php”); if($set_url) { // echo “URL SET”; […]

Read More