Open Source Technologies - PHP Lab
Open Source Technologies - PHP Lab
NO:
DATE: USER AUTHENTICATION
AIM:
ALGORITHM:
Index.php:
<?php
/*
create database mysite default character set=utf16;
use mysite;
*/
// To avoid Undefined Index in var in PHP
error_reporting(E_ALL ^ E_NOTICE);
// Establish database connection and select the database
//$conn = mysqli_connect("localhost","root","");
//mysql_select_db("mysite",$conn);
// Activate the session information
$conn = mysqli_connect("localhost","root","","mysite");
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
session_start();
$message="";
if(isset($_POST["uid"]) && $_POST["uid"]!=NULL && isset($_POST["pwd"]) &&
$_POST["pwd"]!=NULL)
{
// Perform Actions
switch($_POST["useraction"])
{
case "Login":
$result = mysqli_query($conn,"SELECT * FROM users WHERE
username='" . $_POST["uid"] . "' and password = '". $_POST["pwd"]."'");
$row = mysqli_fetch_assoc($result);
if(is_array($row)) {
$_SESSION["uid"] = $row['username'];
$_SESSION["pwd"] = $row['password'];
header("Location: dashboard.php");
} else $message = "Invalid Username or Password!";
break;
case "Register":
if (strlen($_POST["uid"]) >= 5 && strlen($_POST["pwd"]) >= 5)
{
$sql="INSERT INTO users VALUES('".
$_POST["uid"]."','".$_POST["pwd"]."')";
if (mysqli_query($conn,$sql))
{
$_SESSION["uid"] = $_POST["uid"];
$_SESSION["pwd"] = $_POST["pwd"];
header("Location: dashboard.php");
}
} else $message = "Both username and password should have at
least 5 characters!";
break;
}
}
?>
<html>
<head>
<title>User Login</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<form name="frmUser" method="post" action="">
<table border="0" cellpadding="10" cellspacing="1" width="500" align="center">
<tr class="tableheader">
<td align="center" colspan="2">Enter Login Details</td>
</tr>
<tr class="tablerow">
<td align="right">User Name</td>
<td><input type="text" name="uid"></td>
</tr>
<tr class="tablerow">
<td align="right">Password</td>
<td><input type="password" name="pwd"></td>
</tr>
<tr class="tableheader">
<td align="center" colspan="2"><input type="submit" name="useraction"
value="Login">For Existing User<input type="submit" name="useraction"
value="Register">For New User</td>
</tr>
</table>
<div class="message"><?php if($message!="") { echo $message; } ?></div>
</form>
</body>
</html>
Dashboard.php:
<?php
// To avoid Undefined Index in var in PHP
error_reporting(E_ALL ^ E_NOTICE);
// Activate the session information
session_start();
if(!isset($_SESSION["uid"])) {
header("Location: index.php");
}
?>
<html>
<head>
<title>User Login</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<table border="0" cellpadding="10" cellspacing="1" width="500" align="center">
<tr class="tableheader">
<td align="center"><?php echo $_SESSION["uid"]; ?> Dashboard</td>
</tr>
<tr class="tablerow">
<td>
<?php
if($_SESSION["uid"]) {
?>
Welcome <?php echo $_SESSION["uid"]; ?>. Click here to <a href="logout.php"
tite="Logout">Logout.
<?php
}
?>
</td>
</tr>
</body>
</html>
Logout.php:
<?php
// Activate the session information
session_start();
// Remove the values associated with the session variables
unset($_SESSION["uid"]);
unset($_SESSION["pwd"]);
header("Location: index.php");
?>
Style.css:
.tableheader {
background-color: #95BEE6;
color:white;
font-weight:bold;
}
.tablerow {
background-color: #A7D6F1;
color:white;
}
.message {
color: #FF0000;
font-weight: bold;
text-align: center;
width: 100%;
}
INPUT/OUTPUT SCREEN:
EX.NO:
DATE: SHOPPING CART APPLICATION
AIM:
To develop a E-commerce application for Shopping Cart using PHP and MYSQL.
ALGORITHM:
Style.css
.product_wrapper {
float:left;
padding: 10px;
text-align: center;
}
.product_wrapper:hover {
box-shadow: 0 0 0 2px #e5e5e5;
cursor:pointer;
}
.product_wrapper .name {
font-weight:bold;
}
.product_wrapper .buy {
text-transform: uppercase;
background: #F68B1E;
border: 1px solid #F68B1E;
cursor: pointer;
color: #fff;
padding: 8px 40px;
margin-top: 10px;
}
.product_wrapper .buy:hover {
background: #f17e0a;
border-color: #f17e0a;
}
.message_box .box{
margin: 10px 0px;
border: 1px solid #2b772e;
text-align: center;
font-weight: bold;
color: #2b772e;
}
.table td {
border-bottom: #F0F0F0 1px solid;
padding: 10px;
}
.cart_div {
float:right;
font-weight:bold;
position:relative;
}
.cart_div a {
color:#000;
}
.cart_div span {
font-size: 12px;
line-height: 14px;
background: #F68B1E;
padding: 2px;
border: 2px solid #fff;
border-radius: 50%;
position: absolute;
top: -1px;
left: 13px;
color: #fff;
width: 14px;
height: 13px;
text-align: center;
}
.cart .remove {
background: none;
border: none;
color: #0067ab;
cursor: pointer;
padding: 0px;
}
.cart .remove:hover {
text-decoration:underline;
}
db.php
<?php
// Enter your Host, username, password, database below.
// I left password empty because i do not set password on localhost.
/*
use shoppingcart;
*/
$con = mysqli_connect("localhost","root","","shoppingcart");
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
?>
Index.php
<?php
// Activate the session information
session_start();
include('db.php');
$status="";
if (isset($_POST['code']) && $_POST['code']!="")
{
$code = $_POST['code'];
$result = mysqli_query($con,"SELECT * FROM `products` WHERE
`code`='$code'");
$row = mysqli_fetch_assoc($result);
$name = $row['name'];
$code = $row['code'];
$price = $row['price'];
$image = $row['image'];
$cartArray = array(
$code=>array(
'name'=>$name,
'code'=>$code,
'price'=>$price,
'quantity'=>1,
'image'=>$image)
);
if(empty($_SESSION["shopping_cart"])) {
$_SESSION["shopping_cart"] = $cartArray;
$status = "<div class='box'>Product is added to your cart!</div>";
}else{
$array_keys = array_keys($_SESSION["shopping_cart"]);
if(in_array($code,$array_keys)) {
$status = "<div class='box' style='color:red;'>Product is
already added to your cart!</div>";
} else {
$_SESSION["shopping_cart"] =
array_merge($_SESSION["shopping_cart"],$cartArray);
$status = "<div class='box'>Product is added to your cart!
</div>";
}
}
}
?>
<html>
<head>
<title>Simple Shopping Cart using PHP and MySQL - AllPHPTricks.com</title>
<link rel='stylesheet' href='css/style.css' type='text/css' media='all' />
</head>
<body>
<div style="width:700px; margin:50 auto;">
<?php
if(!empty($_SESSION["shopping_cart"]))
{
$cart_count = count(array_keys($_SESSION["shopping_cart"]));
?>
<div class="cart_div">
<a href="cart.php"><img src="cart-icon.png" />
Cart<span><?php echo $cart_count; ?></span></a>
</div>
<?php
}
<div style="clear:both;"></div>
<?php
if(!empty($_SESSION["shopping_cart"]))
{
$cart_count = count(array_keys($_SESSION["shopping_cart"]));
?>
<div class="cart_div">
<a href="cart.php">
<img src="cart-icon.png" /> Cart
<span><?php echo $cart_count; ?></span></a>
</div>
<?php
}
?>
<div class="cart">
<?php
if(isset($_SESSION["shopping_cart"])){
$total_price = 0;
?>
<table class="table">
<tbody>
<tr>
<td></td>
<td>ITEM NAME</td>
<td>QUANTITY</td>
<td>UNIT PRICE</td>
<td>ITEMS TOTAL</td>
</tr>
<?php
foreach ($_SESSION["shopping_cart"] as $product){
?>
<tr>
<td><img src='<?php echo $product["image"]; ?>' width="50"
height="40" /></td>
<td><?php echo $product["name"]; ?><br />
<form method='post' action=''>
<input type='hidden' name='code' value="<?php echo
$product["code"]; ?>" />
<input type='hidden' name='action' value="remove" />
<button type='submit' class='remove'>Remove Item</button>
</form>
</td>
<td>
<form method='post' action=''>
<input type='hidden' name='code' value="<?php echo
$product["code"]; ?>" />
<input type='hidden' name='action' value="change" />
<select name='quantity' class='quantity'
onChange="this.form.submit()">
<option <?php if($product["quantity"]==1) echo "selected";?>
value="1">1</option>
<option <?php if($product["quantity"]==2) echo "selected";?>
value="2">2</option>
<option <?php if($product["quantity"]==3) echo "selected";?>
value="3">3</option>
<option <?php if($product["quantity"]==4) echo "selected";?>
value="4">4</option>
<option <?php if($product["quantity"]==5) echo "selected";?>
value="5">5</option>
<option <?php if($product["quantity"]==6) echo "selected";?>
value="6">6</option>
<option <?php if($product["quantity"]==7) echo "selected";?>
value="7">7</option>
<option <?php if($product["quantity"]==8) echo "selected";?>
value="8">8</option>
<option <?php if($product["quantity"]==9) echo "selected";?>
value="9">9</option>
<option <?php if($product["quantity"]==10) echo "selected";?>
value="10">10</option>
</select>
</form>
</td>
<td><?php echo "$".$product["price"]; ?></td>
<td><?php echo "$".$product["price"]*$product["quantity"]; ?></td>
</tr>
<?php
$total_price += ($product["price"]*$product["quantity"]);
}
?>
<tr>
<td colspan="5" align="right">
<strong>TOTAL: <?php echo "$".$total_price; ?></strong>
</td>
</tr>
</tbody>
</table>
<?php
}else{
echo "<h3>Your cart is empty!</h3>";
header("Location: index.php");
}
?>
</div>
<div style="clear:both;"></div>
INPUT/OUTPUT SCREEN:
EX.NO:
DATE: ONLINE JOB PORTAL
AIM:
To develop an application for Job Web Portal using PHP and MYSQL database.
ALGORITHM:
<html>
<head>
<title>Sign Up Form</title>
</head>
<body>
<center>
<br>
<h1>Job Registeration Form</h1>
<br><br>
<form name="reg" action="add1.php" method="POST" >
<table>
<tr>
<td>Name :</td>
<td><input type="text" name="name" value="" required/></td>
</tr>
<tr>
<td>Father Name :</td>
<td><input type="text" name="father_name" value="" required/></td>
</tr>
<tr>
<td>Address :</td>
<td><input type="text" name="address" value="" required/></td>
</tr>
<tr>
<td>Gender :</td>
<td><select name="gender">
<option value="">Select Value</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</td>
</tr>
<tr>
<td>State :</td>
<td><select name="state">
<option value="">Select Value</option>
<option value="India">India</option>
<option value="America">America</option>
</td>
</tr>
<tr>
<td>City :</td>
<td><select name="city">
<option value="">Select Value</option>
<option value="Pollachi">Pollachi</option>
<option value="CBE">CBE</option>
</td>
</tr>
<tr>
<td>Date Of Birth :</td>
<td><input type="date" name="dob" value=""></td>
</tr>
<tr>
<td>Pincode :</td>
<td><input type="text" name="pin" value=""></td>
</tr>
<tr>
<td>Name of the Post :</td>
<td><select name="post">
<option value=""></option>
<option value="computer">Computer Operator & Pragramming Assistant</option>
<option value="desiger">Designer</option>
<option value="marketing">Marketing</option>
</select>
</td>
</tr>
<tr>
<td>Email ID :</td>
<td><input type="email" name="email" value="" /></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="psw" value="" /></td>
</tr>
<tr>
<td><input type="submit" value="Register" class="submit" name="submit"
id="submit" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
add.php
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
mysql> */
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// close connection
mysqli_close($link);
?>
Job.php
<!DOCTYPE html>
<html>
<head>
<title>Sign Up Form</title>
</head>
<body>
<center>
<br>
<h1>Available Job Information</h1>
<br>
<form name="job" action="" method="POST" >
<table>
<tr>
<td><b>ART PRODUCTION MANAGER</b>
<p>Art production managers or traffic managers oversee the production aspect of art to
improve efficiency and cost effectiveness. Art production managers supervise artists or
advise the supervisors of artists.
Creative directors and art directors often assume the role of art production managers,
especially when production cost is not a critical enough concern to designate a manager
for the specific role.</p>
<p><b>Experience:</b>0 - 2 Years.</p>
<p><b>Job Location:</b> Pollachi </p>
<p><b>Salary:</b> 10,000 /- Month.</p>
<input type="submit" value="Apply Now" class="submit" name="submit" /></td>
</tr>
<tr>
<td><b>BRAND IDENTITY DEVELOPER</b>
<p>Brand identity Developer or traffic managers oversee the production aspect of art to
improve efficiency and cost effectiveness. Brand identity Developer supervise artists or
advise the supervisors of artists.
Creative directors and art directors often assume the role of art production managers,
especially when production cost is not a critical enough concern to designate a manager
for the specific role.</p>
<p><b>Experience:</b>0 - 3 Years.</p>
<p><b>Job Location:</b> Pollachi </p>
<p><b>Salary:</b> 12,000 /- Month.</p>
<input type="submit" value="Apply Now" class="submit" name="submit" /></td>
</tr>
</table>
</form>
</center>
</body>
</html>
INPUT/OUTPUT SCREEN:
EX.NO:
DATE: ONLINE QUIZ APPLICATION
AIM:
To building online quiz website using PHP and MYSQL.
ALGORITHM:
Step 2: Create a database for storing participants name and score details.
Index.css
body {
background: url("bg.jpg");
background-size:100%;
background-repeat: no-repeat;
position: relative;
background-attachment: fixed;
}
/* button */
.button {
display: inline-block;
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
width: 500px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.title{
background-color: #ccc11e;
font-size: 28px;
padding: 20px;
}
.button3 {
border: none;
color: white;
padding: 10px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button3 {
background-color: white;
color: black;
border: 2px solid #f4e542;
}
.button3:hover {
background-color: #f4e542;
color: Black;
}
dbconfig.php
<?php
$con = mysqli_connect("localhost","root","","quizDb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
?>
Index.php
<!DOCTYPE>
<html>
<?php require 'dbconfig.php';
session_start(); ?>
<head>
<title>Technopoints Quiz</title>
<style>
body {
background: url("bg.jpg");
background-size:100%;
background-repeat: no-repeat;
position: relative;
background-attachment: fixed;
}
/* button */
.button {
display: inline-block;
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
width: 500px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.title{
background-color: #ccc11e;
font-size: 28px;
padding: 20px;
}
.button3 {
border: none;
color: white;
padding: 10px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button3 {
background-color: white;
color: black;
border: 2px solid #f4e542;
}
.button3:hover {
background-color: #f4e542;
color: Black;
}
</style>
</head>
<body><center>
<div class="title">Online Quiz Website</div>
<?php
if (isset($_POST['click']) || isset($_GET['start'])) {
@$_SESSION['clicks'] += 1 ;
$c = $_SESSION['clicks'];
if(isset($_POST['userans'])) { $userselected =
$_POST['userans'];
$result2 = mysqli_query($con,$fetchqry2);
} else {
$_SESSION['clicks'] = 0;
//echo($_SESSION['clicks']);
?>
<div class="bump"><br><form><?php if($_SESSION['clicks']==0){ ?> <button
class="button" name="start" float="left"><span>START QUIZ</span></button> <?
php } ?></form></div>
<form action="" method="post">
<table><?php if(isset($c)) { $fetchqry = "SELECT * FROM `quiz` where id='$c'";
$result=mysqli_query($con,$fetchqry);
$num=mysqli_num_rows($result);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC); }
?>
<tr><td><h3><br><?php echo @$row['que'];?></h3></td></tr> <?php
if($_SESSION['clicks'] > 0 && $_SESSION['clicks'] < 6){ ?>
<tr><td><input required type="radio" name="userans" value="<?php echo $row['option
1'];?>"> <?php echo $row['option 1']; ?><br>
<tr><td><input required type="radio" name="userans" value="<?php echo $row['option
2'];?>"> <?php echo $row['option 2'];?></td></tr>
<tr><td><input required type="radio" name="userans" value="<?php echo $row['option
3'];?>"> <?php echo $row['option 3']; ?></td></tr>
<tr><td><input required type="radio" name="userans" value="<?php echo $row['option
4'];?>"> <?php echo $row['option 4']; ?><br><br><br></td></tr>
<tr><td><button class="button3" name="click" >Next</button></td></tr> <?php }
?>
<form>
<?php if($_SESSION['clicks']>5){
$qry3 = "SELECT `ans`, `userans` FROM `quiz`;";
$result3 = mysqli_query($con,$qry3);
$storeArray = Array();
while ($row3 = mysqli_fetch_array($result3, MYSQLI_ASSOC)) {
if($row3['ans']==$row3['userans']){
@$_SESSION['score'] += 1 ;
}
}
?>
<h2>Result</h2>
<span>No. of Correct Answer: <?php echo $no = @$_SESSION['score'];
session_unset(); ?></span><br>
<span>Your Score: <?php echo $no*2; ?></span>
<?php } ?>
<!-- <script type="text/javascript">
function radioValidation(){
/* var useransj = document.getElementById('rd').value;
//document.cookie = "username = " + userans;
alert(useransj); */
var uans = document.getElementsByName('userans');
var tok;
for(var i = 0; i < uans.length; i++){
if(uans[i].checked){
tok = uans[i].value;
alert(tok);
}
}
}
</script> -->
</center>
</body>
</html>
INPUT/OUTPUT SCREEN:
EX.NO:
DATE:
ONLINE EXAMINATION WEBSITE
AIM:
To develop an online quiz web site using PHP and MYSQL.
ALGORITHM:
Home.php
<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
$_SESSION["name"] = $_POST["uname"];
header("Location: quiz.php");
}
?>
<!DOCTYPE html>
<html>
<body>
<script>
function check() {
var x = 0;
if(document.getElementById("q1c").checked == true)
{
x=x+1
}
if(document.getElementById("q2a").checked == true)
{
x=x+1
}
if(document.getElementById("q3d").checked == true)
{
x=x+1
}
if(document.getElementById("q4b").checked == true)
{
x=x+1
}
if(document.getElementById("q5d").checked == true)
{
x=x+1
}
alert ("Your Score is : " + x);
window.location.replace("home.php");
}
</script>
<div align="center">
<button style="background-color:green;padding: 15px 32px;cursor: pointer; color:white"
onclick="check()">SUBMIT</button>
</div>
<br><br>
<hr>
</body>
</html>
INPUT/OUTPUT SCREEN:
EX.NO:
DATE: ONLINE BANK APPLICATION
AIM:
Develop an application for simple online banking system
ALGORITHM:
Step 1: Start the process.
Step 2: Create a database for storing user account and bank transaction details.
Step 3: To connect the database to your front – end application by using
mysqli_connect( ) function.
Step 4: To sign-in or Login into the website.
Step 5: Verify the username and password by using search query.
Step 6: To perform various bank transactions like deposite, withdraw and check the
balance amount.
Step 7: Run the application.
Step 8: Stop the process.
Home.php:
<html>
<head>
<title>Home</title>
<script type="text/javascript">
function redirectToURL(btnId){
if(btnId=="login")
window.location.replace("login.php");
else if(btnId=="account")
window.location.replace("account.php");
}
</script>
</head>
<body align="center">
<br>
<h1 align="center">HOME PAGE</h1>
<h2 align="center">WELCOME TO E-BANKING SYSTEM</h2>
<h3 align="center">GAYATHRI NATIONAL BANK</h3>
<h4 align="center">POLLACHI,COIMBATORE,TAMIL NADU,INDIA.</h4>
$con = mysqli_connect("localhost","root","","bank");
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
session_start();
<!DOCTYPE html>
<html>
<head>
<title>LogIn</title>
</head>
<body>
<center>
<br>
<h1>USER LOGIN</h1>
<br><br>
<form name="frmlogin" action="" method="POST" >
<table>
<td>Email ID :</td>
<td><input type="email" name="email" value="" required/></td>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="psw" value="" required/></td>
</tr>
<tr>
<td><input type="submit" value="Login" name="useraction"/></td>
</tr>
</table>
<br>
Not registered yet <a href="account.php"> Click Here</a> to Create New Account.
</form>
</center>
</body>
</html>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$con = mysqli_connect("localhost","root","","bank");
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
session_start();
if($_SERVER["REQUEST_METHOD"] == "POST") {
// username and password sent from form
$uid = mysqli_real_escape_string($con,$_POST['email']);
$psw = mysqli_real_escape_string($con,$_POST['psw']);
$sql = "SELECT * FROM account WHERE eid = '$uid' and psw = '$psw'";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row['active'];
$count = mysqli_num_rows($result);
<script type="text/javascript">
function redirectToURL(btnId){
if(btnId=="home")
window.location.replace("home.php");
else if(btnId=="login")
window.location.replace("login");
else if(btnId=="account")
window.location.replace("account.php");
else if(btnId=="dep")
window.location.replace("deposite.php");
else if(btnId=="drop")
window.location.replace("withdraw.php");
else if(btnId=="bal")
window.location.replace("balance.php");
else if(btnId=="logout")
window.location.replace("logout.php");
}
</script>
</head>
<body>
<table align="right">
<tr>
<td align="right"><?php echo $_SESSION["uid"]; ?> <a
href="logout.php">LOGOUT</a></td>
</tr>
</table>
<br>
<h1 align="center">DASHBOARD</h1>
<h2 align="center">WELCOME TO E-BANKING SYSTEM</h2>
<h3 align="center">GAYATHRI NATIONAL BANK</h3>
<h4 align="center">POLLACHI,COIMBATORE,TAMIL NADU,INDIA.</h4>
</body>
</html>
Deposite.php:
<?php
// To avoid Undefined Index in var in PHP
error_reporting(E_ALL ^ E_NOTICE);
// Activate the session information
session_start();
if(!isset($_SESSION["uid"])) {
header("Location: login.php");
}
?>
<html>
<head>
<title>Deposite</title>
</head>
<body>
<form name="frm" action="depAdd.php" method="POST" >
<table align="right">
<tr>
<td align="right"><?php echo $_SESSION["uid"]; ?> <a href="dashboard.php">BACK
TO DASHBOARD</a></td>
</tr>
</table>
<br>
<h1 align="center">DEPOSITE MONEY</h1>
<h2 align="center">WELCOME TO E-BANKING SYSTEM</h2>
<h3 align="center">GAYATHRI NATIONAL BANK</h3>
<h4 align="center">POLLACHI,COIMBATORE,TAMIL NADU,INDIA.</h4>
<br><br>
<table align="center">
<tr>
<td>How much amount you like to deposite :</td>
<td><input type="text" name="user_amt" value="" required/></td>
</tr>
<tr>
<td><input type="submit" id="add" value="DEPOSITE MONEY" name="useraction"
/></td>
</tr>
</table>
</form>
</body>
</html>
depAdd.php:
<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
$con = mysqli_connect("localhost","root","","bank");
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
$email=mysqli_real_escape_string($con,$_SESSION["uid"]);
$sql = "SELECT * FROM account WHERE eid = '$email' ";
$result = mysqli_query($con,$sql);
$active = $row['active'];
$count = mysqli_num_rows($result);
if($count > 0) {
while($row = mysqli_fetch_assoc($result)) {
$amt=$row["amt"];
}
}else {
echo "0 results";
}
$uamt=mysqli_real_escape_string($con, $_REQUEST['user_amt']);
$add=($amt + $uamt);
<html>
<head>
<title>Withdraw</title>
</head>
<body>
<form name="frm" action="drop.php" method="POST" >
<table align="right">
<tr>
<td align="right"><?php echo $_SESSION["uid"]; ?> <a href="dashboard.php">BACK
TO DASHBOARD</a></td>
</tr>
</table>
<br>
<h1 align="center">WITHDRAW MONEY</h1>
<h2 align="center">WELCOME TO E-BANKING SYSTEM</h2>
<h3 align="center">GAYATHRI NATIONAL BANK</h3>
<h4 align="center">POLLACHI,COIMBATORE,TAMIL NADU,INDIA.</h4>
<br><br>
<table align="center">
<tr>
<td>How much amount you like to withdraw :</td>
<td><input type="text" name="user_amt" value="" required/></td>
</tr>
<tr>
<td><input type="submit" id="drop" value="WITHDRAW MONEY"
name="useraction" /></td>
</tr>
</table>
</form>
</body>
</html>
Drop.php:
<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
$con = mysqli_connect("localhost","root","","bank");
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
$email=mysqli_real_escape_string($con,$_SESSION["uid"]);
$sql = "SELECT * FROM account WHERE eid = '$email' ";
$result = mysqli_query($con,$sql);
$active = $row['active'];
$count = mysqli_num_rows($result);
if($count > 0) {
while($row = mysqli_fetch_assoc($result)) {
$amt=$row["amt"];
}
}else {
echo "0 results";
}
$uamt=mysqli_real_escape_string($con, $_REQUEST['user_amt']);
$drop=($amt - $uamt);
$sql = "UPDATE account SET amt=$drop WHERE eid='$email' ";
if(mysqli_query($con, $sql)){
header("Location: dashboard.php");
} else {
echo "ERROR: Could not able to execute $sql. " . mysqli_error($con);
}
mysqli_close($con);
?>
Balance.php:
<?php
// To avoid Undefined Index in var in PHP
error_reporting(E_ALL ^ E_NOTICE);
// Activate the session information
session_start();
if(!isset($_SESSION["uid"])) {
header("Location: login.php");
}
?>
<html>
<head>
<title>Withdraw</title>
</head>
<body>
<form name="frm" action="drop.php" method="POST" >
<table align="right">
<tr>
<td align="right"><?php echo $_SESSION["uid"]; ?> <a href="dashboard.php">BACK
TO DASHBOARD</a></td>
</tr>
</table>
<br>
<h1 align="center">WITHDRAW MONEY</h1>
<h2 align="center">WELCOME TO E-BANKING SYSTEM</h2>
<h3 align="center">GAYATHRI NATIONAL BANK</h3>
<h4 align="center">POLLACHI,COIMBATORE,TAMIL NADU,INDIA.</h4>
</form>
</body>
</html>
<?php
$con = mysqli_connect("localhost","root","","bank");
if (mysqli_connect_errno())
{
die("Failed to connect to MySQL: " . mysqli_connect_error());
}
$email=mysqli_real_escape_string($con,$_SESSION["uid"]);
$sql = "SELECT * FROM account WHERE eid = '$email' ";
$result = mysqli_query($con,$sql);
$active = $row['active'];
$count = mysqli_num_rows($result);
if($count > 0) {
while($row = mysqli_fetch_assoc($result)) {
$amt=$row["amt"];
}
}else {
echo "0 results";
}
echo "<br>";
echo "<br>";
echo "Your current Balance amount is : ".$amt;
mysqli_close($con);
?>
Logout.php:
<?php
// Activate the session information
session_start();
// Remove the values associated with the session variables
unset($_SESSION["uid"]);
unset($_SESSION["pwd"]);
header("Location: home.php");
?>
INPUT/OUTPUT SCREEN:
EX.NO: VALIDATION CONCEPT USING
DATE: ANGULARJS
AIM:
To develop and apply form validation concept using angularjs
ALGORITHM:
<body ng-app="formApp">
<div ng-controller="FormController">
<style type="text/css">
.css-form input.ng-invalid.ng-touched {
background-color: #FA787E;
}
.css-form input.ng-valid.ng-touched {
background-color: #78FA89;
}
</style>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
<script type="text/javascript" src="app.js"></script>
</body>
</html>
App.js:
var app = angular.module('formApp', []);
app.controller('FormController', function($scope) {
$scope.master = {};
$scope.save= function(employee) {
$scope.master = angular.copy(employee);
};
$scope.reset = function() {
$scope.employee = angular.copy($scope.master);
};
$scope.reset();
});
INPUT/OUTPUT SCREEN:
EX.NO:
SIMPLE NODE.JS PROGRAM
DATE: USING MODULES
AIM:
To develop a simple node.js program using modules.
ALGORITHM:
Myfirstmodule.js:
exports.myDateTime = function () {
return Date();
};
Demo_module.js:
var http = require('http');
var dt = require('./myfirstmodule');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write("The date and time is currently: " + dt.myDateTime());
res.end();
}).listen(8081);
INPUT/OUTPUT SCREEN:
EX.NO:
SIMPLE WEB-BASED EMAIL
DATE: SERVICE
AIM:
To develop an application for simple Web-Based Email Service using PHP and MYSQL.
ALGORITHM:
email.php
<?php
$from ="[email protected]";
$to = $mailid;
$message ="TEst Email";
$subject="subject";
$body ="";
$body .=$message
$go = mail($to, $subject, $body, "From:<$from>");
if(!$go) {
echo "<script type='text/javascript'>alert('failed!')</script>";
}
?>