Tuesday, February 2, 2016

LocalHost PhpMyAdmin

login.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
</head>

<body>
<form method="post" action="">
<input type="text" name="login" placeholder="Enter UserName"><br/>
<input type="password" name="pass" placeholder="Enter Password"><br/>
<input type="submit" name="submit" value="Log In">
</form>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
if($_SERVER['REQUEST_METHOD']=='POST')
{
extract($_POST);
$result=$mysqli->query("SELECT * FROM user WHERE login='$login' AND password='$pass'");
if($result->num_rows>0)
{
echo "<h1>Login Successful</h1>";
}
else
{
echo "<h1> Not Registered</h1>";
}
}
?>
</body>
</html>
_________________________________________________
entry_procedure.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Entry Procedure</title>
</head>
<body>
<form method="post" action="">
<input type="text" name="name" placeholder="Enter Name"><br/>
<input type="text" name="address" placeholder="Enter Address"><br/>
<input type="text" name="mobile" placeholder="Enter Mobile"><br/>
<input type="submit" name="submit" value="INSERT">
</form>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
if($_SERVER['REQUEST_METHOD']=='POST')
{
extract($_POST);
$result=$mysqli->query("CALL InsertStudent('$name', '$address', '$mobile')");
if($mysqli->affected_rows>0)
{
header("Location:display_data.php");
}
else
{
echo "<h1 align='center' style='color:red'>Not Inserted</h1>";
}
}
?>
</body>
</html>
________________________________________
edit.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Edit Page</title>
</head>
<body>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
$id=$_GET['id'];
$result=$mysqli->query("SELECT * FROM student WHERE id='$id'");
$data=$result->fetch_array();
?>
<form method="post" action="">
<input type="text" name="name" value="<?php echo $data['name'] ?>"><br/>
<input type="text" name="address" value="<?php echo $data['address'] ?>"><br/>
<input type="text" name="mobile" value="<?php echo $data['mobile'] ?>"><br/>
<input type="submit" name="submit" value="Update">
</form>
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
{
extract($_POST);
$result=$mysqli->query("UPDATE student SET name='$name', address='$address', mobile='$mobile' WHERE id='$id'");
if($mysqli->affected_rows>0)
{
header("Location:display_data.php");
}
else
{
echo "<h1 align='center' style='color:red'>Not Update</h1>";
}
}
?>
</body>
</html>
------------------------------------------------------------------------------------------------
display_data.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Display</title>
</head>
<body>
<form method="post" action="">
<table align="center" border="1">
<tr>
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>Mobile</th>
<th>Module Name</th>
<th>Total Marks</th>
<th>Edit</th>
</tr>
<?php
$mysqli=new MySQLi('localhost','root','','idb_bisew');
$result=$mysqli->query("SELECT * FROM display_view");
while($data=$result->fetch_array()){
?>
<tr>
<td><?php echo $data['id'] ?></td>
<td><?php echo $data['name'] ?></td>
<td><?php echo $data['address'] ?></td>
<td><?php echo $data['mobile'] ?></td>
<td align="center"><?php echo $data['module_name'] ?></td>
<td align="center"><?php echo $data['totalmarks'] ?></td>
<td align="center"><a href="edit.php?id=<?php echo $data['id'] ?>">Edit</a></td>
</tr>
<?php }?>
</table>
</form>

</body>
</html>
__________________________
delete.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Delete</title>
</head>

<body>
<form method="post" action="">
<select name="deleteid">
<?php $mysqli=new MySQLi('localhost','root','','idb_bisew');
$sql=$mysqli->query("SELECT * FROM student");
while($data=$sql->fetch_array()){
?>
<option value="<?php echo $data['id'] ?>"><?php echo $data['id'] ?>-<?php echo $data['name'] ?></option>
<?php } ?>
</select>
<br/>
<input type="submit" name="submit" value="Delete">
</form>
<?php
if($_SERVER['REQUEST_METHOD']=='POST')
{
$id=$_POST['deleteid'];
$result=$mysqli->query("DELETE FROM student WHERE id='$id'");
if($mysqli->affected_rows>0)
{
echo "<h1 align='center' style='color:green'>Id-$id Delete Successful</h1>";
}
else
{
echo "<h1 align='center' style='color:red'>Not Delete</h1>";
}
}
?>
</body>
</html>
___________________
display_view
CREATE VIEW display AS
SELECT student.id, name, address, mobile, module_name, totalmarks
FROM student, result
WHERE student.id=result.student_id ;
_________________
INSERT_PROCEDURE
DELIMITER $$
CREATE PROCEDURE InsertStudent(IN st_name VARCHAR(50), IN st_address VARCHAR(100), IN st_mobile VARCHAR(20))
BEGIN
INSERT INTO student SET name=st_name, address=st_address, mobile=st_mobile ;
END $$
DELIMITER ;
__________
DELIMITER $$
CREATE TRIGGER resultdelete
AFTER DELETE ON student
FOR EACH ROW
BEGIN
DELETE FROM result
WHERE student_id=OLD.id;
END $$
DELIMITER ;


No comments:

Post a Comment