Saturday, 30 November 2013

PHP registration form validation code with MySQL database connectivity

registration form in php and mysql with validation

Here i am providing  you the single php code required to create a simple signup/registration form with all the necessary validations and connectivity with mysql database so that the user input data can be stored in the database.

Software used : WAMP/XAMPP OR ANY SUPPORTING PHP.

The form will look like this :




Just follow these steps at time of using the code:

  • In the database connectivity portion of the code change the phpmyadmin username and password to that of yours.
  • Create the database "user_signup" and table "user" in phpmyadmin (code is provided for that as comment ).
  • In the "user_signup" database, Just run the  "create table..." query provided in run sql query section in phpmyadmin to create the table "user" .
  • Now save the code as "form1.php"  in the wamp/xampp root directory from where you will run the code in the browser.
  • when user fills up the form and press submit ,the data will be inserted in the database and user redirects to the same signup form.( change the header location in the code if you wish to direct user to some other page).

 The code is as follows :

 <html>  
 <head>  
 <?php  
 //form validation  
 // define variables and set to empty values  
 $fname = $lname = $email = $address = $gender = @$memtype = "";  
 @$uname = @$passn = "";  
 if ($_SERVER["REQUEST_METHOD"] == "POST")  
 {  
  $fname = test_input($_POST["fname"]);  
  $lname = test_input($_POST["lname"]);  
  $email = test_input($_POST["email"]);  
  @$address = test_input($_POST["add"]);  
  @$gender = test_input($_POST["gen"]);  
  @$uname = test_input($_POST["username"]);  
  @$passn = test_input($_POST["pass"]);  
  @$memtype = test_input($_POST["mtype"]);  
 }  
 function test_input($data)  
 {  
  $data = trim($data);  
  $data = stripslashes($data);  
  $data = htmlspecialchars($data);  
  return $data;  
 }  
 ?>  
 <?php  
 // define variables and initialize with empty values  
 $fnameErr = $lnameErr = $emailErr = $addressErr= $ageErr= $unameErr = $passnErr= $genderErr = $memtypeErr = "";  
 $fname1 = $age1 = $lname1 = $email1 = $address1 = $gender1 = $passn1 = $uname1 = $memtype1 = "";  
 if ($_SERVER["REQUEST_METHOD"] == "POST") {  
  $valid = true;  
      if(empty($_POST["fname"])) {  
     $fnameErr = "Missing Firstname";  
     $valid =false;  
      }  
   else {  
     $fname1 = test_input($_POST["fname"]);  
           // check if name only contains letters and whitespace  
   if (!preg_match("/^[a-zA-Z ]*$/",$fname))  
    {  
    $fnameErr = "Only letters and white space allowed";  
    $valid=false;  
       }  
   }  
      if (empty($_POST["lname"])) {  
     $lnameErr = "Missing Lastname";  
      $valid=false;  
      }  
   else {  
     $lname1 = test_input($_POST["lname"]);  
     // check if name only contains letters and whitespace  
   if (!preg_match("/^[a-zA-Z ]*$/",$lname))  
    {  
    $lnameErr = "Only letters and white space allowed";  
    $valid=false;  
       }  
      }  
      if (empty($_POST["email"])) {  
     $emailErr = "Missing email address";  
     $valid=false;  
      }  
   else {  
     $email1 = test_input($_POST["email"]);  
           // check if e-mail address syntax is valid  
   if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email))  
    {  
    $emailErr = "Invalid email format";  
    $valid=false;  
       }  
   }  
   if (empty($_POST["add"])) {  
     $addressErr = "specify Address ";  
     $valid=false;  
      }  
   else {  
     $address1 = test_input($_POST["add"]);  
   }  
   if (!isset($_POST["gen"])) {  
     $genderErr = "specify your gender";  
     $valid=false;  
      }  
   else {  
     $gender1 = test_input($_POST["gen"]);  
   }  
      if (!isset($_POST["mtype"])) {  
     $memtypeErr = "specify your membership type";  
     $valid=false;  
      }  
   else {  
     $memtype1 = test_input($_POST["mtype"]);  
   }  
      if (empty($_POST["age"])) {  
   }  
   else {  
     $age = test_input($_POST["age"]);  
      if (preg_match("/^[a-zA-Z ]*$/",$age))  
    {  
    $ageErr = "Invalid age";  
    $valid=false;  
       }  
       }  
      if (empty($_POST["username"])) {  
     $unameErr = "specify your username";  
     $valid=false;  
      }  
   else {  
     $uname1 = test_input($_POST["username"]);  
   }  
      if (empty($_POST["pass"])) {  
     $passnErr = "specify your password";  
     $valid=false;  
      }  
   else {  
     $passn1 = test_input($_POST["pass"]);  
   }  
      }  
 // here form validation ends        
 ?>  
 <?Php  
 /*  
 --  
 -- Database: `user_signup`  
 --  
 -- --------------------------------------------------------  
 --  
 -- Table structure for table `user`  
 --  
 CREATE TABLE IF NOT EXISTS `user` (  
  `FirstName` char(30) NOT NULL,  
  `LastName` char(30) NOT NULL,  
  `Email` char(30) DEFAULT NULL,  
  `CPhone` mediumtext,  
  `Address` varchar(70) DEFAULT NULL,  
  `Age` int(11) DEFAULT NULL,  
  `Gender` char(10) DEFAULT NULL,  
  `UserName` varchar(20) NOT NULL,  
  `Password` varchar(20) NOT NULL,  
  `MType` char(10) NOT NULL,  
  `UId` int(11) NOT NULL AUTO_INCREMENT,  
  PRIMARY KEY (`UId`)  
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;  
 */  
 ?>  
 <?php  
 //mysql database connectivity  
 //inserting form data into the database  
 if(@$valid==true)  
       {  
 $con= mysql_connect("localhost","username","password");  //change the username and password  
 mysql_select_db("user_signup", $con);  
 @$a=$_POST['fname'];  
 @$b=$_POST['lname'];  
 @$c=$_POST['email'];  
 @$d=$_POST['cell'];  
 @$e=$_POST['add'];  
 @$f=$_POST['age'];  
 @$g=$_POST['gen'];  
 @$i=$_POST['username'];  
 @$j=$_POST['pass'];  
 @$h=$_POST['mtype'];  
 mysql_query("insert into user (FirstName,LastName,Email,CPhone,Address,Age,Gender,Username,Password,MType) values('$a','$b','$c','$d','$e','$f','$g','$i','$j','$h')");  
 header("Location:form1.php");  
 mysql_close($con);  
       }  
 ?>  
 </head>  
 <style>  
 div.ex  
 {  
 width:600px;  
 padding:30px;  
 border:7px solid red;  
 margin:4px;  
 }  
 body  
 {  
 background-image:url("bg.jpg");  
 }  
 </style>  
 <body >  
 <center>  
 <h2><b><i><u>Signup</u></i></b></h2>  
 <div class="ex">  
 <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" >  
 <table id="rtid1" border="0" cellpadding="5" cellspacing="0" width="600">  
 <tr id="rtrid1">  
 <td><b>FirstName*:</b></td>  
 <td>  
 <input id="FirstName" name="fname" value="<?php echo htmlspecialchars($fname);?>" type="text" maxlength="60" style="width:146px; border:1px solid #999999" />  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$fnameErr;?></i></font></span>  
 </td>  
 </tr>   
 <tr>  
 <td><b>lastName*:</b></td>  
 <td>  
 <input id="LastName" name="lname" value="<?php echo htmlspecialchars($lname);?>" type="text" maxlength="60" style="width:146px; border:1px solid #999999" />  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$lnameErr;?></i></font></span>  
 </td>  
 </tr>  
 <tr>  
 <td>  
 <b>Email address*:</b>  
 </td>  
 <td>  
 <input id="FromEmailAddress" name="email" type="text" value="<?php echo htmlspecialchars($email);?>" maxlength="60" style="width:200px; border:1px solid #999999" />  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$emailErr;?></i></font></span>  
 </td>  
 </tr>  
 <tr id="rtrid2">  
 <td><b>Cell Phone:</b></td>  
 <td><input id="CellPhone" name="cell" type="text" maxlength="43" style="width:200px; border:1px solid #999999" /></td>  
 </tr>  
 <tr id="rtrid3">  
 <td><b>Address *:</b></td>  
 <td><input id="StreetAddress1" name="add" type="textarea" value="<?php echo htmlspecialchars($address);?>" maxlength="120" style="width:300px; border:1px solid #999999" />  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$addressErr;?></i></font></span>  
 </td>  
 </tr>  
 <tr id="rtrid4">  
 <td><b>Age:</b></td>  
 <td>  
 <input id="Age" name="age" type="text" maxlength="120" style="width:300px; border:1px solid #999999" />  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$ageErr;?></i></font></span>  
 </td>  
 </tr>  
 <tr id="rtrid5">  
 <td><b>Gender*:</b></td>  
 <td>  
 <input type="radio" name="gen" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male" id= "rgm">Male  
 <input type="radio" name="gen" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female" id="rgf">Female  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$genderErr;?></i></font></span>  
 </td>  
 </tr>  
 <tr >  
 <td><b>UserName*:</b></td>  
 <td>  
 <input id="Username" name="username" type="text" value="<?php echo htmlspecialchars($uname);?>" maxlength="60" style="width:146px; border:1px solid #999999" />  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$unameErr;?></i></font></span>  
 </td>  
 </tr>  
 <tr>  
 <td><b>Password*:</b></td>  
 <td>  
 <input id="Password" name="pass" type="password" value="<?php echo htmlspecialchars($passn);?>" maxlength="60" style="width:146px; border:1px solid #999999" />  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$passnErr;?></i></font></span>  
 </td><br>  
 </tr>  
 <tr id="rtrid6">  
 <td><b>Membership type*:</b></td>  
 <td>  
 <input type="radio" name="mtype" <?php if (isset($memtype) && $memtype=="ordinary") echo "checked";?> value="ordinary">Ordinary     
 <input type="radio" name="mtype" <?php if (isset($memtype) && $memtype=="premium") echo "checked";?> value="premium">Premium  
 <span class="error"><font color="red"><i><?php echo "&nbsp&nbsp&nbsp".$memtypeErr;?></i></font></span>  
 </td>  
 </tr>  
 <td colspan="2" align="center">  
 <br />  
 <br><input id="skip_Submit" name="skip_Submit" type="submit" value="Submit" /></br>  
 </br>  
 </td>  
 </tr>  
 </table>  
 <br/>  
 </form>  
 </div>  
 </center>  
 </body>  
 </html>  







