Thursday, September 12, 2013

Number Game

Number Game

Checks  weather the entered number is Lucky Number or not

Create a  NumberGame.php  file and add following code to it 


<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Vowel or Constant</title>
</head>
<body  bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Number Game</h1>
<form name="form1" action="NumberGame.php" method="POST" >
<table >
<tr>
 <td>Enter a Number between 40 to 50</td><td><input type="text" name="value1" maxlength="2" /></td></tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Result</td><td><?php 
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){ // this will not run for 1st time
$Value1=$_POST['value1']; // taking the value from textbox 
$rand_number=rand(40,50 );//1st parameter is to check the starting range and 2nd is to check the End range of Number
if($Value1 == $rand_number  ){//checking in both number are equal or not
echo "<h2>You Won!!!</h2>";
}else{
echo "$rand_number was the Lucky Numer..Hard luck!!<br /> Try again Later.";
}
}
?></td></font></tr>
</table
></form>
</div> 
</body>
</html>"e

Thursday, September 5, 2013

Check Vowel or Constant

Vowel or Constant

check the weather the entered Character is Vowel or Constant

Create a  VowelConstant.php  file and add following code to it 



<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> Vowel or Constant</title>
</head>
<body  bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Check It is Vowel or Constant</h1>
<form name="form1" action="VowelConstant.php" method="POST" >
<table >
<tr><td>Enter First Value</td><td><input type="text" name="value1" maxlength="1" /></td></tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Result</td><td><?php 
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){ // this will not run for 1st time
$Value1=$_POST['value1']; // taking the value from textbox 
if($Value1 =="a" || $Value1 =="e" || $Value1 =="i" ||$Value1 =="o" || $Value1 =="u" || $Value1 =="A" || $Value1 =="E" || $Value1 =="I" ||$Value1 =="O" || $Value1 =="U"  ){//checking in both lower and upper case
echo "$Value1 is a Vowel!!";
}else{
echo "$Value1 is a Constant!!";
}
}
?></td></font></tr>
</table
</form>
</div> 
</body>
</html>

Temperature Converter

Temperature converter 

change the Temperature  from Celsius to Fahrenheit and from Fahrenheit to Celsius  

Create a  temperature.php  file and add following code to it 

<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Temperature </title>
</head>
<body bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Temperature</h1>
<form name="form1" action="temperature.php" method="POST" >
<table >
<tr><td>Enter Temperature</td><td><input type="text" name="value1" /></td></tr>
<tr><td>Celsius to Fahrenheit  </td><td><input type="radio" name="temp" value="celTofar" /> 
</td>
</tr>
<tr><td>Fahrenheit to Celsius </td><td><input type="radio" name="temp" value="farTocel" /> </td>
</tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Changed Value  is :</td><td><?php 
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){
$Value1=$_POST['value1'];
$Source=$_POST['temp'];
if($Source=="farTocel"){
echo  $Value1 * 9/5 +32 ."`C";
}else{
echo  ($Value1-32) * 5/9 ."`F";
}
//echo $Value1." Total " .$Value2 .$operation;
}
?></td></font></tr>
</table
</form>
</div> 
</body>
</html>

Check Even Odd in php

Even od Odd

Check the given number is even or odd

Create a  EvenOdd.php  file and add following code to it 


<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Even or Odd </title>
</head>
<body bgcolor="lightgray">
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Check It is Even or Odd</h1>
<form name="form1" action="EvenOdd.php" method="POST" >
<table >
<tr><td>Enter First Value</td><td><input type="text" name="value1" /></td></tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><td>Result</td><td><?php 
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){ // this will not run for 1st time
$Value1=$_POST['value1']; // taking the value from textbox 
if($Value1 % 2==0){
echo "$Value1 is a Even Number!!";
}else{
echo "$Value1 is a Odd Number!!";
}
}
?></td></font></tr>
</table
</form>
</div>
</body>
</html>

Currency Converter

PHP assignment 

Create a currency Converter 

Create a  converter.php  file and add following code to it


<!Doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>converter </title>
</head>
<body>
<?php error_reporting(E_ALL^E_NOTICE)?>
<div align='Center'>
<h1>Converter</h1>
<form name="form1" action="converter.php" method="POST" >
<table >
<tr><td>Enter First Value</td><td><input type="text" name="value1" /></td></tr>
<tr><td>Source currency </td><td><select name="Source">  
<option value="Euro">Euro</option>
<option value="Dollar">Dollar </option>
<option value="Rupees">Rupees </option>
</select></td>
</tr>
<tr><td>Destination currency </td><td><select name="Destination">  
<option value="Euro">Euro</option>
<option value="Dollar">Dollar </option>
<option value="Rupees">Rupees </option>
</select></td>
</tr>
<tr><td colspan="2" align="Center"><input type="Submit" name="submit1" value="Calculate" /></td></tr>
<tr><font color="red"><td>Changed Value  is :</td><td><?php 
//echo $Value1." Total " .$Value2;
if(isset($_POST['submit1'])){
$Value1=$_POST['value1'];
$Source=$_POST['Source'];
$Destination=$_POST['Destination'];
if($Source== $Destination){
echo "Please Select Diff Choice!!";
}elseif($Source=="Dollar" && $Destination=="Rupees" ){
echo $Value1 /68;
}elseif($Source=="Rupees" && $Destination=="Dollar" ){
echo $Value1 *68;
}elseif($Source=="Euro" && $Destination=="Rupees" ){
echo $Value1 *0.011;
}elseif($Source=="Rupees" && $Destination=="Euro" ){
echo $Value1 /0.011;
}elseif($Source=="Dollar" && $Destination=="Euro" ){
echo $Value1 *0.76;
}elseif($Source=="Euro" && $Destination=="Dollar" ){
echo $Value1 /0.76;
}
//echo $Value1." Total " .$Value2 .$operation;
}
?></td></font></tr>
</table
</form>
</div> 
</body>
</html>

Calculator in php

PHP assingment

Create Simple arithmetic calculator with basic validation.


First create a calc.php file  and then add the following code to it 

Friday, June 24, 2011

Java Database Connection(JDBC) using SQL server 2005

Software required :
Jdk 1.2 or above
Microsoft SQL SERVER 2005 or above clients.

Steps for using JDBC - ODBC Bridge using Microsoft SQL SERVER 2005.

1)Create a DSN(User) with same name that is listed in jdbc uri.
Go to control panel --> Administrative tools --> Click Data Source(ODBC)



2) Click on Add and Select SQL SERVER (which is the last 1 in the list)



3)Click on finish. You will get the following dialog box.



I.)Enter DSN name in the Data Source Name text filed(this is most Important because You'll use just like Database name)
II.)Description is not mandatory(not used)
III.)To Enter Server of SQL Copy the SERVER name from Microsoft SQL Server 2005



IV.)AND Paste It in the Server DropDown List filed.



V.)Then Click NEXT



VI.) again Click NEXT



VII.)Select The CheckBoX




And Most Important Select The DATABASE You Want to
USE like I used HOTEL my Data Base in this Example.
For EX. You have database User
But whatever the Database You choose,You'll refer It with the DSN name you have given.
In this Example "User" is given as DSN name
VIII.) click the **NEXT** AND then Click Finish



IX.) A dialog Box Will appear like this



X.) click on Test Data Source
Result should be like this