Wednesday 12 September 2012

enquiry form validation using javascript


<html>
<head>
         <script language="JavaScript" type="text/JavaScript">
function Validate()
{
 var sName=document.frmContact.txtName.value;
 var stxtPhone=document.frmContact.txtPhone.value;

 var sEmail=document.frmContact.txtEmail.value;
 var sComments=document.frmContact.txtComments.value;

 if(sName == "")
  {
    alert("Please provide your name");
document.frmContact.txtName.focus();
return false;
  }
  if(stxtPhone!= ""){
  if(isNaN(stxtPhone)){

alert("Please Enter Valid Number");
document.frmContact.txtPhone.focus();
return false;
}
  }else{
      alert("Please Enter your Phone Number");
      document.frmContact.txtPhone.focus();
 return false;
  }

 if(sEmail == "")
  {
    alert("Please provide your email");
document.frmContact.txtEmail.focus();
return false;
  }
  var regex = /^[a-zA-Z0-9_.]+@([a-zA-Z0-9_.]+\.)+[a-zA-Z0-9.-]{2,3}$/;
  match = regex.test(sEmail)
  if(! match)
   {
     alert("Invalid email, please provide valid email");
     document.frmContact.txtEmail.focus();
     return false;  
   }
   
    if(sComments =="")
   {
    alert("Please provide your comments");
     document.frmContact.txtComments.focus();
     return false;    
   }
   if(document.frmContact.captcha_code.value != document.frmContact.txtSecCode.value){
alert("Security code doesnot match. Please enter valid security code.");
document.frmContact.txtSecCode.focus();
return false;
}
return true;
}
</script>

</head>
<body>
<form method="post" action="" name="frmContact" id="frmContact" onSubmit="return Validate()">

        <table width="90%"  border="0" cellpadding="0" cellspacing="1" class="text">
         <tr>
            <td colspan="3" height="5" align="left" valign="middle" class="white_text"></td>
            </tr>
 
            <tr>
            <td width="33%" height="25" align="left" valign="middle" class="green"><span class="mandatory">*&nbsp;</span>Name</td>

<td width="6%" align="left" valign="middle" class="white_text">:</td>
                <td width="61%" align="left" valign="middle"><input name="txtName" type="text" class="forTextfield" size="30" maxlength="50"/></td>
            </tr>
            <tr>
            <td height="25" align="left" valign="middle" class="green"><span class="mandatory">*&nbsp;</span>Phone</td>
<td width="6%" align="left" valign="middle" class="white_text">:</td>

           <td align="left" valign="middle"><input name="txtPhone" type="text" class="forTextfield" size="30" maxlength="15"/></td>
            </tr>

            <tr>
            <td height="25" align="left" valign="middle" class="green"><span class="mandatory">*&nbsp;</span>Email</td>

<td width="6%" align="left" valign="middle" class="white_text">:</td>
                <td align="left" valign="middle"><input name="txtEmail" type="text" class="forTextfield" size="30" maxlength="50"/></td>
            </tr>
            <tr>
           <td align="left" class="green" valign="middle"><span class="mandatory">&nbsp;</span> Address</td>
<td width="6%" class="white_text" align="left" valign="middle">:</td>

           <td align="left" valign="middle"><textarea name="txtAddress" rows="2" cols="25" class="forTextfield"></textarea></td>
            </tr>
<tr>
           <td align="left" class="green" valign="middle"><span class="mandatory">*&nbsp;</span>Enquiry</td>
<td width="6%" class="white_text" align="left" valign="middle">:</td>

           <td align="left" valign="middle"><textarea name="txtComments" rows="2" cols="25" class="forTextfield"></textarea></td>
            </tr>
           
           
            <tr>
              <td colspan="2" align="left" valign="middle">&nbsp;</td>
              <td height="60" align="left" valign="middle"><img src="captcha/CaptchaSecurityImages.php?width=100&height=40&characters=5" />
                <input type="hidden" name="captcha_code" value="<?=$_SESSION['code']?>"></td>
            </tr>
            <tr>
              <td align="left" valign="middle" class="green">Security Code</td>
              <td align="left" valign="middle" class="white_text">:</td>
              <td align="left" valign="middle"><input type="text" name="txtSecCode" class="forTextfield" id="txtSecCode"></td>
            </tr>
            <tr>
              <td colspan="2" align="left" valign="middle">&nbsp;</td>
              <td align="left" valign="middle">&nbsp;</td>
            </tr>
            <tr>
           <td colspan="2" align="left" valign="middle">&nbsp;</td>

           <td align="left" valign="middle"><input name="hid_submit" type="submit" class="forButton" id="hid_submit" value="submit"></td>
            </tr>
        </table>
        </form>



