0% found this document useful (0 votes)
228 views

Open Source Technologies - PHP Lab

The document describes developing a user authentication and personalization application using PHP and MySQL. It includes the following steps: 1. Create a user database to store credentials. 2. Connect the database to the front-end application. 3. Design a login form with username, password, and login/register buttons. 4. Perform authentication by querying the user database and setting session variables. 5. Redirect to a personalized dashboard upon successful login.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
228 views

Open Source Technologies - PHP Lab

The document describes developing a user authentication and personalization application using PHP and MySQL. It includes the following steps: 1. Create a user database to store credentials. 2. Connect the database to the front-end application. 3. Design a login form with username, password, and login/register buttons. 4. Perform authentication by querying the user database and setting session variables. 5. Redirect to a personalized dashboard upon successful login.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 55

EX.

NO:
DATE: USER AUTHENTICATION

AIM:

To develop an application for User Authentication and Personalization using open


source technologies.

ALGORITHM:

Step1: Start the process.


Step 2: Create a database for storing user’s credentials.
Step 3: To connect the database to your front – end application by using
mysqli_connect( ) function.
Step 4: To activate the session information by session_start() function.
Step 5: Design a html form with user name, password, LogIn and Register button.
Step 6: To perform the user action by using switch…case statement.
Step 7: To set the username and password by $_SESSION( ) function.
Step 8: To close the database by mysqli_close( ) function.
Step 9: Stop the process.

Index.php:
<?php
/*
create database mysite default character set=utf16;

use mysite;

create table users(username varchar(30) primary key,


password varchar(10)) default character set=utf16;

insert into users value('admin','Pass@123');

*/
// 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:

Step 1: Start the process.


Step 2: Create a database for storing product details.
Step 3: To connect the database to your front – end application by using
mysqli_connect( ) function.
Step 4: To display the product details by using array() function in PHP.
Step 5: To store the session values by using $_SESSION() function.
Step 6: To add the selected products on the cart by using Key value of the array.
Step 7: Run the application.
Step 8: Stop the process.

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.

/*

create database shoppingcart default character set=utf16;

use shoppingcart;

create table products (code varchar(20) primary key,


name varchar(150) not null, price double(9,2) not null,
image varchar(150) not null) default character set=utf16;

insert into products values('Laptop01', 'Laptop Core i5', 600.00,


'product-images/laptop.jpg');
insert into products values('Bag01', 'Laptop Bag', 50.00, 'product-images/laptop-
bag.jpg');
insert into products values('iphone01', 'iPhone X', 700.00,
'product-images/iphone.jpg');

*/
$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;">

<h2>Shopping Cart - <strong>ABC SHOPPING MALL</strong></h2>

<?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
}

$result = mysqli_query($con,"SELECT * FROM `products`");


while($row = mysqli_fetch_assoc($result))
{
echo "<div class='product_wrapper'>
<form method='post' action=''>
<input type='hidden' name='code' value=".
$row['code']." />
<div class='image'><img src='".$row['image']."'
/></div>
<div class='name'>".$row['name']."</div>
<div class='price'>$".$row['price']."</div>
<button type='submit' class='buy'>Buy
Now</button>
</form>
</div>";
}
mysqli_close($con);
?>

<div style="clear:both;"></div>

<div class="message_box" style="margin:10px 0px;">


<?php echo $status; ?>
</div>
<strong>ABC SHOPPING MALL PVT. LTD.</strong><br /><br />
</div>
</body>
</html>
Cart.php
<?php
// Activate the session information
session_start();
$status="";
if (isset($_POST['action']) && $_POST['action']=="remove")
{
if(!empty($_SESSION["shopping_cart"]))
{
foreach($_SESSION["shopping_cart"] as $key => $value)
{
if($_POST["code"] == $key)
{
unset($_SESSION["shopping_cart"][$key]);
$status = "<div class='box'
style='color:red;'>Product is removed from your cart!</div>";
}
if(empty($_SESSION["shopping_cart"]))
unset($_SESSION["shopping_cart"]);
}
}
}

if (isset($_POST['action']) && $_POST['action']=="change")


{
foreach($_SESSION["shopping_cart"] as &$value)
{
if($value['code'] === $_POST["code"])
{
$value['quantity'] = $_POST["quantity"];
break; // Stop the loop after we've found the product
}
}
}
?>
<html>
<head>
<title>Shopping Cart</title>
<link rel='stylesheet' href='css/style.css' type='text/css' media='all' />
</head>
<body>
<div style="width:700px; margin:50 auto;">

