Thursday, 16 October 2014

 <script type="text/javascript" src="">  
 function validate()  
 {  
      var d=document.register;  
      var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
      if(d.cn.value == '')  
      {  
           alert("Enter Name");  
           d.cn.focus();  
           return false;  
      }  
      if(d.cn.value.length<=2)  
      {  
      alert("Minimum Name Should be greater than two");  
      return false;       
      }  
      if(d.email.value == '')  
      {  
      alert("Email is is Required");  
      d.email.focus();  
      return false;       
      }  
      if(reg.test(d.email.value) == false)  
      {  
      alert("Invalid Email");  
      return false;       
      }  
      if(d.password.value == '')  
      {  
      alert("Password is is Required");  
      d.password.focus();  
      return false;       
      }  
      if(d.password.value != d.cpassword.value)  
      {  
      alert("Passwords Mismatch")  
      return false;       
      }  
      if(d.year.value == 1)  
      {  
      alert("Select Year");  
      return false;       
      }  
      if(d.gender[0].checked == false && d.gender[1].checked == false)  
      {  
      alert("Select Gender");  
      return false;       
      }  
      if(d.terms.checked == false)  
      {  
      alert("Accept terms");  
      return false;       
      }  
 }  
 </script>  
 <form name="register" method="post" onSubmit="return validate()">  
 <table width="200" border="1" align="center">  
  <tr>  
   <td>CompanyName<span style="color:red">*</span>:</td>  
   <td><input type="text" name="cn" id="cn"></td>  
  </tr>  
  <tr>  
   <td>Email<span style="color:red">*</span>:</td>  
   <td><input type="text" name="email" id="email"></td>  
  </tr>  
  <tr>  
   <td>Password<span style="color:red">*</span>:</td>  
   <td><input type="password" name="password" id="password"></td>  
  </tr>  
  <tr>  
   <td>Confirm-Password:</td>  
   <td><input type="password" name="cpassword" id="cpassword"></td>  
  </tr>  
  <tr>  
   <td>Year<span style="color:red">*</span>:</td>  
   <td>  
   <select name="year" id="year">  
   <option value="1">Select</option>  
   <?php for($i=1999;$i<=date(Y);$i++) { ?>  
   <option value="<?php echo $i ?>"><?php echo $i ?></option>  
   <?Php } ?>  
   </select>  
   </td>  
  </tr>  
  <tr>  
   <td>Gender<span style="color:red">*</span>:</td>  
   <td><input type="radio" name="gender" id="gender">Male  
   <input type="radio" name="gender" id="gender">FeMale</td>  
  </tr>  
  <tr>  
  <td colspan="2"><input type="checkbox" name="terms" id="terms">  
  I Accepted the <a href="terms.php">terms&conditions</a></td>  
  </tr>  
  <tr>  
   <td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="Register"></td>  
  </tr>  
 </table>  
 </form>  

html

html registration form with validation

Posted by Unknown  |  3 comments

 <script type="text/javascript" src="">  
 function validate()  
 {  
      var d=document.register;  
      var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
      if(d.cn.value == '')  
      {  
           alert("Enter Name");  
           d.cn.focus();  
           return false;  
      }  
      if(d.cn.value.length<=2)  
      {  
      alert("Minimum Name Should be greater than two");  
      return false;       
      }  
      if(d.email.value == '')  
      {  
      alert("Email is is Required");  
      d.email.focus();  
      return false;       
      }  
      if(reg.test(d.email.value) == false)  
      {  
      alert("Invalid Email");  
      return false;       
      }  
      if(d.password.value == '')  
      {  
      alert("Password is is Required");  
      d.password.focus();  
      return false;       
      }  
      if(d.password.value != d.cpassword.value)  
      {  
      alert("Passwords Mismatch")  
      return false;       
      }  
      if(d.year.value == 1)  
      {  
      alert("Select Year");  
      return false;       
      }  
      if(d.gender[0].checked == false && d.gender[1].checked == false)  
      {  
      alert("Select Gender");  
      return false;       
      }  
      if(d.terms.checked == false)  
      {  
      alert("Accept terms");  
      return false;       
      }  
 }  
 </script>  
 <form name="register" method="post" onSubmit="return validate()">  
 <table width="200" border="1" align="center">  
  <tr>  
   <td>CompanyName<span style="color:red">*</span>:</td>  
   <td><input type="text" name="cn" id="cn"></td>  
  </tr>  
  <tr>  
   <td>Email<span style="color:red">*</span>:</td>  
   <td><input type="text" name="email" id="email"></td>  
  </tr>  
  <tr>  
   <td>Password<span style="color:red">*</span>:</td>  
   <td><input type="password" name="password" id="password"></td>  
  </tr>  
  <tr>  
   <td>Confirm-Password:</td>  
   <td><input type="password" name="cpassword" id="cpassword"></td>  
  </tr>  
  <tr>  
   <td>Year<span style="color:red">*</span>:</td>  
   <td>  
   <select name="year" id="year">  
   <option value="1">Select</option>  
   <?php for($i=1999;$i<=date(Y);$i++) { ?>  
   <option value="<?php echo $i ?>"><?php echo $i ?></option>  
   <?Php } ?>  
   </select>  
   </td>  
  </tr>  
  <tr>  
   <td>Gender<span style="color:red">*</span>:</td>  
   <td><input type="radio" name="gender" id="gender">Male  
   <input type="radio" name="gender" id="gender">FeMale</td>  
  </tr>  
  <tr>  
  <td colspan="2"><input type="checkbox" name="terms" id="terms">  
  I Accepted the <a href="terms.php">terms&conditions</a></td>  
  </tr>  
  <tr>  
   <td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="Register"></td>  
  </tr>  
 </table>  
 </form>  