</body>
</html>

Thursday 6 September 2012

php basic programs

<?php    // functions with the arguments

function myfun($var1,$var2)
{   
 $output= $var1*$var2;
 //echo "$output".'<br/>';
}
$one=myfun('10','5');
$two=myfun('6','9');

echo "$one".'<br/>';
echo "$two";

// local and global varables with their scopes

$name='3kits';
function fun1()
{
    global $name;
    echo "welcome to $name with in the function ".'<br/><br/><br>';   
}

fun1();
echo "welcome to $name from outside funtion "."<br><br>";

// Arrays declaration and the execution
echo "arrays "."<br>";
$cart_array=array("tea","coffee","Milk");

echo "$cart_array[0] "."FIRST ITEM"."<br>";
echo "$cart_array[1] "."SECOND ITEM"."<br>";
echo "$cart_array[2] "."THIRD ITEM"."<br>"."<br>";

//echo Serializable($cart_array);    //not working (result is fatal error)


$cart_array1[]="raju"."<br>";
$cart_array1[]="suman"."<br>";
$cart_array1[]="tarun";
$cart_array1[]="uday";

echo $cart_array1[0];
echo $cart_array1[1]."<br>";


// associate arrays
echo "associate arrays "."<br>";

$cart_array_assoc["raju"]="25";
$cart_array_assoc["suman"]="30";
$cart_array_assoc["uday"]="35";
$cart_array_assoc["varun"]="40"."<br>";

echo "age of raju:".$cart_array_assoc["raju"]."<br>";
echo "age of suman".$cart_array_assoc["suman"];
echo "other way of the assoc array declaration"."<br>";
$cart_array_assoc_secondway=array("tomoto"=>"3.00",
                                    "potato"=>"5.00",
                                    "beans"=>"10.00","sapotas"=>"12.00","bananas"=>"2.00"   
                                    );


echo "Bananas rate in the market is:".$cart_array_assoc_secondway["bananas"]."<br>";
print_r($cart_array_assoc_secondway); //will print the values in a single lined fashion

//var_dump($cart_array_assoc_secondway)."from the var_dump ariable ";   //will print like the formatted way like their size and the values in the line by lin

// multi dimensional arrays
echo "multi dimensional arrays"."<br>";

$cart_array_multidimen=array("member1" =>array("name"=>"raju",           
                                                "height"=>"5.7",
                                               "weight"=>"55"
                                               ),
                             "member2"=>array("name"=>"raju1",           
                                                "height"=>"5.7",
                                               "weight"=>"55"
                                              ),
                            "member3"=>array("name"=>"raju2",           
                                                "height"=>"5.7",
                                               "weight"=>"55"
                                             )
                            );
                           
echo count($cart_array_multidimen)."<br>";
print_r($cart_array_multidimen);

?>
<?php
$shop = array( array( Title => "rose",
                      Price => 1.25,
                      Number => 15
                    ),
               array( Title => "daisy",
                      Price => 0.75,
                      Number => 25,
                    ),
               array( Title => "orchid",
                      Price => 1.15,
                      Number => 7
                    )
             );
echo '<u><h2 align="center">flowers shopping cart</h2></u>';
echo "<h1>Manual access to each element from associative array</h1>";

for ($row = 0; $row < 3; $row++)
{
    echo $shop[$row]["Title"]." costs ".$shop[$row]["Price"]." and you get minimum ".$shop[$row]["Number"];
    echo "<br />";
}
    echo "<h1>Using foreach loop to display elements</h1>";
    echo "<ol>";   // default it will print the heading values like 1.  2.
for ($row = 0; $row < 3; $row++)   //the variable must start from zero only
{
    echo "<li><b>The row number $row</b>";
    echo "<ul>";
    foreach($shop[$row] as $key => $value)
    {
        echo "<li>".$value."</li>";
    }
    echo "</ul>";
    echo "</li>";
}
echo "</ol>";
?>
<!--arrays in the arithmetic operations -->
<?php
$myArray = array(500.00, 300.00, 200.00, 400.00);
$result = 0;
foreach ($myArray as $key => $value) {
    $result = $result + $value;
}
$output = number_format($result);

?>

<h2>Rs:<?php echo $output; ?></h2>

<?php
$file_x="my_file.txt";
$createFile=touch($file_x);
if(file_exists($file_x))
{
   
echo "file has been created ";
   
}else
echo "file has not been created";


