Process

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

<?

php

$mysqli = new mysqli ('localhost', 'root', '', 'web') or die


(mysqli_error($mysqli));
$fname = '';
$mname = '';
$lname = '';
$gender = '';
$contactno = '';
$job = '';

if (isset($_POST['registerbtn']))
{
$fname = $_POST['fname'];
$mname = $_POST['mname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$contactno = $_POST['contactno'];
$job = $_POST['job'];

if(empty($fname) && empty($mname) && empty($lname) && empty($gender) &&


empty($contactno) && empty($job))
{
echo "<script>alert('Please complete all the fields'); window.location.href =
'web.php'; </script>";

}
else{

$mysqli->query("INSERT INTO webtb( firstname, middlename, lastname, gender,


contactnum, job) VALUES ('$fname', '$mname', '$lname', '$gender', '$contactno',
'$job')") or die ($mysqli->error);
header ("Location: Dimaano.html");
exit;
}
}

if (isset($_GET['delete']))
{
$id = $_GET['delete'];
$mysqli->query("DELETE FROM webtb WHERE idno = $id ") or die ($mysqli->error());
header ("Location: web.php");
exit;
}
if (isset($_GET['edit']))
{
$id = $_GET['edit'];
$result = $mysqli->query("SELECT * FROM webtb WHERE idno = $id ") or die
($mysqli->error());
if (count($result) == 1)
{
$row = $result->fetch_array();
$fname = $row['firstname'];
$mname = $row['middlename'];
$lname = $row['lastname'];
$gender = $row['gender'];
$contactno = $row['contactnum'];
$job = $row['job'];

}
header ("Location: web.php");
}

?>

<script type = "text/javascript">


function err()
{
alert ("Complete all the fields");
return true;
}
</script>

You might also like