Saturday, 9 November 2013

Bitdefender total security 2013 free Download with lifetime activation

bitdefender total security 2013 full version download






Bit defender total security 2013 comes up with all the features required for PC protection and is one of the best anti-virus in the market today.Not only does it protect your computer and files, but it is easy to use and since here's the free download link available just at the bottom so value doesn't matter.

Standout Features

* Effective antivirus protection

* Light footprint on your computer

Steps to Follow


  • After downloading, Open the folder named "~Get Your Software Here"

  • Then see the video "Bit Defender 2013 Lifetime Activation Video Tutorial - code3h.mp4" which will guide about the installation procedure.
  • Just follow the steps of the video to get the fully licensed version of bit defender for lifetime .


Here's the download Link


https://www.dropbox.com/sh/2l96xi72cwb3q6d/kSprc2QK1s









Sunday, 29 September 2013

learn php step by step through videos !!!!

 

Download free videos to learn php in few Hours!!!

What is php??


 

The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases.It is a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages and for developing web based software applications. . PHP is a server-side, cross-platform, HTML embedded scripting language.

PHP statements and commands are actually embedded in HTML documents having content of a webpage.When a webpage runs on a browser the php commands gives it output,displayed on the webpage which cannot be seen in the source code.

Here is the link from which you can download video tutorials - PHP fundamentals by Jeffrey way( editor of Nettuts+) which are very useful in understanding the basic concepts of php and its fundamentals.The videos are very easy to understand and describes all platforms required to run php etc.