<h2>Shopping Cart - <strong>ABC SHOPPING MALL</strong></h2>

<?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>

<div class="message_box" style="margin:10px 0px;">


<?php echo $status; ?>
</div>
<strong>ABC SHOPPING MALL PVT. LTD.</strong><br /><br />
</div>
</body>
</html>

INPUT/OUTPUT SCREEN:
EX.NO:
DATE: ONLINE JOB PORTAL
AIM:
To develop an application for Job Web Portal using PHP and MYSQL database.

ALGORITHM:

Step 1: Start the process.


Step 2: Create a database for storing user person as well as academic details.
Step 3: To connect the database to your front – end application by using
mysqli_connect( ) function.
Step 4: Design a web page to getting the job seekers personal as well as academic
qualifications.
Step 5: After getting the user information it will redirect into Job Available page.
Step 6: Run the Application.
Step 7: Stop the process.
Index.php
<!DOCTYPE html>

<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> use jobport


Database changed
mysql> drop table job;
Query OK, 0 rows affected (0.04 sec)

mysql> create table job(name varchar(20),fname varchar(20),addr varchar(20),gender


varchar(10),state varchar(20),city varchar(20),dob date,pin varchar(10),post
varchar(20),email varchar(20),psw varchar(20));
Query OK, 0 rows affected (0.06 sec)

mysql> */

$link = mysqli_connect("localhost", "root", "", "jobport");

// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}

// Escape user inputs for security


$nm = mysqli_real_escape_string($link, $_REQUEST['name']);
$fn = mysqli_real_escape_string($link, $_REQUEST['father_name']);
$addr = mysqli_real_escape_string($link, $_REQUEST['address']);
$gender = mysqli_real_escape_string($link, $_REQUEST['gender']);
$state = mysqli_real_escape_string($link, $_REQUEST['state']);
$city = mysqli_real_escape_string($link, $_REQUEST['city']);
$dob = mysqli_real_escape_string($link, $_REQUEST['dob']);
$pincode = mysqli_real_escape_string($link, $_REQUEST['pin']);
$post = mysqli_real_escape_string($link, $_REQUEST['post']);
$email = mysqli_real_escape_string($link, $_REQUEST['email']);
$psw = mysqli_real_escape_string($link, $_REQUEST['psw']);

// attempt insert query execution


$sql = "INSERT INTO job (name, fname, addr, gender, state, city, dob, pin, post, email,
psw) VALUES ('$nm', '$fn', '$addr', '$gender', '$state', '$city', '$dob', '$pincode', '$post',
'$email', '$psw')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
header("Location: job.php");
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}

// 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 1: Start the process.

Step 2: Create a database for storing participants name and score details.

Step 3: To connect the database to your front – end application by using


mysqli_connect( ) function.
Step 4: To retrieve the quiz questions one by one using search query and randomize the
questions.
Step 5: On clicking Next button new question will display.
Step 6: After completion of the quiz click on next button the score and user information
will store on the database.
Step 7: Run the application.
Step 8: Stop the process.

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'];

$fetchqry2 = "UPDATE `quiz` SET


`userans`='$userselected' WHERE `id`=$c-1";

$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'];?>">&nbsp;<?php echo $row['option 1']; ?><br>
<tr><td><input required type="radio" name="userans" value="<?php echo $row['option
2'];?>">&nbsp;<?php echo $row['option 2'];?></td></tr>
<tr><td><input required type="radio" name="userans" value="<?php echo $row['option
3'];?>">&nbsp;<?php echo $row['option 3']; ?></td></tr>
<tr><td><input required type="radio" name="userans" value="<?php echo $row['option
4'];?>">&nbsp;<?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:&nbsp;<?php echo $no = @$_SESSION['score'];
session_unset(); ?></span><br>
<span>Your Score:&nbsp<?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:

Step 1: Start the process.


Step 2: Create a database for storing participants name and score details.
Step 3: To connect the database to your front – end application by using
mysqli_connect( ) function.
Step 4: To retrieve the quiz questions one by one using search query and randomize the
questions.
Step 5: On clicking Next button new question will display.
Step 6: After completion of the quiz click on next button the score and user information
will store on the database.
Step 7: Run the application.
Step 8: Stop the process.

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>

<form name="home" action="" method="POST">


