Affecting all data in Database While Using Modal - php

Without Modal, user_timeout.php does not have a problem but When I use modal, as you can see at the picture below the problem is. But they have same logic codes so I dont know what the problem is. I want to use modal for some quality design so help me guys thank you
logs.php
<a rel="tooltip" title="Timeout" id="<?php echo $idlogs; ?>" href="user_timeout.php<?php echo '?id='.$idlogs; ?>" class="btn btn-info"><i class="icon-minus icon-large"></i> Manual Time-Out</a>
And for Modal
<a rel="tooltip" title="timeout" id="<?php echo $idlogs; ?>" href="#timeout<?php echo $idlogs; ?>" data-toggle="modal" class="btn btn-success"><i class="icon-pencil icon-large"></i> Manual Time-Out</a>
<?php include('modal_time_user.php'); ?>
user_timeout.php
<?php $get_id= $_GET['id']; ?>
<div class="container">
<div class="margin-top">
<div class="row">
<div class="span12">
<?php
$query=mysqli_query($dbcon,"select * from user_logs_tbl where id ='$get_id'")or die(mysqli_error());
$row=mysqli_fetch_assoc($query);
$iduser=$row['user_id'];
$idlogs=$row['id'];
?>
<div class="alert alert-info"><i class="icon-pencil></i> Manual Time-out</div>
<p><a class="btn btn-info" href="logs.php"><i class="icon-arrow-left icon-large"></i> Back</a></p>
<div class="addstudent">
<div class="details">Please Enter Details Below</div>
<form class="form-horizontal" method="POST" enctype="multipart/form-data">
<div class="control-group">
<br>
<div class="control-group">
<label class="control-label" style="margin-left:10%;" for="inputEmail">Time-Out:</label>
<div class="controls">
<input type="time" id="inputEmail" name="timeout" placeholder="Time">
</div>
</div>
<br>
<div class="control-group">
<div class="controls">
<button name="timeouts" type="submit" style="margin-left:16%;" class="btn btn-success"><i class="icon-save icon-large"></i> Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
if (isset($_POST['timeouts'])){
$timeout=$_POST['timeout'];
$timeout = date('Y-m-d H:i:s', strtotime(str_replace('-', '/',
$timeout)));
mysqli_query($dbcon,"UPDATE user_logs_tbl set time_out = '$timeout' where id='$idlogs'")or die(mysqli_error($dbcon));
$yourURL="logs.php";
echo ("<script>location.href='$yourURL'</script>");
}
?>
But If I change it into modal form, it's working but all data will change if I change one
modal_time_user.php
<div id="timeout<?php echo $idlogs; ?>" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-body">
<div class="alert alert-info"><strong>Time</strong></div>
<form class="form-horizontal" method="post">
<div class="control-group">
<label class="control-label" for="inputEmail">Time-Out :</label>
<div class="controls">
<input type="time" id="inputEmail" name="time_out" pattern="[a-zA-Z0-9]{5,}" required>
</div>
</div>
<div class="control-group">
<div class="controls">
<button name="enter" type="submit" class="btn btn-success"><i class="icon-save icon-large"></i> Update</button>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><i class="icon-remove icon-large"></i> Close</button>
</div>
</div>
<?php
if (isset($_POST['enter'])){
$timeout=$_POST['time_out'];
$timeout = date('Y-m-d H:i:s', strtotime(str_replace('-', '/', $timeout)));
mysqli_query($dbcon,"UPDATE user_logs_tbl SET time_out='$timeout' where id = '$idlogs'")or die(mysqli_error($dbcon));
$yourURL="logs.php";
echo ("<script>location.href='$yourURL'</script>");
}
?>
Problem
After Inserting a Time Out In USER ID 45

Related

html form is not submitting

