Wednesday, May 14, 2014

HTML 5 number validation

HTML 5 number digit validator



<input type="number" id="r" size="20" name="r"  placeholder="Input value" pattern="[0-9]+([.][0-9]+)?" step="0.01" title="Enter Numeric Digit" />

pattern  =
step       =
title       =

validation of two Password Match

 

 Validation of two Password Match

 

I make a project and i want to match both password .

if password same then carry on ...

else abort . ...............................

 


example:


--------------

 

 

 
 
 
 
 
<script type="text/javascript">
function validate()
     {
        var pw1 = document.getElementById("password1").value;
        var pw2 = document.getElementById("password2").value;

        //Check values are present in both fields
        if(pw1 ==='' || pw2 === '')
        {
            alert("Please enter your password twice.");
            return false;
        }
        //Check there no spaces
        else if(document.getElementById("password1").value.indexOf(" ") > - 1) 
        {
            alert("Spaces are not allowed in passwords!");
            return false;
        }
        //Check passwords are the same
        else
        {
            if(pw1 !== pw2) 
            {
                alert("The passwords you entered were not the same. Please try again!");
                return false;
            }
            else
            {
                alert("Password accepted!");
                return true;
            }
        }

    }
 </script>
</head>

<body>
<form id="register">
    <label for="username">Username</label>
    <input type="text" class="input_text" name="username" id="name" placeholder="username" />
    <br />
    <label for="password">Password</label> 
    <input type="text" class="input_text" name="password1" id="password1" placeholder="123456" />
    <br />
    <label for="re-enterpassword">Re-enter password</label>
    <input type="text" class="input_text" name="password2" id="password2" placeholder="123456" />

    <input type="submit" class="button" onclick="validate()" value="Register" />
    </form>
</body>
</html>

Friday, May 2, 2014

bit bucket

Explore GIT


There is main problem in uploading the project on GIT.
 Many Technical student face problem to

how to upload 
how to create repository
how to push
how to pull

  1. Log into Bitbucket under your individual account.
  2. Click Repositories > Create repository or the Create new repository link.
  3. Choose a repository Owner.
    This only appears if you are creating under an account with membership in one or more teams. 
  4. Enter a Name and Description for your repository.
  5. Tick Private if you want to hide your repository from the general public, so that only selected people can see it.
  6. Select the Repository type.
  7. Click Create repository.
step1 :

Download GIT

Step 2:

create Account on GIT
bitbucket
github

step 3:

use these commands on CMD of Git


$ cd /C/ PATH TO FOLDER
$ git init
$ git add --all
$ git commit -m "adding repo instructions"
  


 commands >.>

mkdir /path/to/your/project 

cd /path/to/your/project 

git init 

git remote add origin ssh://git@bitbucket.org/username/bbreponame.git


Create a project with some code:

$ mkdir my_project
$ cd my_project
$ echo "foobar" > some_file

Then, while inside the project's folder, do an initial commit:
 
$ git init
$ git add some_file
$ git commit -m "Initial commit"

then for using bitbucket or such you add a remote and push up
 
$ git remote add some_name user@host:repo
$ git push some_name

you also might then want to configure tracking branches etc. see git remote set-branches and related commands for that.


Thursday, April 24, 2014

Implementation of Captcha in Javascript

Implementation of Captcha in Javascript 

captcha helps us in understanding and logical implentation of captcha on entirely client side.

Generating Captcha using client side scripting is quite a simple but make sure that the javascript is enabled. Anyways lets move towards the code details.
the source code is quite simple and straight forward.

Source Code

<html>
<head>
<title>Captcha</title>
    
    <script type="text/javascript">

   //Created / Generates the captcha function    
    function DrawCaptcha()
    {
        var a = Math.ceil(Math.random() * 10)+ '';
        var b = Math.ceil(Math.random() * 10)+ '';       
        var c = Math.ceil(Math.random() * 10)+ '';  
        var d = Math.ceil(Math.random() * 10)+ '';  
        var e = Math.ceil(Math.random() * 10)+ '';  
        var f = Math.ceil(Math.random() * 10)+ '';  
        var g = Math.ceil(Math.random() * 10)+ '';  
        var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' '+ f + ' ' + g;
        document.getElementById("txtCaptcha").value = code
    }

    // Validate the Entered input aganist the generated security code function   
    function ValidCaptcha(){
        var str1 = removeSpaces(document.getElementById('txtCaptcha').value);
        var str2 = removeSpaces(document.getElementById('txtInput').value);
        if (str1 == str2) return true;        
        return false;
        
    }

    // Remove the spaces from the entered and generated code
    function removeSpaces(string)
    {
        return string.split(' ').join('');
    }
    
 
    </script>
    
    
    
</head>
<body onload="DrawCaptcha();">
<table>
<tr>
    <td>
        Welcome To Captcha<br />
    </td>
</tr>
<tr>
    <td>
        <input type="text" id="txtCaptcha" 
            style="background-image:url(1.jpg); text-align:center; border:none;
            font-weight:bold; font-family:Modern" />
        <input type="button" id="btnrefresh" value="Refresh" onclick="DrawCaptcha();" />
    </td>
</tr>
<tr>
    <td>
        <input type="text" id="txtInput"/>    
    </td>
</tr>
<tr>
    <td>
        <input id="Button1" type="button" value="Check" onclick="alert(ValidCaptcha());"/>
    </td>
</tr>
</table>
</body>
</html> 
 
 

Saturday, April 5, 2014

How to UPLOAD image in Database

  there is main problem
how can i upload image in databse there is two way for uploading image in database

1.image uploading using blob
2.image uploading using folder


1.image uploading using blob

in this method  you have to create two files first upload.php and second is upload1.php.
upload.php

<form method="post" enctype="multipart/form-data">