$target_file = "my_file.txt";
// Here we define the string data that is to be placed into the file
$target_file_data = "This is the string data or code I want to place in the newly created file.";
// Here we are creating a file(since it does not yet exist) and adding data to it
$handle = fopen($target_file, "w");
fwrite($handle, $target_file_data); // write it
fclose($handle);
// Here we are opening and appending to the file
$handle = fopen($target_file, "a");
// Here we define the string data that is to be appended to the data already in file
$target_file_data = "Here is more data I want to append to the file.";
fwrite($handle, $target_file_data); // write it
fclose($handle);

// Here we display the file contents by including it
include($target_file);

?>

<?php
//to write the string in the red colored text have to use it.

highlight_string(
  '<?php
     echo "this is the 3kits india ltd ";
 ?>'
 );

?>

<?php
// html encode and decode

$original_input = "<strong><em>Hello World!</em></strong>";
echo $original_input."origanl data" ;
echo "
<hr />
";
$html_encoded = htmlentities($original_input);
echo $html_encoded."after encoding";
echo "
<hr />
";
$html_decoded = html_entity_decode($html_encoded);
echo $html_decoded."after decoding";
?>

Thursday 9 August 2012

Registration form creation in the html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DB Registration Page</title>

<script type="text/javascript">
function fun1()
{
  confirm("are you sure :");
}
</script>


</head>

<ul>
  <li>  <i>    <a href="add.php ">Add</a>     </i> </li>
  <li>  <i>    <a href="view.php"> View</a>   </i>   </li>
  <li>  <i>    <a href="edit.php"> Edit</a>   </i> </li>
</ul>

<body>

<table border="" cellpadding="2" align="center" bgcolor="#CCFFFF" style="text-align:left" >
<tr><td>
<p><strong> Registration form</strong></p></td></tr>

<form name="form1" method="post" action=" ">
<tr>    <td>       Username.   </td>    <td><input type="text" name="txtuser" placeholder="enter user name" />  </td></tr>
<tr>    <td>       Password.    </td>   <td><input type="password" name="txtpwd" placeholder="enter password" /> </td></tr>

<tr>    <td>       CPWord.    </td>   <td><input type="password" name="txtcpwd" placeholder="enter Cpassword" /> </td></tr>


<tr>   <td> Address.    </td>        <td><textarea name="txtaddress" cols="22" rows="3" placeholder="ex:hno:--- (v.name)---(mdl)---(pin)5000001
 etc.."></textarea></td>      </tr>
<tr>   <td>Email Id...  </td>       <td><input type="text" name="txtemailid" placeholder="ex:user@gmail.com" /></td>                    </tr>

<tr>   <td>
             Gender:
</td>
    <td><label>
        <input type="radio" name="gender" value="male" id="gender_0"  checked=""/>male</label>

             <label> <input type="radio" name="gender" value="female" id="gender_1" onfocus="gender" />female</label>
</td>
</tr>





<tr> <td> Languages Known :
     </td>
      <td>   <label><input type="checkbox" name="lang" value="eng" id="languagesknown_0"   /> English</label>

       <label> <input type="checkbox" name="lang1" value="Hin" id="languagesknown_1" /> Hindi</label>
 </td>
</tr>

<tr><td>Education Details:</td><td align="center">

<select name="dropdown" onchange="selectDropdown" >
  <option>Degree</option>
  <option>Intermediate</option>
  <option>Tenth</option>
</select>


</td></tr>

<tr>    <td align="left">    About You(1000)
        </td>

         <td>        <textarea name="about" cols="22" rows="3" placeholder="brief discription"></textarea>
</td>
</tr>

<tr>       <td></td>
           <td align="center">    <input type="submit" value="submit" name="btnsubmit" onclick="fun1()"/>
  </td>
</tr>
</form>
</table>
<br />


<?php
include("connect-db.php");


$username= $_POST["txtuser"];
$password1= $_POST["txtpwd"];
$address= $_POST['txtaddress'];
$emailid= $_POST['txtemailid'];
$gender= $_POST['gender'];
$language= $_POST['lang'].",".$_POST['lang1'];

$education=$_POST["dropdown"];

$about= $_POST['about'];





$user_name = "root";
$password = "";
$database = "raju";
$server = "127.0.0.1";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);

  if($db_found)
  {

$insertion=mysql_query("insert into registration(username,password,address,emaiid,gender,language,about,education)values('$username','$password1','$address','$emailid','$gender','$language','$about','$education')") or die(mysql_error());
       
  }
 
  echo "data inserted successfully";
 

?>
<a href=" view.php">view the details of the users</a>

<br />
<br/>


</body>
</html>

Wednesday 18 July 2012

imp html tags examples


Span tag : (is used to color a part of the text ):
 -----------------------------------------------


<html>
    <head>
    </head>

<body>

<p>my villages name is <span style="color:red;"/>  gowrelly</span> </p>



 html layouts:
----------------


 <div id="container" style="width:500px">

