157 lines
5.3 KiB
PHP
157 lines
5.3 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset='utf-8'>
|
|
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
|
<title>Placeholder Register</title>
|
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
<link rel='stylesheet' type='text/css' media='screen' href='style.css'>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<a href="home.php" style="font-family: cursive; color:white; font-size: xx-large; text-decoration: none"> Placeholder</a>
|
|
</header>
|
|
<div class="login-box">
|
|
<?php
|
|
session_start();
|
|
$ID = $_SESSION['EmployeeID'];
|
|
if ($ID == ''){
|
|
header("location:index.php");
|
|
}
|
|
?>
|
|
<h2>Shipment Fill-out form</h2>
|
|
<form action="insert.php" method="post">
|
|
<div class="user-box">
|
|
<input type="number" name="shipmentID" required>
|
|
<label>Shipment ID</label>
|
|
</div>
|
|
<div class="user-box">
|
|
<input type="text" name="source_addr" required>
|
|
<label>Source Address</label>
|
|
</div>
|
|
<div class="user-box">
|
|
<input type="text" name="dest_addr" required>
|
|
<label>Destination Address</label>
|
|
</div>
|
|
<div class="user-box">
|
|
<select name="shipType" class="styled-combo" style="margin-top: 25px" >
|
|
<option value="small">Small</option>
|
|
<option value="medium">Medium</option>
|
|
<option value="large">Large</option>
|
|
</select>
|
|
<label style="margin-top: -10px">Shipment Type</label>
|
|
</div>
|
|
<h2>Shipment Process form</h2>
|
|
<div class="user-box">
|
|
<input type="text" name="storeID" required>
|
|
<label>Store ID</label>
|
|
</div>
|
|
<div id="pakbox">
|
|
<button type="submit" id="submitButton" name="Register">Submit</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
<!--The bettah code that I wrote MWAHAHAHA-->
|
|
<?php
|
|
define('MYSQL','localhost');
|
|
define('USERNAME','root');
|
|
define('PASSWORD','');
|
|
define('DATABASE','g1_pila');
|
|
|
|
|
|
$connect = mysqli_connect(MYSQL,USERNAME,PASSWORD,DATABASE) or die('<script>alert("Server Connection Failed.");</script>');
|
|
if(isset($_POST['Register'])){
|
|
$shipID =$_POST['shipmentID'];
|
|
$source=$_POST['source_addr'];
|
|
$dest = $_POST['dest_addr'];
|
|
$shipType = $_POST['shipType'];
|
|
$storeID = $_POST['storeID'];
|
|
|
|
if(empty($shipID) || empty($source) || empty($dest) || empty($shipType) || empty($storeID)){
|
|
echo "<script>alert('Sorry There are empty fields that needs to be filled');</script>";
|
|
}else{
|
|
$sql = "INSERT INTO shipment (SHIPMENT_ID, SOURCE_ADDRESS, DESTINATION_ADDRESS, SHIPMENT_TYPE) values ('$shipID','$source','$dest','$shipType')";
|
|
if(mysqli_query($connect,$sql)){
|
|
$sql = "INSERT INTO shipment_process (SHIPMENT_ID,STORE_ID) values ($shipID,$storeID)";
|
|
if(mysqli_query($connect,$sql)){
|
|
echo '<script>alert("Record saved successfully");</script>';
|
|
}else{
|
|
echo "<script>alert('shipment process record fail ERROR: 1D-10T Process Br1@n');</script>";
|
|
}
|
|
}else{
|
|
echo "<script>alert('Shipment fillup fail ERROR: ERROR: 1D-10T Process Br1@n');</script>";
|
|
}
|
|
|
|
}
|
|
}
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!--Trash code before I completely understood the lection-->
|
|
/* <!--
|
|
try {
|
|
define('SERVER','localhost');
|
|
define('USERNAME','root');
|
|
define('PASSWORD','');
|
|
define('DATABASE','');
|
|
$pdo = mysqli_connect(SERVER, USERNAME, PASSWORD);
|
|
|
|
if($_SERVER["REQUEST_METHOD"] == "POST"){
|
|
$shipmentID = $_POST['shipmentID'];
|
|
$sourceAddr = $_POST['source_addr'];
|
|
$destAddr = $_POST['dest_addr'];
|
|
$shipmentType = $_POST['shipType'];
|
|
$storeID = $_POST['storeID'];
|
|
|
|
if(empty($shipmentID) || empty($sourceAddr) || empty($destAddr) || empty($shipmentType) || empty($storeID)){
|
|
echo '<script>alert("These fields cannot be empty");</script>';
|
|
}else{
|
|
$statement = $pdo->prepare("INSERT INTO shipment (SHIPMENT_ID, SOURCE_ADDRESS, DESTINATION_ADDRESS, SHIPMENT_TYPE) VALUES (:shipmentID, :sourceAddr, :destAddr, :shipmentType)");
|
|
$statement->bindParam(':shipmentID', $shipmentID);
|
|
$statement->bindParam(':sourceAddr', $sourceAddr);
|
|
$statement->bindParam(':destAddr', $destAddr);
|
|
$statement->bindParam(':shipmentType', $shipmentType);
|
|
if ($statement->execute()) {
|
|
if ($statement->rowCount() > 0) {
|
|
$statement = $pdo->prepare("INSERT INTO shipment_process (SHIPMENT_ID, STORE_ID) VALUES (:shipmentID, :storeID)");
|
|
$statement->bindParam(':shipmentID', $shipmentID);
|
|
$statement->bindParam(':storeID', $storeID);
|
|
if($statement->execute()){
|
|
echo '<script>alert("Stuff Recorded!");</script>';
|
|
} else {
|
|
echo '<script>alert("Failed to insert into shipment_process!");</script>';
|
|
}
|
|
} else {
|
|
echo '<script>alert("Failed to insert into shipment!");</script>';
|
|
}
|
|
} else {
|
|
echo '<script>alert("Failed to insert into shipment!");</script>';
|
|
}
|
|
}
|
|
}
|
|
} catch (PDOException $e) {
|
|
echo '<script>alert("Connection failed: ' . $e->getMessage() . '");</script>';
|
|
}
|
|
?> -->
|