Tuesday, April 29, 2014

Password reset using PHP and Mysql

In this article i am going to explain how to reset password using PHP,Mysql.

There are many methods available for password reset.In this i have used php email function to reset the password.I have used both $_POST and $_GET method for this.

If not registered user entered email address it shows error,if email was exists in database shows success message and sent mail with reset link.

The email contains reset link the user.if you click the link it will go to  password reset page.





Functionality files:

1.forgotpassword.php
2.resetpassword.php

In this you will learn the following things.

1.Send mail using PHP
2.UPDATE Query

Form

 <form name="forgotpwdform" action="#" method="post">
          <h3><a href="#" title="Forgot Password">Forgot Password</a></h3>
          <label>Email</label>
          <input type="email" name="Email" required/>
          <p>
            <input type="submit" name="ForgotPassword" value="Submit" id="submit"/>
          </p>
        </form>

Mail function with reset option

      <?php
if(isset($_POST['ForgotPassword'])){

        $email=$_POST['Email'];
        //Query
        $Password=mysql_query("SELECT Password FROM users WHERE Email='$email'");
      
        $NumRows=mysql_num_rows($Password);
       
                     if($NumRows == '0') { 
                        echo 'Sorry..Your Email not found in our database. Please try again';
                        header('Location:forgotpassword.php');
                        exit();
 } else {
               
                $to=$email; //To Mail
                $subject="Password Assistance"; //Subject
                $headers = "From: yourweb@website.in\r\n";
                $headers .= "MIME-Version: 1.0\r\n";
                $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
                $headers .= "X-Priority: 1\n";
                $headers .= "X-MSmail-Priority: High\n";
                $headers .= "X-Mailer: PHP". phpversion() ."\r\n" ;
           
            //Message
            $message = " Hi ,\r\n";
            $message .= "To initiate the password reset process for your $Email Account, click the link below:\r\n";
            $message .= "http://www.yourwebsite.com/resetpassword.php?Email=$email\r\n";
            $message .= "Cheers,\r\n";
            $message .= " Team\n\n";
         
            //Mail Script
            $sentmail=mail($email, $subject, $message,$headers);
        }
                       
    if($sentmail) {
        echo 'Your Password reset link Has Been Sent To Your Email Address.Please check your Inbox!';
        header('Location:forgotpassword.php');
        exit();
 }  else {

         echo 'Error.Please try again!';
         header('Location:forgotpassword.php');
        exit();
         }
    }
?>

Password Reset Form

<form accept-charset="UTF-8"  name="ProfileUpdate"  method="post" action="#" id="reset-form" style="width:590px">
          <h3>Reset Password</h3>
          <div >
            <div>
              <label>New Password</label>
            </div>
            <div>
              <input type="password" name="Password1"  id="Password1" class="user-text" />
            </div>
          </div>
          <div>
            <div>
              <label>Confirm New Password</label>
            </div>
            <div >
              <input type="password" name="Password2" id="Password2" class="user-text1"/>
            </div>
          </div>
          <div>
            <p>
              <input type="submit" name="ResetPassword" value="Submit"  id="submit" />
            </p>
          </div>
        </form>

Reset function in PHP

 <?php
//Database config
$connection=mysql_connect("localhost","root","");
$db=mysql_select_db("campustiger",$connection);

// Check connection
if (!$connection) {
    die('Could not connect: ' . mysql_error());
}

if(isset($_POST['ResetPassword'])) {

     $currentpassword = $_POST['Password']; // get the current password from                                                                   
     $newpassword = $_POST['Password1']; // get the new password from the                                                                       
     $hash = md5($newpassword); // encrypt the current password supplied by the user
                                                          
     $email = $_GET['Email'];
     $result = mysql_query("SELECT Password from users  where Email='$email'");  // query the database for getting password for a the user.

     while($row = mysql_fetch_array($result)) {
         $p=$row['Password'];
     }
    // get the encrypted password from the database for the user
     ?>
      <?php                                    

           $result = mysql_query("UPDATE users set Password='$hash' where Email='$email' ");
          
           if($result) {
                     header('Location:login.php');
         }
         else {
                    echo 'OOPS!.Please try again';
                    header('Location:resetpassword.php');
                    exit();
 }
    }