My HTML form is not submitting. I am trying to collect data from form to an API but the form is not submitting.
<div class="col-lg-12">
<div class="card">
<div class="panel panel-primary">
<div class="panel-header">
<h4 class="text-center">Investment Preview</h4>
</div>
<div class="panel-body">
<h5 class="text-center"> Credit your account </h5>
<?php $classObj->funding(); ?>
<form action="google.com" method="POST">
<p class="form-control-static text-center"> Enter amount in dollar </p>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="number" name="amount" min="300" max="4999" class="form-control" required />
</div>
</div>
<div class="panel-footer">
<button type="submit" name="fund" class="btn btn-primary btn-block btn-flat"> Invest </button>
</div>
</form>
</div>
</div>
</div>
This is the php code for funding method
function funding(){
echo "testing";
if(isset($_POST["fund"])) {
$amount = mysqli_real_escape_string($this->conn, trim($_POST['amount']));
echo $amount;
}
}
Its not submitting because you have your form action as google.com
<form action="google.com" method="POST">
This needs to be changed to the correct file path that contains the processing code.
This is form opening and closing are wrong please set like this after form submit done:
<div class="col-lg-12">
<div class="card">
<div class="panel panel-primary">
<div class="panel-header">
<h4 class="text-center">Investment Preview</h4>
</div>
<form action="https://www.google.com" method="POST">
<div class="panel-body">
<h5 class="text-center"> Credit your account </h5>
<?php $classObj->funding(); ?>
<p class="form-control-static text-center"> Enter amount in dollar </p>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="number" name="amount" min="300" max="4999" class="form-control" required />
</div>
</div>
<div class="panel-footer">
<button type="submit" name="fund" class="btn btn-primary btn-block btn-flat"> Invest </button>
</div>
</form>
</div>
</div>
Your HTML tags are not properly nested. The second </div> in the form matches the <div> before <form>, so it's ending the form as well. As a result, the submit button is not inside the form.
Move that </div> down, after </form>.
Any decent editor or IDE should have warned you about unbalanced tags. You also should have noticed that the button wasn't inside the form when you opened the browser's console and checked the DOM inspector.
<div class="col-lg-12">
<div class="card">
<div class="panel panel-primary">
<div class="panel-header">
<h4 class="text-center">Investment Preview</h4>
</div>
<div class="panel-body">
<h5 class="text-center"> Credit your account </h5>
<?php $classObj->funding(); ?>
<form action="yourscript.php" method="POST">
<p class="form-control-static text-center"> Enter amount in dollar </p>
<div class="input-group">
<span class="input-group-addon">$</span>
<input type="number" name="amount" min="300" max="4999" class="form-control" required />
</div>
<div class="panel-footer">
<button type="submit" name="fund" class="btn btn-primary btn-block btn-flat"> Invest </button>
</div>
</form>
</div>
</div>
</div>
</div>

isset in php not working