<div id="header" style="background-color:#FFA500;">
          <h1 style="margin-bottom:0;">Main Title of Web Page</h1>
</div>

<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>Menu</b><br />
   HTML<br />
   CSS<br />
   JavaScript
</div>

<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;">
Content goes here</div>

<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;">
Copyright © W3Schools.com</div>


</div>

Html Forms  :
------------
<table>
<form >

<tr> <td><colspan="5" >First name :<input type="text" name="First name " /></td></tr> <br/>
<tr><td>  Sur name : <input type="text" name="surname" /></td></tr><br/>
  <tr><td> desired<br/> username:<input type="text" name="user name "/></td></tr>  <br/>
 <tr><td>  password <input type="password" name="password" </td></tr>/>  <br/>
 <tr><td>  Gender <input type="radio" value="male" /></td></tr> <br/>
<tr><td>   Female <input type="radio" value="female" /></td></tr>
<tr><td>   Highest qualification<br/>
ssc<input type="checkbox" value="ssc" /></td></tr><br/>
        <tr><td> intermediate    <input type="checkbox" value="inter" /></td></tr><br/>
                <tr><td>  graduation   <input type="checkbox" value="graduation" /></td></tr><br/> 
               <tr><td>   post graduation   <input type="checkbox" value="post graduation" /></td></tr><br/>                      
<tr><td> <input type="submit" value="submit"/></td></tr><br/>
</form>
</table>


Iframes in html:
------------------

<iframe src="http://www.w3schools.com/html/html_iframe.asp" frameborder="10"/>

<iframe src="http://news.google.co.in/nwshp?hl=en&tab=wn" frameborder="5"/>
<FRAMESET ROWS="75%, *" COLS="*, 40%">
     <FRAME SRC="first.html">
     <FRAME SRC="second.html">

</FRAMESET>
</body>
</html>

basic html tags


<html>
<head>
 style in css Internal:
----------------------
<style type="text/css">

body {background-color:cyan ;}

p {color:green;}

</style>

 style in the css with External :
---------------------------------
<link rel="stylesheet" type="text/css" href="mystyle.css" />


</head>

<body>

 heading tags
------------------
<h1>this is the H1 heading tag   </h1>
<h2>This is the H2 heading tag   </h2>
<h3>This is the H3 heading tag   </h3>
<h4>This is the H4 heading tag   </h4>
<h5>This is the H5 heading tag   </h5>
<h6>This is the H6 heading tag   </h6>

 paragraph tags  and multi lined comment in the html
----------------------------------------------------

<p> This is the paragraph tag  </p><hr/>

<p>
<! this is the comment tag of html>
this is the comment tag
</p>


 anchor ttag and break tags:
----------------------------

<br><a href="http://www.w3schools.com"> this is the the link to w3schools</a></br>
<a href="http://www.php.net" target="_blank">this is the link to php website</a><br>

<a href="http://images.google.com/search?num=10&hl=en&site=&tbm=isch&source=hp&biw=1366&bih=667&q=roses&oq=roses&gs_l=img.3..0l10.6567.8105.0.10205.5.5.0.0.0.0.111.502.3j2.5.0...0.0...1ac.xvy1Ydd4FdA" >this the link to see the rose flowers</a>


<a name="tips" > </a>
<a href="#tips">Visit the Useful Tips Section</a>

 Image tag and attributes:
--------------------------

<img src="C:/Users/Public/Pictures/Sample Pictures/penguins.jpg"  alt="unable to find the source" width="104" height="100"/>


inline css styles:
-------------------

<h4 style="background-color:red;">This is a heading</h4>
<p  style="background-color:green;">This is a paragraph.</p>
<p style="font-family:arial;color:red;font-size:20px;"> A Paragraph</p>
<p style="font-family:timesnewroman;font-size:30px;color:cyan;" >this is one more paragraph </p>

 table format :
 ---------------
<table border="3">
<tr><thead>
        <th> company name  </th>
        <th> Address       </th>
        <th> contact no   </th>
   <thead>
</tr>
<tr> 
      <td> 3kits        </td>
      <td> kpally       </td>
      <td>12345 </td>  
</tr>
<tr>

<td>mavin </td>
        <td>madhapur </td>
<td>456789 </td>

</tr>
</table>


 unordered list and Ordered list &Definition lists :
 -----------------------------------

<ul>
<li>Coffeee   </li>
<li>Milk      </li>
<li>Juice     </li>
</ul>

<ol>
<li>  school   </li>
<li>  College  </li>
<li>  University </li

</ol>
<dl>
<dt>Coffee </dt>
<dd>Black hot drink </dd>
<dt>Milk </dt>
<dd>White cold drink </dd>

</dl>
</body>

</html>