?>
Please share your comments and feedback.Thanks.

Monday, April 28, 2014

Facebook style comment Using PHP and Jquery

Hi friends.My friends are asked to me how to create facebook style comment .Thats why i have wrote this article.I have used PHP and Javascript to add comment.Let's have a look.

In this you will learn the following things:

1.SESSION
2.Ajax Method(GET)

Functionality Files:
1. index.php


HTML Code

<div class="container">
  <div class="content">
    <div id="commentscontainer">
      <div class="comments clearfix">
        <div class="pull-left lh-fix"> <img src="img/default.gif"> </div>
        <div class="comment-text pull-left"> <span class="color strong"><a href="#">Vinoth</a></span> &nbsp;Hello Friends <span class="info"><abbr class="time" title="2014-04-024T21:50:03+02:00"></abbr></span> </div>
      </div>
      <div class="comments clearfix">
        <div class="pull-left lh-fix"> <img src="img/default.gif"> </div>
        <div class="comment-text pull-left"> <span class="color strong"><a href="#">Code Innovators</a></span> &nbsp;What's up?? <span class="info"><abbr class="time" title="2014-04-024T21:50:03+02:00"></abbr></span> </div>
      </div>
    </div>
    <div class="comments clearfix">
      <div class="pull-left lh-fix"> <img src="img/default.gif"> </div>
      <div class="comment-text pull-left">
        <textarea class="text-holder" placeholder="Write a comment.." id="message"></textarea>
      </div>
    </div>
  </div>
</div>


jQuery Code

<script type="text/javascript">
    $(document).ready(function() {
var msg = '#message';

$('.time').timeago();
$(msg).autosize();

$('#post_comment').click(function() {
$(msg).focus();
});

$(msg).keypress(function(e) {
if(e.which == 13) {
var val = $(msg).val();

$.ajax({
url: 'php/ajax.php',
type: 'GET',
data: 'token=<?php echo $token; ?>&msg='+escape(val),
success: function(data) {
$(msg).val('');
$(msg).css('height','14px');
$('#commentscontainer').append(data);
$('.time').timeago();
}
});
}
});

$('#like_post').click(function() {
var count = parseFloat($('#count').html()) + 1;
if(count > 1) {
$('#if_like').html('You and');
$('#people').html('others');
} else {
$('#if_like').html('You like this.');
$('#likecontent').hide();
}

$('#like_post').hide();
$('#unlike_post').show();
});

$('#unlike_post').click(function() {
var count = parseFloat($('#count').html()) - 1;
if(count < 1) {
$('#likecontent').show();
}
$('#unlike_post').hide();
$('#like_post').show();
$('#if_like').html('');
$('#people').html('people');
});
});
</script>
Please share your comments and feedback.Thanks

Add Google reCAPTCHA to form

In this article i am going to explain how to add Google reCAPTCHA in website.





Please find the below steps:

Step 1 : Go to this website
Step 2: Click Get reCAPTCHA button
Step 3: Click sign up now button
Step 4: Login with your Google Account
Step 5: Enter your domain name and click create button.

Step 6 :Get your public and Private keys,

Step 7: Download library files form this link

Step 8 : Sample PHP form with library file.

Sample Form

      <form action="" method="post">
<?php

require_once('recaptchalib.php');

// Get a key from https://www.google.com/recaptcha/admin/create
$publickey = "";
$privatekey = "";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
        $resp = recaptcha_check_answer ($privatekey,
                                        $_SERVER["REMOTE_ADDR"],
                                        $_POST["recaptcha_challenge_field"],
                                        $_POST["recaptcha_response_field"]);

        if ($resp->is_valid) {
                echo "You got it!";
        } else {
                # set the error code so that we can display it
                $error = $resp->error;
        }
}
echo recaptcha_get_html($publickey, $error);
?>
    <br/>
    <input type="submit" value="submit" />
    </form>