<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">

<tr>

<td width="246">

<input type="hidden" name="MAX_FILE_SIZE" value="2000000">

<input name="userfile" type="file" id="userfile">

</td>

<td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>

</tr>

</table>

</form>





Upload1.php


<?php

if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)

{

$fileName = $_FILES['userfile']['name'];

$tmpName  = $_FILES['userfile']['tmp_name'];

$fileSize = $_FILES['userfile']['size'];

$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');

$content = fread($fp, filesize($tmpName));

$content = addslashes($content);

fclose($fp);

if(!get_magic_quotes_gpc())

{

    $fileName = addslashes($fileName);

}

include 'library/config.php';

include 'library/opendb.php';

$query = "INSERT INTO upload (name, size, type, content ) ".

"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($query) or die('Error, query failed');

include 'library/closedb.php';

echo "<br>File $fileName uploaded<br>";

}

?>

Tuesday, March 25, 2014

create a calandar using PHP

create a calandar using PHP


In this tutorial you will learn how to build your own web based calendar using PHP. This calendar is made you can use a plain text editing software such as Notepad.


calandar.php



<?php

$monthNames = Array("January", "February", "March", "April", "May", "June", "July", 

"August", "September", "October", "November", "December");

?>


First we need to check if we have set up our parameters already. If we have not, we set them to the current month and year. (For detailed explanation of date() function please refer to PHP Manual ).

<?php

if (!isset($_REQUEST["month"])) $_REQUEST["month"] = date("n");

if (!isset($_REQUEST["year"])) $_REQUEST["year"] = date("Y");

?>


Lets also set the variables that we are going to use in our calandar:

<?php

$cMonth = $_REQUEST["month"];

$cYear = $_REQUEST["year"];



$prev_year = $cYear;

$next_year = $cYear;

$prev_month = $cMonth-1;

$next_month = $cMonth+1;



if ($prev_month == 0 ) {

 $prev_month = 12;

 $prev_year = $cYear - 1;

}

if ($next_month == 13 ) {

 $next_month = 1;

 $next_year = $cYear + 1;

}

?>

<table width="200">

<tr align="center">

<td bgcolor="#999999" style="color:#FFFFFF">

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="50%" align="left">  <a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $prev_month . "&year=" . $prev_year; ?>" style="color:#FFFFFF">Previous</a></td>

<td width="50%" align="right"><a href="<?php echo $_SERVER["PHP_SELF"] . "?month=". $next_month . "&year=" . $next_year; ?>" style="color:#FFFFFF">Next</a>  </td>

</tr>

</table>

</td>

</tr>

<tr>

<td align="center">

<table width="100%" border="0" cellpadding="2" cellspacing="2">

<tr align="center">

<td colspan="7" bgcolor="#999999" style="color:#FFFFFF"><strong><?php echo $monthNames[$cMonth-1].' '.$cYear; ?></strong></td>

</tr>

<tr>

<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>

<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>M</strong></td>

<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>

<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>W</strong></td>

<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>T</strong></td>

<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>F</strong></td>

<td align="center" bgcolor="#999999" style="color:#FFFFFF"><strong>S</strong></td>

</tr>


// because we don't want our dates to start from 0.

 

<?php 

$timestamp = mktime(0,0,0,$cMonth,1,$cYear);

$maxday = date("t",$timestamp);

$thismonth = getdate ($timestamp);

$startday = $thismonth['wday'];

for ($i=0; $i<($maxday+$startday); $i++) {

 if(($i % 7) == 0 ) echo "<tr>n";

 if($i < $startday) echo "<td></td>n";

 else echo "<td align='center' valign='middle' height='20px'>". ($i - $startday + 1) . "</td>n";

 if(($i % 7) == 6 ) echo "</tr>n";

}

?>


// Now we add just the finishing touches of the html and we have finished the calendar.

</table>

</td>

</tr>

</table>

Monday, March 24, 2014

PHP Interview Questions.


 PHP Interview Questions.

 As PHP language is in trend nowadays that’s why all web developing companies give priority to those candidates who are good in PHP language. These companies hire the desired candidates who have a good knowledge of HTML language as well as PHP language & ask them the following PHP Interview Questions.

Frequently Asked PHP Interview Questions

What is PHP?
PHP is an open source scripting language which is widely used nowadays. The full form of PHP is Hypertext Pre-processor.

What is a PHP File?
Those files which contain text, HTML, JavaScript code, and PHP code are known as PHP files. The default file extension of PHP files is “.php”.

What is the current version of PHP, Apache, MySQL?
The current version of PHP is php 5.1.2, the current version of Apache is Apache 2.1 and the current version of MySQL is MySQL 5.1.

What are the uses of PHP language?
The main uses of PHP language are following:-
1. PHP language is used to generate dynamic page content.
2. Through PHP language user can create, open, read, write, and close files on the server.
3. User can collect form data through PHP language.
4. You can send and receive cookies with the help of PHP language.
5. User can add, delete and modify data in your database through PHP language.

Why we use PHP over other languages?
We use PHP language over other languages beacuse PHP language runs on different platforms like Windows, Linux, Unix, Mac OS X, etc. It is also compatible on all servers like Apache, IIS, etc.

In PHP language, what does a special set of tags <?= and ?> do?
The use of special set of tags in PHP language is to display the output of the program directly to the browser.

What is the common difference b/w include and require in PHP language?
In PHP language the functions include and require are used to handle the failures in a program. The common diffrence between include and require in PHP language is that in case of include function, if the file of any program is not found by include() then it shows a warning to the user but side by side the execution of the script will continue. In case of require function in PHP language, if the file of any program is not found by the rquire() then it shows a fatal error to the user and also it halt the execution of the script.

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide If you're looking to host a Laravel project on Hostinger’s hPa...