I have a to get a data from this form and insert it into database.
I am not able to find any solution online.
Everything works on the browser but the data is not getting stored into the table and echo inside the if block is not printed on screen.
The code is what can be seen below.
HTML
<form action="" method="POST">
<div class="container-fluid">
<div class="container">
<div class="row">
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-10 col-lg-4 col-md-offset-3" style="top:100px">
<div class="offer offer-radius offer-primary">
<div class="shape">
<div class="shape-text">
<span class="glyphicon glyphicon-user"></span>
</div>
</div>
<div class="offer-content">
<h4 style="margin-left:70px;font-size:20px">Enter your details below and enroll your slot</h4>
<div class="container col-xs-12">
<div class="stepwizard">
<div class="stepwizard-row setup-panel">
<div class="stepwizard-step">
<a href="#step-1" type="button" class="btn btn-primary btn-circle">
<i class="glyphicon glyphicon-user" style="margin-left: -18px;top: -24px;font-size: 90%;"></i></a>
</div>
<div class="stepwizard-step">
<a href="#step-2" type="button" class="btn btn-default btn-circle" disabled="disabled">
<i class="glyphicon glyphicon-education" style="margin-left: -18px;top: -24px;font-size: 90%;"></i></a>
</div>
<div class="stepwizard-step">
<a href="#step-4" type="button" class="btn btn-default btn-circle" disabled="disabled">
<i class="glyphicon glyphicon-ok" style="margin-left: -18px;top: -24px;font-size: 90%;"></i></a>
</div>
</div>
</div>
<div class="row setup-content" id="step-2">
<div class="col-xs-12">
<div class="col-md-10">
<h3>Qualification</h3>
<div class="col-xs-12 col-xs-offset-1" style="top:-50px">
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
</div>
<div class="col-xs-12" style="clear:both;top:-45px">
<input maxlength="20" type="text" required="required" class="form-control" placeholder="B Tech" readonly="" />
</div>
<div class="col-xs-12 form-group" style="clear:both;top:-40px">
<label for="subject">
Year of Pass out</label>
<input maxlength="20" type="text" required="required" class="form-control" placeholder="2016" readonly="" />
</div>
<div class="col-xs-12 form-group" style="clear:both;top:-40px">
<label for="subject">
Branch</label>
<select id="subject" name="subject" class="form-control" required="required">
<option value="na" selected="">Choose One:</option>
<option value="service">Computer Science</option>
<option value="suggestions">Information Technology</option>
<option value="product">Electronics & Communication</option>
<option value="product">Electronics & Electrical</option>
<option value="product">Instrumentation</option>
</select>
</div>
<div class="col-xs-12" style="clear:both;top:-40px">
<label for="subject">
Percentage (%)</label>
<input maxlength="6" type="text" class="form-control" placeholder="Your Percentage" name="percentage" />
</div>
</div>
</div>
</div>
</div>
<div class="row setup-content" id="step-1">
<div class="col-xs-12">
<div class="col-md-12">
<div class="container">
<div class="row">
<div class="col-xs-4">
<button class="btn btn-primary nextBtn btn-lg pull-right" type="button" >Next</button>
<h3>Personal Information</h3>
<div class="col-xs-12" style="padding:15px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<input maxlength="100" type="text" class="form-control" placeholder="First Name" name="F_Name" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<input maxlength="100" type="text" class="form-control" placeholder="Last Name" name="L_Name" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope fa" aria-hidden="true"></i></span>
<input maxlength="100" type="text" class="form-control" placeholder="Your Email" name="EmailID" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone fa" aria-hidden="true"></i></span>
<input maxlength="14" type="text" class="form-control" placeholder="(+91) 555-555-5555" name="Phone_Number" />
</div>
</div>
<div class="col-xs-12" style="clear:both;padding:10px">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone fa" aria-hidden="true"></i></span>
<input maxlength="14" type="text" class="form-control" placeholder="Reference Code" name="R_Code" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row setup-content" id="step-4">
<div class="col-xs-12">
<div class="col-xs-12">
<div class="container" style="height:307px;">
<h4>Registered</h4>
<div class="col-xs-4" style="margin-left:-60px;top:60px">
<button class="btn btn-success completeBtn btn-lg pull-right" type="button" name="proceed">Proceed to payment</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
PHP
<?php
$cn= mysqli_connect('localhost','testuser','password','invoicedb');
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "string";
if(isset($_POST["proceed"]))
{echo "string";
$fname=$_POST['F_Name'];
$lname=$_POST['L_Name'];
$emailID=$_POST['EmailID'];
$phone_number=$_POST['Phone_Number'];
$reference_code=$_POST[‘R_Code’];
$branch=$_POST[‘subject’];
$percentage=$_POST[‘percentage’];
echo "insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')";
mysqli_query($cn,"insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')");
//best outside the if statement so user isn't stuck on a white blank page.
header("location:confirm.php");
exit;
}
?>
You can access $_POST[] values only if your form is submitted,
So, Replace this,
<button class="btn btn-success completeBtn btn-lg pull-right" type="button" name="proceed">Proceed to payment</button>
with This,
<button class="btn btn-success completeBtn btn-lg pull-right" type="submit" name="proceed">Proceed to payment</button>
It will work, without replacing your button with input.
If you are submitting the form in the same page then you should use -
<?php
$cn= mysqli_connect('localhost','testuser','password','invoicedb');
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
echo "string";
if($_SERVER["REQUEST_METHOD"] == "POST")
{echo "string";
$fname=$_POST['F_Name'];
$lname=$_POST['L_Name'];
$emailID=$_POST['EmailID'];
$phone_number=$_POST['Phone_Number'];
$reference_code=$_POST[‘R_Code’];
$branch=$_POST[‘subject’];
$percentage=$_POST[‘percentage’];
echo "insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')";
mysqli_query($cn,"insert into students(first_name,last_name,email,phone_number,reference_code,branch,percentage) VALUES ('$fname','$lname','$emailID','$phone_number','$reference_code','$branch','$percentage')");
//best outside the if statement so user isn't stuck on a white blank page.
header("location:confirm.php");
exit;
}
?>
if(isset($_POST["proceed"])){}
$_POST["proceed"] is not set at all, it needs a value in it to make sure it is set.
instead of checking if, just print the post values and try if your form is getting submitted.
inside php tag write below code and try echoing the data.
echo '<pre>';
print_r($_POST);
echo '----------------';
print_r($_REQUEST);