Step 9: Enter your keys and library files in the form.Now check.

Please share your comments and feedback.Thanks.

Thursday, April 24, 2014

Simple search using PHP and Mysql

In this article i am going to explain how to search values using PHP,Mysql.

In this you will learn the following things:

1.$_POST Method
2.Databse Connection
3.Communication between Database and PHP
4.Fetch results from datbase and display.



Functionality Files:

1.Search.php
2.conn.php


Database Connection

   <?php
          $conn=mysqli_connect("localhost","root","","search") or die('Error connection');
        /*Hostname = "localhost".Replace with your hostname*/
         /*Databse Username="root".Replace with your Username*/
         /*Databse Password="".Replace with your Password*/
         /*Databse Name="search".Replace with your database name*/

    ?>

Search.php

     <?php
  $conn=mysqli_connect("localhost","root","","search") or die('Error connection');
  $search_results = '';
  if(isset($_POST['search']))
  {
    $str = $_POST['search'];
    $str = preg_replace("#[^0-9a-z]#i","",$str);
    $query = "SELECT UserName FROM users WHERE UserName LIKE '%$str%'";
    $result = mysqli_query($conn,$query);
    $count = mysqli_num_rows($result);
    if($count>0)
    while($row = mysqli_fetch_array($result))
      {
        $search_results = $search_results."<div>".$row['UserName']."</div>";
      }
  }

?>
    <form action="#" method="post">
      <input type="text" name="search" />
      <input type="submit" value="search"/>
    </form>
    <?php if(isset($_POST['search'])) { ?>
    <h2>Search Results:</h2>
    <?php echo $search_results; ?>
    <?php } ?>
Please share your comments and feedback.Thanks.

Display facebook like button on website

Today i am going to show how to add facebook like button in website.
Facebook share and likes are very important for websites and blogs.We can easily integrate like button in website.



Please find the below steps.

Let's take a look.
Step 1: Please click this link

Step 2: Please enter your URL in URL to Like box and customize your like box style,width.
Step 3: Click Get Code Button.
Step 4: Copy & paste the code in your Web page.

Please share your comments and feedback.Thanks.

Tuesday, April 22, 2014

File Upload Progress bar using PHP and Jquery

In this article i am going to shows how to upload file with progress bar.

I have used PHP,Jquery to upload a file.

Functionality Files:

1.Index.php
2.Upload.php




HTML Code

    <div style='width:900px;margin:auto'>
      <h1> File Upload Progress bar using PHP and Jquery </h1>
      <form action="upload.php" method="post" enctype="multipart/form-data">
        <input type="file" name="uploadedfile" required>
        <br>
        <input type="submit" name="Upload" id="upload" value="Upload File">
      </form>
      <div class="progress">
        <div class="bar"></div >
        <div class="percent">0%</div >
      </div>
      <div id="status"></div>
    </div>

Jquery Files

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
      <script src="http://malsup.github.com/jquery.form.js"></script>
      <script>
 (function() {
 var bar = $('.bar');
 var percent = $('.percent');
 var status = $('#status');
 $('form').ajaxForm({
   beforeSend: function() {
     status.empty();
     var percentVal = '0%';
     bar.width(percentVal)
     percent.html(percentVal);
   },
   uploadProgress: function(event, position, total, percentComplete) {
     var percentVal = percentComplete + '%';
     bar.width(percentVal)
     percent.html(percentVal);
   },
   complete: function(xhr) {
     bar.width("100%");
     percent.html("100%");
     status.html(xhr.responseText);
   }
 }); 
 })();    
 </script>

PHP Code

      <?php
 if(isset($_POST['submit']))
 {
 $upload_dir = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']);
 $upload_url = '/';
      $temp_name = $_FILES['uploadedfile']['tmp_name'];
      $file_name = $_FILES['uploadedfile']['name'];
      $file_path = $upload_dir.$upload_url.$file_name;
      if(move_uploaded_file($temp_name, $file_path))
      {
           echo "File uploaded Success !";
      }
}
?>
Please share your comments and feedback.Thanks.!

Monday, April 21, 2014

