Posts

Showing posts from August, 2015

HTML contact form with CAPTCHA

Image
Using a contact form on your website is very useful as it helps your web site visitors to communicate with you in an easy and simple way. But, there are spammers and hackers who are looking for exploitable web forms. It is essential to secure your form against all ‘holes’ that those hackers are searching for.   Adding Captcha to the form Captcha is an image with a code written on it. The website visitor is required to read the code on the image and enter the value in a text field. If the word entered is wrong, the form submission is not processed. As CAPTCHA is a smartly blurred image, the spam bot can’t read it. So the form cannot be auto-submitted by a ‘bot’. The contact form with CAPTCHA Here is the HTML code for the contact form: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <form method= "POST" name= "contact_form" action= "<?php echo htmlentities($_SERVER['PHP_SE

PHP Captcha

Before start working with user input by accessing HTML forms , we need to ensure that these inputs are entered manually by a human. Or else, people can submit bulk unwanted data though cron like program execution or any tools, which will create serious issues like, increasing server load, getting spam data and etc. For that, we can create special code called captcha using PHP script to get rid of these issues. This article deals with some simple steps for creating such PHP captcha code. Steps in Creating PHP captcha Create captcha Add captcha into HTML form Compare captcha code Now, we are going to get into the above steps one by one. For that, we have taken PHP contact form in which the captcha code is to be put to prevent from getting spam data. Create captcha For ease understanding, We can further split this step into the following list of functionalities we need to perform. Start session to get PHP session_id before sending header to the browser. This is

PHP Captcha using jQuery AJAX Contact form (sent data to mail)

Image
Captcha code in a form is used for ensuring that the form is submitted with manual intervention without any tools or programs. In this tutorial, we are using jQuery AJAX for getting captcha image from PHP. Using jQuery we can also refresh the captcha code by resending AJAX call to generate new captcha image. View Demo Download      Contact Form with Captcha This code is for displaying contact form with refreshable captcha image. <div id = "frmContact" > <div> <label style = " padding - top : 20px ; " > Name </label> <span id = "userName-info" class = "info" ></span><br/> <input type = "text" name = "userName" id = "userName" class = "demoInputBox" > </div> <div> <label> Email </label> <span id = "userEmail-info" class = "info" ></span><br/> <i

Insert CheckBox and Radio button Data in MySQL Database Using PHP

Image
MY-SQL Code CREATE DATABASE IF NOT EXISTS databasename; CREATE TABLE students( student_name varchar(255) NOT NULL, student_email varchar(255) NOT NULL, student_contact varchar(255) NOT NULL, student_address varchar(255) NOT NULL, stars varchar(25) NOT NULL, sports varchar(25) NOT NULL, gender text(25) NOT NULL, )     Download Code     LIVE DEMO   page- formelements.php   php code <?php $connection = mysqli_connect("localhost", "root", "","formdatainsert"); // Establishing Connection with Server //$db = mysql_select_db("colleges", $connection); // Selecting Database from Server if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL $name = $_POST['name']; $email = $_POST['email']; $contact = $_POST['contact']; $address = $_POST['address']; $sports=implode(' , ',$_POST['sports']); $star=implode(' , ',$_POST['star']);

Insert Data in MySQL Database Using PHP

Image
Php is a server side scripting language it allows to store data into database at server level. In this post I will illustrate you how insert data with Sql insert query in PHP. insert into tablename(column1,column2,...) values(value1,'value2',...);    Note :  Value1 is written without single quotes, because it is an integer value and value2 is a string.       For example : value1 = 1 and value2 = Albert.   First of all, I have created  HTML form, in which method is set to post  ,to hide values in URL which flows on form submission. Next, I wrote PHP code where the main functionality of insertion of values into database is performed. At MySql database I have created a database named “colleges” and table named “students” which consists of five fields viz. “student_id”, “student_name”, “student_email”, “student_contact”, “student_address”. Here in the download code provided below there is file naming db.sql in which sql queries are written for creating databa