Here's the download link 

https://www.mediafire.com/folder/z5h7d9e2z8r4q/php%20basics








Sunday, 22 September 2013

How to find email addresses from your own gmail Account?

How to find email addresses from your own gmail Account?


Finding valid email addresses on internet without much knowledge about a person is a tough task .You must have seen your mailing account got filled with  plenty of random emails send from people you never met and try to reply them , no response generally comes back.

These emails are generally sent by educational companies ,shopping websites etc for business purposes and advertisements.And at some point of time , somehow you entered your email address in a website to complete a survey and now they can send you as many emails they want till you unsubscribe.

From my long "re"search on the internet about email addresses, I found out that there are bulk of websites,softwares etc available to get random email addresses like Rapportive(its good),email permutator,Email address collector  etc.Certain websites directly offers you large no of addresses by make you complete some surveys but God know if they are valid or not!!!

Even though, it didn't worked for me , i tried many softwares and websites to get a genuine list of email addresses for some business purpose but most of them were wrong.I mailed them and suddenly a reply came to me saying:

 Delivery to the following recipient failed permanently:

     "xylem@gmail.com"

Technical details of permanent failure:
The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces.......................!!!

The tutorial will show you get a valid list of email addresses from your own gmail account without any software,website,blog etc.

1. Login to your gmail account
    