Top 5 HTML5 web frameworks

In this article i am going to show top 5 user interface tools for web projects.

UI  framework List

1.Kendo UI
2.Twitter Bootstrap
3.Brick UI
4.Metro UI
5.UI Kit Maker



Kendo UI:

Kendo UI is HTML5 based web framework .It is used to create HTML applications.Kendo UI combines HTML5,CSS3 and Javascript.
View Demo & Download

UI Kit Maker:

UI Kit Maker is contains many css components,we can create quality websites not much effort using UI Kit.

View Demo & Download

Brick UI;

Brick UI is a collection  of re-usable web components.It is used to create HTML5 web applications and Mobile applications.It is used to create mobile friendly websites.
 View Demo & download

Metro UI:

Metro UI is a set of styles is used to create website like windows 8 type websites.It can used to along with other frameworks.

It contains many features;
1.Live Titles
2.Slide shows
3.Sidebars
4.Mobile ready
etc.


View Demo & Download

5.Twitter Bootstrap

Twitter bootstrap is used to create mobile websites and responsive websites.It is allow users to customize style and all javascript.

View Demo & Download

Fatal error: Call to undefined function apc_fetch() in Joomla

Step 1:Open your configuration.php file.
Step 2:

Find Line

public $cache_handler = 'apc';

Replace with

public $cache_handler = 'file';

Step 3:Save and refresh the page.

 It works fine

Please share your comments.

Saturday, April 19, 2014

Disable previous date in date picker using jQuery

In this post we will discuss about hide previous dates using jQuery.

Before this we need to add library files and CSS files.

minDate is used to hide previous dates.If we set minDate:0 it will hide previous dates.



Demo

Date:

jQuery Files

      <link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="Stylesheet" type="text/css" />
      <script src="http://code.jquery.com/jquery-2.0.2.min.js" language="javascript"></script>
      <script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
      <script language="javascript">
    $(document).ready(function () {
        $("#previousdate").datepicker({
            minDate: 0 // this is used to hide previous date.
        });
    });
</script>
   

HTML code

 Date:       <input id="previousdate" type="text" class="Datepicker">
    

Send attachment in mail using php

Lets take a look about how to send attachment in mail using PHP

It is very important to send attachment in mail.



Functionality file:
1.Index.html
2.mail.php


HTML Code

<table cellspacing="0" cellpadding="0" border="0">
      <tbody>
        <tr>
          <td height="20" class="contacttxttitle" style="color:#990000; width:300px; font-family:Arial, Helvetica, sans-serif; font-size:16px;  padding:5px;"  colspan="2"> Enquiry Form </td>
        </tr>
      <form name="contactusform" action="mail.php" method="post" enctype="multipart/form-data">
        <tr>
          <td width="179" height="30" class="contactspl">Name :</td>
          <td width="271" height="30"><input type="text" size="30" id="uname_1" name="uname" required>
          </td>
        </tr>
        <tr>
          <td height="30" class="contactspl">Contact No :</td>
          <td height="30"><input type="tel" size="30" pattern="\d{10}" id="contact_1" name="contact" required>
          </td>
        </tr>
        <tr>
          <td height="30" class="contactspl">Email :</td>
          <td height="30"><input type="email" size="30" id="email_1" name="email" required>
          </td>
        </tr>
        <tr>
          <td height="30" class="contactspl">Message :</td>
          <td height="30"><textarea rows="4" cols="23" id="comment_1" name="comment" required></textarea>
          </td>
        </tr>
        <tr>
          <td height="30" class="contactspl">Resume :</td>
          <td height="30"><input type="file" name="fileAttach" required />
          </td>
        </tr>
        <tr>
          <td height="30" align="center" colspan="2"><input type="submit" value="Submit" id="submit" name="submit">
          </td>
        </tr>
      </form>
      </tbody>
   
    </table>

PHPCode

