2603.0 - First effort...
This commit is contained in:
83
add_type_save.php
Normal file
83
add_type_save.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
session_start();
|
||||
date_default_timezone_set("America/Montreal");
|
||||
$_SESSION['rezult_msg']="";
|
||||
$_SESSION['ret_link']="";
|
||||
include('conn.php');
|
||||
|
||||
//DATA
|
||||
//ip $ip
|
||||
//adddate $adddate
|
||||
//enddate $enddate
|
||||
//reason $reason
|
||||
//type $type
|
||||
|
||||
|
||||
if(!empty($_POST['old_type'])&&isset($_POST['old_type'])){
|
||||
$old_type=trim($_POST['old_type']);
|
||||
}
|
||||
else{
|
||||
$old_type="";
|
||||
}
|
||||
|
||||
if(!empty($_POST['type'])&&isset($_POST['type'])){
|
||||
$type=trim($_POST['type']);
|
||||
}
|
||||
else{
|
||||
$type="";
|
||||
}
|
||||
|
||||
if(!empty($_POST['label'])&&isset($_POST['label'])){
|
||||
$label=trim(addslashes($_POST['label']));
|
||||
}
|
||||
else{
|
||||
$label="";
|
||||
}
|
||||
|
||||
if(!empty($_POST['status'])&&isset($_POST['status'])){
|
||||
if($_POST['status']=='a'){
|
||||
$status=1;
|
||||
}
|
||||
elseif($_POST['status']=='i'){
|
||||
$status=0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$status="";
|
||||
}
|
||||
|
||||
if(!empty($_POST['action'])&&isset($_POST['action'])){
|
||||
$action=$_POST['action'];
|
||||
}
|
||||
else{
|
||||
$action="";
|
||||
}
|
||||
|
||||
if($action=="yes"){
|
||||
$sql_action="UPDATE type SET type='$type', label='$label', status='$status' WHERE type='$old_type'";
|
||||
}
|
||||
elseif($action=="no"){
|
||||
$sql_action="INSERT INTO type (type,label,status) VALUES ('$type','$label','$status')";
|
||||
}
|
||||
else{
|
||||
$_SESSION['rezult_msg']="There is insuficient information to be able to add records to the database. Please try again.<br>".mysqli_error($con);
|
||||
$_SESSION['ret_link']="add_type_frm.php";
|
||||
header("location:error.php?var=2");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(mysqli_query($con,$sql_action)){
|
||||
$_SESSION['rezult_msg']="Type successfully added/updated to the database.";
|
||||
$link="add_type_frm.php";
|
||||
echo $_SESSION['rezult_msg'];
|
||||
header("location:$link?var=1");
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
$_SESSION['rezult_msg']="The value was not added/updated to the database. Please try again.<br>".mysqli_error($con);
|
||||
$_SESSION['ret_link']="add_type_frm.php";
|
||||
header("location:error.php?var=2");
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user