2. Now type "Fwd" in the search section of your account
   and press "enter".
                    



Now you will get a list of all "forwarded"emails you received that is they are send to you by another person who received it from some other one.  

3. Now select one of the mail and see inside.
          
                           
you may get a no of other recipients email addresses to whom the mail is sent or forwarded and the person's other mail addresses whom sent mail to you.
This is a zero time consuming and good practice to find out quick contacts and their mail info.

Thank you!!!


Wednesday, 14 August 2013

some most sought after open source big data tools!!



Big data is the term for a collection of data sets so large and complex that it becomes difficult to process using on-hand database management tools or traditional data processing applications.

  

The data is too big, moves too fast, or doesn’t fit the structures of your database architectures. To gain value from this data, you must choose an alternative way to process it.The challenges include capture, storage, search, sharing, transfer, analysis and visualization.So a need arises to know how Big data works? There are some open source tools , you can try your hands with.


Friday, 9 August 2013

Some expensive quality gadgets , that add luxury to your home!!

 

Some of the high-tech expensive Gadgets of 2012-2013.Lets take a look at some of these.......

Loewe 55" Individual

cost :  $8,499.00/Rs. 5,46,750

 

 

This entertainment system opens up many multimedia possibilities.With its surround sound and High quality 3D environment will make your home your theater. you can watch web videos,listen to online radio and can even convert your 2-D programmes to 3-D.With a 400 Hz E-led  backlit screen, an integrated 3D blue-ray player and a hard disk recorder with 500 GB memory ,everything you need comes from one source.Know more about the Gadget 


Tuesday, 6 August 2013

How to test a website on Different mobile devices?


What testing does your mobile Site need?


Be prepared to test your website on as many mobile devices as you possibly can. Although you can use your browser to test or imitate thing such as screen size, display, layout etc. but there are some horrible things that can go wrong which cannot be seen on a browser. Some of these are:



Monday, 5 August 2013

Easiest and Fastest way to sync and share your files !


Free online Syncing tool to sync all your files at one place!!!

  

Most of us use multiple devices to store and access our files. At home, Laptop is used, desktop, tablets at work and Smartphone on the go. Storing files on cloud rather than on a personal device makes data's access more convenient and easy. There are many online storage platforms which lets you to sync all your data and files. The latest cloud storage device in the queue is 4sync. If you are using one or planning to use, then give a try to 4sync. It lets you access all your files and data from anywhere at any time. It gives 15 GB of free online data storage space.Though Google drive and dropbox are available but 4sync is a good alternative.
  
A look at some of its features



Saturday, 3 August 2013

What makes Google glass, the most hotly anticipated Gadget!!!!

What makes Google glass, the most hotly anticipated Gadget!!!!


Wearable smart-devices represent the next phase in mobile computing. It is not an extension of your Android Smartphone or tablet, but is a whole new gadget in itself that can perform various day to day tasks, without you ever moving your hands. Google glass is a high tech and advanced Eye glasses that are powered by android OS. It can connect to internet and record videos plus it can take pictures just like your Iphone but the best thing is that you only need wear it like sunglasses. This glass control via voice commands just like "Ok” represent Enter button on a pc. In addition this glass got GPS (global positioned system) that can help user to find where they need to go. Google glass uses Wi-Fi as band.

 

Some cool features of Google glass one must know…..



Thursday, 1 August 2013

A look at the world’s slimmest Full HD smartphone !!

Xperia Z Ultra














Sony recently launched its Xperia Z Ultra in India claiming to be the slimmest full hd smartphone. It is one of the biggest handsets in the world. The new device, which has a 6.4-inch screen, has been priced at Rs 46,990 and will hit the stores on August 2. It is water and dust resistant and run on Android 4.2(Jelly bean).The device has the same design language as Xperia Z smartphone and features on-screen keys as well as scratch-resistant and shatterproof glass.What makes Windows 8.1 different from others?
 

Key features:



Turingo: Answer Your Curiosity

Create questions | Search questions | Get your answers | Join Communities | Create your teams | Get answers to your curiosity