0% found this document useful (0 votes)
29 views2 pages

Process

This PHP code handles user registration and profile editing. It connects to a database, defines variables to store form data, inserts submitted data into a database table on registration, deletes a record by ID on request, and retrieves and populates an existing record's fields for editing. Required fields are checked on registration, and alerts are displayed for incomplete forms or errors.

Uploaded by

Arj gonzaga
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)
29 views2 pages

Process

This PHP code handles user registration and profile editing. It connects to a database, defines variables to store form data, inserts submitted data into a database table on registration, deletes a record by ID on request, and retrieves and populates an existing record's fields for editing. Required fields are checked on registration, and alerts are displayed for incomplete forms or errors.

Uploaded by

Arj gonzaga
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/ 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