<hr>
<h2 align="center"> ONLINE QUIZ </h2>
<h3 align="center">GENERAL KNOWLEDGE AND CURRENT AFFAIRS</h3>
<h4 align="center">TEST YOUR KNOWLEDGE</h4><hr><br><br>
<h4 align="center" style="color:red">Enter Your Name and Take Quiz</h4>
<table align="center">
<tr>
<td>Enter Your Name : </td>
<td><input type="text" name="uname" value="" required /></td>
</tr>
</table> <br><br>
<div align="center">
<input type="submit" class="submit" id="submit" value="TAKE QUIZ"
style="background-color:blue;padding: 15px 32px;cursor: pointer; color:white" />
</div>
</form>
</body>
</html>
Quiz.php:
<?php
error_reporting(E_ALL ^ E_NOTICE);
session_start();
?>
<html>
<body>

<form action="" method="">


<hr>
<h2 align="center"> ONLINE QUIZ </h2>
<h3 align="center">GENERAL KNOWLEDGE AND CURRENT AFFAIRS</h3>
<h4 align="center">TEST YOUR KNOWLEDGE</h4><hr><br>
Welcome <?php echo $_SESSION["name"]; ?>
<br><br><hr><br>
<div>
1. ISRO has plans to set up India's own space station by _________________.<br>
<input type="radio" name="q1" id="q1a">2025
<input type="radio" name="q1" id="q1b">2026
<input type="radio" name="q1" id="q1c">2030
<input type="radio" name="q1" id="q1d">2032<br><br>
</div>
<div>
2. What is the name of audio guide facility app launched by Ministry of Tourism?<br>
<input type="radio" name="q2" id="q2a">Audio Odigos
<input type="radio" name="q2" id="q2b">Radio Guide
<input type="radio" name="q2" id="q2c">Mobile Guide
<input type="radio" name="q2" id="q2d">Guide to Ride<br><br>
</div>
<div>
3. Which social media has linked an agreement with International Cricket Council to get
exclusive digital content rights for ICC matches in South Asia, recently?<br>
<input type="radio" name="q3" id="q3a">YouTube
<input type="radio" name="q3" id="q3b">Instagram
<input type="radio" name="q3" id="q3c">Twitter
<input type="radio" name="q3" id="q3d">Facebook<br><br>
</div>
<div>
4. Scientists from which institute have developed the biggest-ever computer chip using
carbon nanotubes (CNT)- RV16XNano?<br>
<input type="radio" name="q4" id="q4a">Yale University
<input type="radio" name="q4" id="q4b">Massachusetts Institute of Technology (MIT)
<input type="radio" name="q4" id="q4c">Harvard University
<input type="radio" name="q4" id="q4d">Stanford University<br><br>
</div>
<div>
5. Which item has been banned by the Directorate General of Civil Aviation while
travelling in planes?<br>
<input type="radio" name="q5" id="q5a">MI Phone
<input type="radio" name="q5" id="q5b">Samsung Charger
<input type="radio" name="q5" id="q5c">Lenovo Laptop
<input type="radio" name="q5" id="q5d">Apple Mac Book<br>
</div>
</form>

<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>

<input id="login" type="button" name="useraction" value="ACCOUNT LOGIN"


style="background-color:Gray;padding: 15px 32px;cursor: pointer; color:white"
onClick='redirectToURL(this.id)'/>
<input id="account" type="button" name="useraction" value="CREATE NEW
ACCOUNT" style="background-color:Gray;padding: 15px 32px;cursor: pointer;
color:white" onClick='redirectToURL(this.id)'/>
</body>
</html>
Account.php:
<!DOCTYPE html>
<html>
<head>
<title>Sign Up Form</title>
</head>
<body>
<center>
<br>
<h1>CREATE NEW ACCOUNT</h1>
<br><br>
<form name="account" action="" method="POST" >
<table>
<tr>
<td>Account No :</td>
<td><input type="text" name="accno" value="" required/></td>
</tr>
<tr>
<td>Name :</td>
<td><input type="text" name="name" value="" required/></td>
</tr>
<tr>
<td>Address :</td>
<td><input type="text" name="address" value="" required/></td>
</tr>
<td>Amount :</td>
<td><input type="number" name="amt" value="" required></td>
</tr>
<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="CREATE" class="submit" name="submit"
id="submit" /></td>
</tr>
</table>
<br>
Already you have an account <a href="login.php"> Click Here</a> to LogIn.
</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();