08:10 Share:

how to use ckeditor in php

Posted by Unknown  |  No comments


03:55 Share:

Monday, 18 August 2014

                             In This Tutorial We Will See how to upload a file


HTML FORM:
   
        
 <html>  
 <h1 align="center">SAMPLE FORM</h1>    
 <br><br>  
 <form action="UploadTest.php" method="post" enctype="multipart/form-data">  
 <table style="font-family:verdana;font-size:17px" width="50%">  
 <tr height="50">  
 <td>NAME</td>    
 <td><input type="text" name="t1" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td>AGE</td>    
 <td><input type="text" name="t2" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td>PROFILE</td>    
 <td><input type="file" name="t3" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td colspan="2" align="center">  
 <input type="submit" value="REGISTER">    
 </td>    
 </tr>  
 </table>  
 </form>  
 </body>  
 </html>  
Uploadtest.php
   
       
 <?php  
 echo "<h1>";  
 //if($_FILES['t3']['error']==0)  
 if($_FILES['t3']['error']==0 && $_FILES['t3']['type']=="text/plain" && $_FILES['t3']['size']==25)  
 {  
 $res=move_uploaded_file($_FILES['t3']['tmp_name'], "Upload/".$_FILES['t3']['name']);  
 if($res)  
  echo "File Uploaded!!!";    
 else  
  echo "File could not be uploaded!!".$_FILES['t3']['error'];   
 }  
 else  
   echo "Pl upload only text files !!! <br> U have uploaded ".$_FILES['t3']['type']." file";  
 ?>  
php

File Uploading Using PHP

Posted by Unknown  |  No comments

                             In This Tutorial We Will See how to upload a file


HTML FORM:
   
        
 <html>  
 <h1 align="center">SAMPLE FORM</h1>    
 <br><br>  
 <form action="UploadTest.php" method="post" enctype="multipart/form-data">  
 <table style="font-family:verdana;font-size:17px" width="50%">  
 <tr height="50">  
 <td>NAME</td>    
 <td><input type="text" name="t1" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td>AGE</td>    
 <td><input type="text" name="t2" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td>PROFILE</td>    
 <td><input type="file" name="t3" size="30"></td>  
 </tr>  
 <tr height="50">  
 <td colspan="2" align="center">  
 <input type="submit" value="REGISTER">    
 </td>    
 </tr>  
 </table>  
 </form>  
 </body>  
 </html>  
Uploadtest.php
   
       
 <?php  
 echo "<h1>";  
 //if($_FILES['t3']['error']==0)  
 if($_FILES['t3']['error']==0 && $_FILES['t3']['type']=="text/plain" && $_FILES['t3']['size']==25)  
 {  
 $res=move_uploaded_file($_FILES['t3']['tmp_name'], "Upload/".$_FILES['t3']['name']);  
 if($res)  
  echo "File Uploaded!!!";    
 else  
  echo "File could not be uploaded!!".$_FILES['t3']['error'];   
 }  
 else  
   echo "Pl upload only text files !!! <br> U have uploaded ".$_FILES['t3']['type']." file";  
 ?>  