<?php if(isset($_POST['submit']))
{
$strTo ="test@gmail.com";//Replace with your mail
$strSubject ='Resume';
$cname = nl2br($_POST["uname"]);
$email = nl2br($_POST["email"]);
$contact = nl2br($_POST["contact"]);
$comment = nl2br($_POST["comment"]);
//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));
$strHeader = "";
$strHeader .= "From:
".$_POST["cname"]."<".$_POST["email"].">\nReply-To: ".$_POST["email"]."";
$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= "Name:".$cname."\n\n".'<br>';
$strHeader .= "Email Id:".$email ."\n\n".'<br>';
$strHeader .= "Contact Number:".$contact ."\n\n".'<br>';
$strHeader .= "Message:".$comment ."\n\n";


//*** Attachment ***//
if($_FILES["fileAttach"]["name"] != "")
{
$strFilesName = $_FILES["fileAttach"]["name"];
$strContent =
chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"])));
$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n";
$strHeader .= "Content-Transfer-Encoding: base64\n";
$strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
$strHeader .= $strContent."\n\n";
}

$flgSend = @mail($strTo,$strSubject,null,$strHeader);  // @ = No Show Error //
if($flgSend)
{
echo "Mail sent successfully";
}
else
{
echo "Error.Please try again";
}
}
?>

How to install Joomla3.0

In this article i am going to explain how to install Joomla3.0 in server.

Joomla is a CMS tools,is used to create web application very easily.




Joomla3.0 installation takes only 3 steps.

Download Joomla3.0 from this link.

Extract Zip folder and upload unzip files into your server.

Open your browser type this: http:localhost/joomla3 (For localhost)

Step 1: Configuration 
In this step you need to select your language,Site Name,Admin Email,Site description and admin password.

Step 2: Database Configuration

In this step you need to enter your database details.

If you are install in localhost try the following details:

Host name: Localhost
Username:root
Password: Leave empty
Database Name: your DB name

Click Next

Step 3: Finalisation

If you want sample data use the option install sample data.This will shows how the Joomla3.0 works and module details.
I strongly recommend for beginners to install sample data and try Joomla.


Click Next

Now Joomla3.0 was installed.Click Remove Installation button ,Don't forget.

Now start your customization in Joomla3.0.

Friday, April 18, 2014

Generate random string using Javascript

Hi friends.In this article i am going to show how to create random string using javascript

Using Onclick() event i have created random string.

Description:

Onclick event when user click an event or button.



HTML Code

  <table>
      <form id="form" action="#"  method="post" name="randform">
        <tr>
          <td class="text" height="34">Coupon Code <span style="color:#FF0000">*</span></td>
          <td>
            <input type="text" name="Coupon" required class="t-box1"/>
            &nbsp;
            <input type="button" value="Genereate Code" id="generate" onClick="randomString();" class="btn btn-primary"/></td>
        </tr>
      </form>
    </table>

Jquery Code

 <script language="javascript" type="text/javascript">
function randomString() { var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var string_length = 8;
var randomstring = '';
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
document.randform.Coupon.value = randomstring;
}
</script>

Please share your comments and feedback here.Thanks..!

Allow only numeric or numbers in textbox using Javascript

Hi friends.In this article i am going to show you how to allow numeric values only in textbox using Javascript.

Let's take a look.

Demo

Number:

Jquery Files

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
        $(function () {
        $('#phone_number').keydown(function (e) {
        if (e.shiftKey || e.ctrlKey || e.altKey) {
        e.preventDefault();
        } else {
        var key = e.keyCode;
        if (!((key == 8) || (key == 46) || (key >= 35 && key <= 40) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105))) {
        e.preventDefault();
        }
        }
        });
        });

</script>

HTML Code

<form action="#" method="post">
      <input type="text" name="name" id="phone_number"/>
    </form>


If you like this article please post your comments here.Thanks.!!

Thursday, April 17, 2014

Jquery Easy ticker

In this article i am going to explain how to add ticker in website using jquery.

Jquery is used to create many functionality for website.We need library files to perform this action.Please find the demo below.

Demo


Lorem Ipsum is simply dummy text of the printing and typesetting industry
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
Lorem Ipsum is simply dummy text of the printing and typesetting industry
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.
Lorem Ipsum is simply dummy text of the printing and typesetting industry
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.