$sql="INSERT INTO account VALUES('".$_POST["accno"]."','".$_POST["name"]."','".


$_POST["address"]."',".$_POST["amt"].",'".$_POST["email"]."','".$_POST["psw"]."')";
if(mysqli_query($con, $sql)){
$_SESSION["uid"] = $eid;
echo "Account Created Successfully !!!";
header("location: dashboard.php");
}
mysqli_close($con);
?>
Login.php:

<!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);

// If result matched $myusername and $mypassword, table row must be 1 row


if($count == 1) {
//session_register("myusername");
$_SESSION['uid'] = $uid;
echo "Logged Successfully";
header("location: dashboard.php");
}else {
echo "Your Login Name or Password is invalid";
}
}
?>
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: login.php");
}
?>
<html>
<head>
<title>Dashboard</title>

<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>

<input id="home" type="button" name="useraction1" value="HOME PAGE"


style="background-color:Gray;padding: 15px 32px;cursor: pointer; color:white"
onClick='redirectToURL(this.id)'/>
<input id="login" type="button" name="useraction" value="ACCOUNT LOGIN"
style="background-color:Gray;padding: 15px 32px;cursor: pointer; color:white"
onClick='redirectToURL(this.id)'/>
<input id="account" type="button" name="useraction" value="CREATE NEW
ACCOUNT" style="background-color:Gray;padding: 15px 32px;cursor: pointer;
color:white" onClick='redirectToURL(this.id)'/>
<input id="dep" type="button" name="useraction" value="DEPOSITE MONEY"
style="background-color:Gray;padding: 15px 32px;cursor: pointer; color:white"
onClick='redirectToURL(this.id)'/>
<input id="drop" type="button" name="useraction" value="WITHDRAW MONEY"
style="background-color:Gray;padding: 15px 32px;cursor: pointer; color:white"
onClick='redirectToURL(this.id)'/>
<input id="bal" type="button" name="useraction" value="CHECK BALANCE"
style="background-color:Gray;padding: 15px 32px;cursor: pointer; color:white"
onClick='redirectToURL(this.id)'/>
<input id="logout" type="button" name="useraction" value="LOGOUT"
style="background-color:Gray;padding: 15px 32px;cursor: pointer; color:white"
onClick='redirectToURL(this.id)'/>

</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);

$sql = "UPDATE account SET amt=$add 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);
?>
Withdraw.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>
<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:

Step 1: Start the process.


Step 2: To design a user registration form by using HTML with angularJS.
Step 3: Using ng-required attribute to ensure all the fields are filled or not.
Step 4: Using ng-pattern to check the value on the required format.
Step 5: Using ng-maxlength function to check the length of the mobile number.
Step 6: Save the application with .js extension.
Step 7: Stop the process.
Index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AngularJS Form Validation</title>
</head>

<body ng-app="formApp">
<div ng-controller="FormController">

<form name="form" novalidate class="css-form">


<h1>Form Validation Using AngularJS</h1><br>
EmID : <input type="text" ng-model="employee.id" ng-
required="true"/><br /><br>

Name : <input type="text" ng-model="employee.name" ng-


required="true"/><br /><br>

Email : <input type="email" ng-model="employee.email"


ng-required="true" /><br /><br>

PhNo : <input type="text" ng-model="employee.mob" ng-


maxlength=10 ng-required="true" /><br /><br>

URL ..: <input type="url" name="homepage" ng-


model="employee.url" ng-required="true" /><br><br>

Role : <input type="radio" ng-model="employee.role"


value="development" />Development
<input type="radio" ng-model="employee.role"
value="testing" />Testing<br /></br>

<input type="button" ng-click="reset()" value="Reset" />

<input type="submit" ng-disabled="form.$invalid" ng-


click="save(employee)" value="Submit" />
</form>

<p>Employee Form = {{employee | json}}</p>


<p>Master = {{master | json}}</p>
</div>

<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:

Step 1: Start the process.


Step 2: To find the current date and time by using date function and save it as
myfirstmodule.js.
Step 3: To create port and local host by using require( ) function.
Step 4: To display the result by using write( ) function.
Step 5: Save the file with .js extension.
Step 6: Stop the process.

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:

Step 1: Start the process.


Step 2: Creating a test file for PHP mail
Step 3: Understanding PHP mail
Step 4: To using PHP mail() function.
Step 5: Gathering details for PHPMailer
Step 6: Running the PHPMailer script
Step 7: Stop the process.

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>";
}
?>

You might also like