11:32 Share:
             In this Post We will See how to give  connection to  database  in php
   
       
 <?php  
 $host = 'hostname';  
 $user = 'username';  
 $pass = 'yourpassword';  
 $conn = mysql_connect($host, $user, $pass);  
 if(! $conn )  
 {  
  exit('Not connected: ' . mysql_error());  
 }  
 echo 'Connection Established successfully';  
 mysql_close($conn);  
 ?>  
php

Database Connection in PHP&MYSQL

Posted by Unknown  |  No comments

             In this Post We will See how to give  connection to  database  in php
   
       
 <?php  
 $host = 'hostname';  
 $user = 'username';  
 $pass = 'yourpassword';  
 $conn = mysql_connect($host, $user, $pass);  
 if(! $conn )  
 {  
  exit('Not connected: ' . mysql_error());  
 }  
 echo 'Connection Established successfully';  
 mysql_close($conn);  
 ?>  

11:25 Share:
This Is a Sample Form:

Simple Registration Form
Type:
Name:
Email:
Password:
Re-Type Password:



HTML CODE:

        
  
         
        
 <form name="reg" id="reg" method="post" onSubmit="return validate_reg();" action="" >  
                                      <table border="1" cellspacing="0" cellpadding="0">  
                                       <tr>  
                                        <td align="left" valign="middle"><b>Simple Registration Form</b></td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Type:  
                                         <select name="type">  
                          <option value="Select">Select Type</option>  
                                          <option value="1">IT - software</option>  
                                          <option value="2">NON-IT software</option>  
                                          </select>                                        </td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Name: <input type="text" name="name" placeholder="Name" >                                        </td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Email:<input type="text" name="email" placeholder="Email" ></td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Password:<input type="password" name="pwd" placeholder="Password" ></td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Re-Type Password:<input type="password" name="cpwd" placeholder="Re Enter Password" ><br />  
                                         <label for="remember">  
                                          <input type="checkbox" name="terms" id="remember" value="remember" />  
                                          <span>I accept to the <a href="" target="_blank" style="color:maroon;">Terms and Conditions</a></span>                                         </label><br /><br />  
                           <div style="text-align:center;"><input type="submit" name="submit" title="Submit" class="rbutton" value="Submit" /></div>                          </td>  
                                        </tr>  
  </table>  
                                      </form>  
Here Is JAVASCRIPT CODE:
  
         
        
                                 <script language="javascript">   
                                                    function validate_reg()  
                                                    {   
                                                    if(document.reg.name.value == '')  
                                                    {  
                                                     alert("Name filed is required");  
                                                        document.reg.name.focus();  
                                                        return false;  
                                                    }  
                                                    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
                                                    var address = document.reg.email.value;  
                                                          if(reg.test(address) == false) {  
                                                              alert('Invalid Email');  
                                                              document.reg.email.focus();  
                                                              return false;  
                                                              }  
                                                   if(document.reg.pwd.value == '')  
                                                    {  
                                                     alert("Password filed is required");  
                                                        document.reg.pwd.focus();  
                                                        return false;  
                                                    }       
                                                    if(document.reg.cpwd.value == '')  
                                                    {  
                                                     alert("Re Enter Password filed is required");  
                                                        document.reg.cpwd.focus();  
                                                        return false;  
                                                    }            
                                                    if(document.reg.pwd.value != document.reg.cpwd.value)  
                                                    {  
                                                     alert("Passwords doesn't matched");  
                                                        document.reg.cpwd.focus();  
                                                        return false;  
                                                    }  
                                                    if(document.reg.terms.checked == false)  
                                                    {  
                                                         alert("You have to agree with the Terms & Conditions.");  
                                                        return false;       
                                                    }  
                                               }  
                                                   </script>  
demos

Form Validation Using JavaScript

Posted by Unknown  |  No comments

This Is a Sample Form:

Simple Registration Form
Type:
Name:
Email:
Password:
Re-Type Password:



HTML CODE:

        
  
         
        
 <form name="reg" id="reg" method="post" onSubmit="return validate_reg();" action="" >  
                                      <table border="1" cellspacing="0" cellpadding="0">  
                                       <tr>  
                                        <td align="left" valign="middle"><b>Simple Registration Form</b></td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Type:  
                                         <select name="type">  
                          <option value="Select">Select Type</option>  
                                          <option value="1">IT - software</option>  
                                          <option value="2">NON-IT software</option>  
                                          </select>                                        </td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Name: <input type="text" name="name" placeholder="Name" >                                        </td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Email:<input type="text" name="email" placeholder="Email" ></td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Password:<input type="password" name="pwd" placeholder="Password" ></td>  
                                        </tr>  
                                       <tr>  
                                        <td align="left" valign="middle">Re-Type Password:<input type="password" name="cpwd" placeholder="Re Enter Password" ><br />  
                                         <label for="remember">  
                                          <input type="checkbox" name="terms" id="remember" value="remember" />  
                                          <span>I accept to the <a href="" target="_blank" style="color:maroon;">Terms and Conditions</a></span>                                         </label><br /><br />  
                           <div style="text-align:center;"><input type="submit" name="submit" title="Submit" class="rbutton" value="Submit" /></div>                          </td>  
                                        </tr>  
  </table>  
                                      </form>  
Here Is JAVASCRIPT CODE:
  
         
        
                                 <script language="javascript">   
                                                    function validate_reg()  
                                                    {   
                                                    if(document.reg.name.value == '')  
                                                    {  
                                                     alert("Name filed is required");  
                                                        document.reg.name.focus();  
                                                        return false;  
                                                    }  
                                                    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
                                                    var address = document.reg.email.value;  
                                                          if(reg.test(address) == false) {  
                                                              alert('Invalid Email');  
                                                              document.reg.email.focus();  
                                                              return false;  
                                                              }  
                                                   if(document.reg.pwd.value == '')  
                                                    {  
                                                     alert("Password filed is required");  
                                                        document.reg.pwd.focus();  
                                                        return false;  
                                                    }       
                                                    if(document.reg.cpwd.value == '')  
                                                    {  
                                                     alert("Re Enter Password filed is required");  
                                                        document.reg.cpwd.focus();  
                                                        return false;  
                                                    }            
                                                    if(document.reg.pwd.value != document.reg.cpwd.value)  
                                                    {  
                                                     alert("Passwords doesn't matched");  
                                                        document.reg.cpwd.focus();  
                                                        return false;  
                                                    }  
                                                    if(document.reg.terms.checked == false)  
                                                    {  
                                                         alert("You have to agree with the Terms & Conditions.");  
                                                        return false;       
                                                    }  
                                               }  
                                                   </script>  

10:10 Share:

Sunday, 17 August 2014



                                 In this Post We will See Login Using Php Script
  Create a page login_1.php and add the following code

 