Button isn't fired in a Modal

I'm using an "a" to call a modal:
ausencias.php
echo ' <i class="fa fa-pencil"></i>';
edit.php:
<html>
<?php
If(isset($_GET['aus'])) {
//BASE DE DADOS
include("connection.php");
$aprovar=$_GET['aus'];
$resultado=mysqli_query($db, "SELECT *
FROM contas as a, ausencia as h
WHERE a.id = h.id
AND h.idausensia='$aprovar'");
while($row = mysqli_fetch_array($resultado)){
$noome=$row['nome'];
$pic=$row['pic'];
$datasaida=$row['datasaida'];
$datavolta=$row['datavolta'];
$motivo=$row['tipos'];
$ficheiro=$row['justfile'];
}
?>
<div id="custom-content" class="modal-block modal-block-md">
<section class="panel">
<header class="panel-heading">
<h2 class="panel-title">Visualização de Pedido de Ausência - <?php echo($noome)?> </h2>
</header>
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<br>
<center><img class="img-responsive" src="<?php echo($pic) ?>" /></center>
<br>
</div>
<div class="col-md-22">
</div>
</div>
<div class="row">
<div class="col-md-40">
<div class="panel-body">
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Nome</label>
<div class="col-md-6">
<input type="text" value="<?php echo($noome) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Comprovativo</label>
<div class="col-md-6">
<a class="mb-xs mt-xs mr-xs btn btn-primary" href='download.php?down=<?php echo($ficheiro)?>'><i class="fa fa-cloud"></i> Baixar</a>
</div>
<br><br>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Motivo</label>
<div class="col-md-6">
<input type="text" value="<?php echo($motivo) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Inicio Ausência</label>
<div class="col-md-6">
<input type="text" value="<?php echo($datasaida) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="inputReadOnly">Fim Ausência</label>
<div class="col-md-6">
<input type="text" value="<?php echo($datavolta) ?>" id="inputReadOnly" class="form-control" readonly="readonly">
</div>
</div>
<br>
<br>
<footer class="panel-footer">
<div class="row">
<div class="col-sm-9 col-sm-offset-3">
<form action="" method="post">
<input type="submit" value="Test" name="confirmar">
<button class="btn btn-default modal-dismiss">Sair</button>
<button name="recusar" type="button" class="mb-xs mt-xs mr-xs btn btn-danger">Recusar</button>
</form>
</div>
</div>
</footer>
</div>
</div>
</div>
</div>
<?php
if(isset($_POST['confirmar'])){
mysqli_query($db, "UPDATE ausencia SET estados='Rascunho' WHERE idausensia='$aprovar'");
mysqli_close($db);
header("Location: ausencias.php");
}
?>
<footer class="panel-footer">
<div class="row">
<div class="col-md-12 text-right">
</div>
</div>
</footer>
</section>
</div>
<?php }?>
<html>
But for some reason, the Isset is not working for the button, but when i remove the If, the SQL statement works. When i click the button it just close the modal and don't trigger what is inside the If.
Can anyone help me?
the if that dont work is that:
if(isset($_POST['confirmar'])){
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
you are adding direct php file in href of anchor it will redirect you on target page use Simply Modal window of Bootstrap.

how to set value in input type = file from database

<div class="modal fade validate" id="modal-6">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Edit Advertisement</h4>
<label class="idhere"><?php echo $id; ?></label>
</div>
<?php $sel = $d->select('advertisements', 'ad_id=12');
while ($result = mysqli_fetch_assoc($sel)) {
?>
<div class="modal-body">
<div class="row">
<div class="form-group col-md-6">
<label class="control-label">Image Upload</label>
<div>
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;" data-trigger="fileinput">
<img src="<?php echo $result['photo']; ?>">
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px"></div>
<div>
<span class="btn btn-white btn-file">
<span class="fileinput-new">Select image</span>
<span class="fileinput-exists">Change</span>
<input type="file" name="advertise_photo" accept="image/*">
</span>
Remove
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info">Send</button>
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>
<?php } ?>
</div>
</div>
</div>
I am unable to set the value of input type=file from database,
and if the image is exits then change button appear instead of select image.
when i am choosing new file it works properly,and change and remove button appear instead of select file.
Please help me to solve it.
Note: Above question is continuous of this question so the following answer is also continuous of this answer
You can skip the <label class="idhere"><?php echo $id;?></label>
in JS what yo need is ajax call method to fetch data from database against <?php $id;?> and display in modal
$(document).ready(function() {
$('#modal-6').on('shown.bs.modal', function(e) {
var id = $(e.relatedTarget).data('id');
$.ajax({
type : 'post',
url : 'file.php', //Here you will fetch records or images
data : 'id='+ id, //Pass id
success : function(data){
$('#fetched-data').html(data);//Show fetched data from database
}
});
});
});
Modal HTML will be
<div class="modal fade validate" id="modal-6">
<div class="modal-dialog">
<div class="modal-content">
<div id="fetched-data"></div>
</div>
</div>
</div>
and file.php will be
<?php
//database connection
if($_POST['id']) {
$id = $_POST['id']; //escape the string
//run query
//fetch data from database
//poplutae the HTML with values
?>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Edit Advertisement</h4>
</div>
<?php $sel = $d->select('advertisements','ad_id=12');
while($result = mysqli_fetch_assoc($sel)){
?>
<div class="modal-body">
<div class="row">
<div class="form-group col-md-6">
<label class="control-label">Title</label>
<input class="form-control" value="<?php echo $result['title'];?>" name="advertise_title" data-validate="required" data-message-required="Please Enter Title" placeholder="Enter Title" type="text">
</div>
<div class="form-group col-md-6">
<label class="control-label">URL</label>
<input class="form-control" name="advertise_url" value="<?php echo $result['url'];?>" data-validate="required" data-message-required="Please Enter URL" placeholder="Enter URL" type="text">
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group no-margin">
<label for="description" class="control-label">Description</label>
<textarea class="form-control autogrow" id="description" name="advertise_desc" placeholder="Describe Description Regarding Query">
<?php echo trim($result['description']); ?>
</textarea>
</div>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label class="control-label">Image Upload</label>
<div>
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;" data-trigger="fileinput">
<img src="<?php echo $result['photo']; ?>">
<!-- <img src="images/thumbnail.jpeg" alt="..."> -->
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px"></div>
<div>
<span class="btn btn-white btn-file">
<span class="fileinput-new">Select image</span>
<span class="fileinput-exists">Change</span>
<input type="file" name="advertise_photo" accept="image/*" >
</span>
Remove
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label class="control-label">Active Flag</label>
<input type="checkbox">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info">Send</button>
<button type="button" class="btn btn-white" data-dismiss="modal">Close</button>
</div>
<?php } } ?>
As suggested by #devpro you need <form></form> to edit / update the populated data inside modal.

Records not saving into database when saving from bootstrap modal pop up in php

I want to submit data in database using bootstrap modal popup but when i press submit buttons nothing happens and i think that page which is used to submit a record is also not called. Below is the code of modal popup: i have called addProducts.php page but it is not called on click of a submit buttom please help to solve it. Thanks..
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add Products Details</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-lg-12">
<form role="form" name="Insertdb" method="post" action="Insert_code/add-products.php">
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Name</label>
</div>
</div>
<div class="col-lg-6">
<input class="form-control" name="prodName" placeholder="Enter product Name">
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Price</label>
</div>
</div>
<div class="col-lg-6">
<input class="form-control" name="prodPrice" placeholder="Enter product price">
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Type</label>
</div>
</div>
<div class="col-lg-6">
<input class="form-control" name="productType" placeholder="Enter product type">
</div>
</div>
<div class="row">
<div class="col-lg-4">
<div class="form-group">
<label>Product Description</label>
</div>
</div>
<div class="col-lg-6">
<textarea class="form-control" name="productDesc" rows="3"></textarea>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<input name="button1" type="submit" class="btn btn-primary">
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
</div>
<?
require_once('user.inc.php');
$Users = new Users();
$name=$_REQUEST['prodName'];
$price=$_REQUEST['prodPrice'];
$type=$_REQUEST['productType'];
$description=$_REQUEST['productDesc'];
$query="INSERT INTO tbl_product(`product_name`,`product_desc`,`product_price`,`product_type`)
VALUES('".$name."','".$description."','".$price."','".$type."')";
if(!executeQuery($query))
{
echo '<script language="javascript">';
echo 'alert("An error occured. Please try again")';
echo '</script>';
else
{
echo '<script language="javascript">';
echo 'alert("Record Successfully Inserted")';
echo '</script>';
}
?>

Categories