HTML Code

<div class="test">
      <div>
        <div class="page-title"> <a href="#">Lorem Ipsum is simply dummy text of the printing and typesetting industry</a>
          <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. </p>
        </div>
        <div class="page-title"> <a href="#">Lorem Ipsum is simply dummy text of the printing and typesetting industry</a>
          <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. </p>
        </div>
        <div class="page-title"> <a href="#">Lorem Ipsum is simply dummy text of the printing and typesetting industry</a>
          <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. </p>
        </div>
      </div>
    </div>

CSS Code

<style type="text/css">
    .test{border:1px solid #ccc; padding:10px}
    .page-title{ padding:10px; border-bottom:1px solid #ccc}
</style>

Jquery Files

   <script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>
    <script type="text/javascript" src="http://vaakash.github.io/jquery/easy-ticker.js"></script>
    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
    <script type='text/javascript'>//<![CDATA[
    $(function(){
    $('.test').easyTicker({
        direction: 'up' //you can change direction down and up
    });
    });//]]> 
   
    </script>

Please share feedback and comments.Thanks!!

Submit Website URL in Google Search Engine Database

Hi Friends.In this am going to explain how to submit a website in google search engine.




Please find the below steps:

Step 1: Login into webmaster account using your google account

Step 2:Click Add site button
Step 3:Add your website URL

Step 4:Select your verification method 
Step 5: Copy meta tag from your verification method.I am using HTML verification method

Step 6:Add Verification code before </head> tag.

Step 7 : Save and upload in server
Step 8 : Click verify button form your account

Now your website will appear in google search engine.

Please share your comments and feedback.Thanks!!

Most Popular Programming Languages of 2014

Let's take a look about most popular programming languages.I have found this article in http://blog.codeeval.com/codeevalblog/2014#.U0-bbaJrNcZ.For my blog readers i have added this article here.



Please post your valuable feedback and comments.Thanks!!

Tuesday, April 15, 2014

INSERT Values in Mysql table using php

In this post am going to explain how to write database connection and how to insert values in mysql table.Let's take a look .

Description

Insert values in mysql using php.it's very easy to insert values.
Functionality files:
1.Index.php
2.conn.php
3.insert.php


index.php

<div class="wrapContainer">
  <div class="codeContainer">
    <p class="Blue">
    <form id="formID" action="insert" name="registerform" method="pos">
      <p>
        <input type="text" name="name" value="" placeholder="Name"/>
      </p>
      <p>
        <input type="text" name="phonenumber" value="" "" placeholder="Phonenumber"/>
      </p>
      <p>
        <input type="text" name="address" value="" "" placeholder="Address"/>
      </p>
      <p>
        <input type="submit" name="submit" value=""/>
      </p>
    </form>
  </div>
</div>

conn.php

  
  <?php
$conn=mysql_connect("localhost","root","")or die('Database not connected');
$db=mysql_select_db("Your Database")or die('Database not connected');
?>



insert.php

  <?php
if(isset($_POST['submit']))
{
$name=$_POST['namename'];
$number=$_POST['phonenumber'];
$address=$_POST['address'];
$insert=mysql_query("insert into ddtable(name,number,address)values('$name','$number','$address')");
}
?>

Share your website on social networks

Description

It is very important to share website in social networks like facebook,twitter etc.It became very easy to share website.

You can customize your social networks.Click here to customize.

Share Code

Use the following code to share website.Copy nad paste the following code on your website.

<h3 class="syntax">Share Code</h3>
<div class="wrapContainer">
  <div class="codeContainer">
    <p class="Blue">
Use the following code to share website.Copy nad paste the following code on your website.
<!-- AddToAny BEGIN -->
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_dd" href="http://www.addtoany.com/share_save"></a>
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_google_plus"></a>
</div>
<script type="text/javascript" src="//static.addtoany.com/menu/page.js"></script>
<!-- AddToAny END -->
  </div>
</div>

Demo

Select/Deselect all using check box in jQuery

In this article am going to explain how to select/deselect multiple checkbox using jQuery.

HTML Code

<div class="wrapContainer">
  <div class="codeContainer">
    <p class="Blue">
    <table border="1">
  <tr>
    <th><input type="checkbox" id="selectall"/></th>
    <th>Cell phone</th>
    <th>Rating</th>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" class="case" name="case" value="1"/></td>
    <td>BlackBerry Bold 9650</td>
    <td>2/5</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" class="case" name="case" value="2"/></td>
    <td>Samsung Galaxy</td>
    <td>3.5/5</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" class="case" name="case" value="3"/></td>
    <td>Droid X</td>
    <td>4.5/5</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" class="case" name="case" value="4"/></td>
    <td>HTC Desire</td>
    <td>3/5</td>
  </tr>
  <tr>
    <td align="center"><input type="checkbox" class="case" name="case" value="5"/></td>
    <td>Apple iPhone 4</td>
    <td>5/5</td>
  </tr>
</table>
  </div>
</div>



Jquery Code

Need to include jQuery library function.Copy and paste the following jQuery code. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <SCRIPT language="javascript">
$(function(){

    // add multiple select / deselect functionality
    $("#selectall").click(function () {
          $('.case').attr('checked', this.checked);
    });

    // if all checkbox are selected, check the selectall checkbox
    // and viceversa
    $(".case").click(function(){

        if($(".case").length == $(".case:checked").length) {
            $("#selectall").attr("checked", "checked");
        } else {
            $("#selectall").removeAttr("checked");
        }

    });
});
</SCRIPT>

Demo

Cell phone Rating
BlackBerry Bold 9650 2/5
Samsung Galaxy 3.5/5
Droid X 4.5/5
HTC Desire 3/5
Apple iPhone 4 5/5

Datalist in HTML5

Syntax

The <datalist> is new tag introduced in HTML5.
The <datalist> tag is used to create an autocomplete feature for form input fields in websites.

Using <option> tag shows suggestion for users,when they start typing in input elements.



HTML Code

<div class="wrapContainer">
  <div class="codeContainer">
    <p class="Blue">
    <form action="#" method="get">
      <input list="languages" name="languages">
      <datalist id="languages">
        <option value="Java"></option>
        <option value="PHP"></option>
        <option value="HTML5"></option>
        <option value="Joomla"></option>
        <option value="Wordpress"> </option>
      </datalist>
      <input type="submit" value="Submit">
    </form>
    </p>
  </div>
</div>


Demo

Monday, April 14, 2014

how to set featured image as background wordpress

Syntax

Use the following to get image
    <?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<?php endif; ?>

 

CSS Code

Use this CSS code to add background image. 

<style type="text/css">style=background-image: url('<?php echo $image[0]; ?>')</style>

Display author name on post in Wordpress

Syntax

Use this function to display author name <?php the_author() ?>.

Thursday, April 10, 2014

Encrypt Password using md5() in PHP

Syntax

Description: Calculate the MD5 hash of the string. md5() is used to secure your password more secure.
$pwd="Vinoth";
md5($pwd);

HTML Code

<form name="encrypt" action="#" method="post">
  <p>
    <label for="Name">Name:</label>
    <input type="text" name="name" />
  </p>
  <p>
    <label for="password">Password:</label>
    <input type="password" name="password" />
  </p>
  <p>
    <input type="submit" name="submit" value="Encrypt" />
  </p>
</form>

PHP Code

<?php
if(isset($_POST['submit'])) {

$name=$_POST['name'];
$pwd=$_POST['password'];

//Before encryption
echo "Before Encryption : ".$pwd;
echo "<br>";
//After encryption
$encryptpwd=md5($pwd);
echo "After Encryption : ".$encryptpwd;

}
?>

How to Change the Default Excerpt Length in Wordpress

Steps to change excerpt length

We can easily change the excerpt length without plugin in wordpress.

Description:

The excerpt is summary or description of a post.

Steps:

1.In your wp-content->themes->Your-theme->functions.php add the below lines end of your file.
2.Add these lines
<?php

/* Change Excerpt length */
function custom_excerpt_length( $length ) {
   return 30;
}
add_filter('excerpt_length', 'custom_excerpt_length', 999 );

?>
3.Save your functions.php.

Wednesday, April 9, 2014

Mobile number validation in HTML5

HTML5 is very easy to validate input fields without javascript and jQuery.No need external library files to validate fields.

In this post iw ill expalin how to validate phone number using HTML5.

I have used patterns to validate phone number in below example.



Demo:
tel - Input type for Phone
required - is used to validate input field.

fadeToggle in jQuery Example


fadeToggle in jQuery

Description: Display or hide the matched elements by animating their opacity.

index.html

<p>I am <span>Something</span><span class="hidden">Something2</span> </p>



javascript files:

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
    $(document).ready(function() {

        // run the fade() function every 2 seconds
        setInterval(function(){
            fade();
        },2000);


        // toggle between fadeIn and fadeOut with 0.3s fade duration.
        function fade(){
            $("span").fadeToggle(300);
        }

    });
</script>

Css for fadeToggle:

<style>
.hidden {
    display:none;
}
span {
    position: absolute;
    left:45px;
    top:10px;
}
p {
    width:200px;
    padding:10px;
    position:relative;
}
</style>

The jQuery noConflict() Method

The noConflict() method releases the hold on the $ shortcut identifier, so that other scripts can use it.

Example:

<script type="text/javascript">
    var sa=jQuery.noConflict(); //define variable for conflict.replace $ symbol with your variable
    sa(document).ready(function() {

    });
</script>

sa = jQuery variable

Tuesday, April 8, 2014

Change Password Using PHP and MYSQL

Let's take a look how to change password using PHP and MYSQL

Create table using below sql commands:

CREATE TABLE IF NOT EXISTS `register` (
  `UserId` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(100) NOT NULL,
  `Email` varchar(100) NOT NULL,
  `Username` varchar(100) NOT NULL,
  `Password` varchar(100) NOT NULL,
  `activation` varchar(100) NOT NULL,
  PRIMARY KEY (`UserId`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Functionality files:
1.conn.php
2.change_password.php



Conn.php

<?php
$host = "localhost";
$user = "root";
$pass = "";
$db_name = "email"; //replace with your database name 
//database connection
$link = mysql_connect($host, $user, $pass);
$db=mysql_select_db($db_name);
?>

change_password.php

<?php
//Database Config File
require_once "conn.php";

if(isset($_POST['Submit'])){

$email=$_POST['email'];
$Password=$_POST['password'];
$newpassword=$_POST['newpassword'];
//Query for check user exits in database
$Password_update=mysql_query("SELECT Password FROM register WHERE Email='$email'");
while($row=mysql_fetch_array($Password_update)){
//fetch stored user password
$rowpassword=$row['Password'];
}
if($rowpassword != $Password){
//Check current password and entered password is correct
echo "You have entered wrong password.Enter correct current password";
}
else
{
$update_password=mysql_query("Update register SET Password='$newpassword' WHERE Email='$email'" ); //Update query for Password

if($update_password){
echo "Password changed successfully";//Success message
        }
else
{
echo "Error";
}
}
}

?>

<form action="#" id="register" method="post">
  <table border="0">
    <tbody>
      <tr>
        <td><label for="email">Email:</label>
        </td>
        <td><input id="email" maxlength="45" name="email" type="text" /></td>
      </tr>
      <tr>
        <td><label for="Current Pasword">Current Password:</label>
        </td>
        <td><input id="currentpassword" maxlength="45" name="password" type="password" />
        </td>
      </tr>
      <tr>
        <td><label for="password">New Password:</label></td>
        <td><input id="newpassword" maxlength="45" name="newpassword" type="password" /></td>
      </tr>
      <tr>
        <td><label for="password">Confirm Password:</label></td>
        <td><input id="confirmpassword" maxlength="45" name="confirmpassword" type="password" /></td>
      </tr>
      <tr>
        <td align="right"><input name="Submit" type="submit" value="Submit" /></td>
      </tr>
    </tbody>
  </table>
</form>