login_1.php
 <?php session_start();  
 $db=mysql_connect("localhost","root",'' ");  
 mysql_select_db("sample",$db);
  
 @$email=$_POST['email'];  
 @$password=$_POST['password'];  
 if(isset($_POST['submit'])) {  
 $sql="select * from clist where email='".$email."' and password='".$password."'";       
 $res=mysql_query($sql);  
 $nums=mysql_num_rows($res);  
 if($nums==1)  
 {  
      $result=mysql_fetch_array($res);  
      $_SESSION['email']=$result['email'];  
      $_SESSION['type']=$result['type'];  
      $_SESSION['id']=$result['id'];  
      header("location:next1.php");  
 }  
 else  
 {  
 echo "<script>alert('invalid details')</script>";       
 }  
 }  
 ?>  
 <style>  
 table {  
      background:#8FC283;  
      margin-top:150px;  
      border-radius:5px;  
 }  
 </style>  
 <form method="post">  
 <table align="center" border="0">  
 <tr><td>Email:</td><td><input type="text" name="email" id="email"></td></tr>  
 <tr><td>Password:</td><td><input type="password" name="password" id="password"></td></tr>  
 <tr><td align="center" colspan="2"><input type="submit" name="submit" id="submit" value="Login"></td></tr>  
 </table>   
 </form>  

next1.php:
 <?php session_start();  
 if (empty ($_SESSION['email']))  
 { 
header ('Location: login_1.php');;  
  }  
 echo "Welcome&nbsp;".@$_SESSION['email'];  
 ?>  
 <ul>  
 
 <ol><a href="logout11.php">Logout</a></ol>  
 </ul>  

 logout11.php:  
 <?php session_start();  
 session_destroy();  
 header("location:login_1.php");  
 ?>  
php

login script php

Posted by Unknown  |  No comments



                                 In this Post We will See Login Using Php Script
  Create a page login_1.php and add the following code

 

login_1.php
 <?php session_start();  
 $db=mysql_connect("localhost","root",'' ");  
 mysql_select_db("sample",$db);
  
 @$email=$_POST['email'];  
 @$password=$_POST['password'];  
 if(isset($_POST['submit'])) {  
 $sql="select * from clist where email='".$email."' and password='".$password."'";       
 $res=mysql_query($sql);  
 $nums=mysql_num_rows($res);  
 if($nums==1)  
 {  
      $result=mysql_fetch_array($res);  
      $_SESSION['email']=$result['email'];  
      $_SESSION['type']=$result['type'];  
      $_SESSION['id']=$result['id'];  
      header("location:next1.php");  
 }  
 else  
 {  
 echo "<script>alert('invalid details')</script>";       
 }  
 }  
 ?>  
 <style>  
 table {  
      background:#8FC283;  
      margin-top:150px;  
      border-radius:5px;  
 }  
 </style>  
 <form method="post">  
 <table align="center" border="0">  
 <tr><td>Email:</td><td><input type="text" name="email" id="email"></td></tr>  
 <tr><td>Password:</td><td><input type="password" name="password" id="password"></td></tr>  
 <tr><td align="center" colspan="2"><input type="submit" name="submit" id="submit" value="Login"></td></tr>  
 </table>   
 </form>  

next1.php:
 <?php session_start();  
 if (empty ($_SESSION['email']))  
 { 
header ('Location: login_1.php');;  
  }  
 echo "Welcome&nbsp;".@$_SESSION['email'];  
 ?>  
 <ul>  
 
 <ol><a href="logout11.php">Logout</a></ol>  
 </ul>  

 logout11.php:  
 <?php session_start();  
 session_destroy();  
 header("location:login_1.php");  
 ?>  

10:18 Share:

Email-ID:
            In View Page  Jquery validation for the field:
           rules: {
          userEmail :{
               required: true,
               email: true,
               remote: "<?=base_url()?>user/checkUserEmail" //here i am calling controller name
                        }
                  },


       messages: {
      userEmail:{
         required: "Please enter your email",
         email: "Email must be in the format of name@domain.com",
          remote: "Email Id already exist"
                   }
                      };
-------------------------------------------------------------------------------------------------------------------
Controller:
       Add the following function in your Controller
               
          function checkUserEmail(){
      $userEmail = $this->input->get("userEmail");
       $count = $this->user_model->GetUser(array("userEmail"=>$userEmail));
       if(count($count) == 0){
echo "true"; //The User Email is not available.
          }
                            else{
echo "false"; //The User Email is already taken.
                  }
                                                 }
---------------------------------------------------------------------------------------------------------------------
Model:
       Add the following function in your model file
     function GetUser($options = array()){

if(isset($options['userEmail']))
$this->db->where('userEmail', strip_tags($options['userEmail']));


                                                   }


              


Codeigniter

Email availability checking in codeigniter.

Posted by Unknown  |  No comments


Email-ID:
            In View Page  Jquery validation for the field:
           rules: {
          userEmail :{
               required: true,
               email: true,
               remote: "<?=base_url()?>user/checkUserEmail" //here i am calling controller name
                        }
                  },


       messages: {
      userEmail:{
         required: "Please enter your email",
         email: "Email must be in the format of name@domain.com",
          remote: "Email Id already exist"
                   }
                      };
-------------------------------------------------------------------------------------------------------------------
Controller:
       Add the following function in your Controller
               
          function checkUserEmail(){
      $userEmail = $this->input->get("userEmail");
       $count = $this->user_model->GetUser(array("userEmail"=>$userEmail));
       if(count($count) == 0){
echo "true"; //The User Email is not available.
          }
                            else{
echo "false"; //The User Email is already taken.
                  }
                                                 }
---------------------------------------------------------------------------------------------------------------------
Model:
       Add the following function in your model file
     function GetUser($options = array()){

if(isset($options['userEmail']))
$this->db->where('userEmail', strip_tags($options['userEmail']));


                                                   }


              


04:47 Share:
Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top