Data not Insert not Insert with Blank textbox Using PHP Mysql
up vote
0
down vote
favorite
I would like to ask if anyone know how to solved my issue.
I have Form with 4 and I want save the data into the database.
the problem is I want add data with blank input.
Example 1 :
Consumer Request : data = test and submit the form. the others text box I want it blank and mydatabase only Consumer Request data insert into database.
Example 1 :
Check & Verification : data = 'test', and submit the form. the others text box I want it blank and mydatabase only Check & Verification data insert into database.
The real issue is If I only insert 1 text box the system cannot work. but if I insert all 4 texbox the data will insert into database without no issue.
Sorry if my explaination a bit confius and my bad English.
<div align="center">
<h2>Add Product</h2>
<form onSubmit="return saveData();" action="user.php" method="post">
<ul style="text-decoration: none; list-style: none">
<li>Consumer Request :</li>
<li><input type="text" name="cons_req"></li>
<li>Check & Verification</li>
<li><input type="text" name="chk_ver"></li>
<li>MNP Transaction</li>
<li><input type="text" name="mnp_trns"></li>
<li>Point</li>
<li><input type="text" name="point"></li><br>
<li><input type="submit" id="save" name="save" value="save" class="btn-danger"><br><br><br><br>
</li>
</ul>
</form>
</div>
<div align="center">
<table style="color: #fff; background: #333; border: 2px solid #fff">
<tr style="color: #fff; background:rgba(201,5,8,1.00); border: 2px solid #fff">
<th style="border: 2px solid #fff; padding: 5px">Consumer Request</th>
<th style="border: 2px solid #fff; padding: 5px">Check & Verification</th>
<th style="border: 2px solid #fff; padding: 5px">MNP Transaction</th>
<th style="border: 2px solid #fff; padding: 5px">Point</th>
<th style="border: 2px solid #fff; padding: 5px">Update</th>
<th style="border: 2px solid #fff; padding: 5px">Delete</th>
</tr>
<tbody id="data" style="color: #333; background: #fff; border: 2px solid #fff" align="center"></tbody>
</table>
</div>
and below is my process code.
<?php
$db = mysqli_connect("localhost", "root", "", "mifaresystem"); // Create database connection
$msg = ""; // Initialize message variable
if(isset($_POST['save'])) // If upload button is clicked ...
{
$cons_req = mysqli_real_escape_string($db, $_POST['cons_req']);
$chk_ver = mysqli_real_escape_string($db, $_POST['chk_ver']);
$mnp_trns = mysqli_real_escape_string($db, $_POST['mnp_trns']);
$point = mysqli_real_escape_string($db, $_POST['point']);
$sql = "INSERT INTO productivity_request (`consumer_request`, `check_ver`, `mnp_transaction`, `point`) VALUES ('$cons_req', '$chk_ver', '$mnp_trns', '$point')";
// execute query
if(mysqli_query($db, $sql))
{
header("Location: javainsert.php");
exit;
}else{
echo json_encode('problem');
}
}
?>
javascript php jquery html
add a comment |
up vote
0
down vote
favorite
I would like to ask if anyone know how to solved my issue.
I have Form with 4 and I want save the data into the database.
the problem is I want add data with blank input.
Example 1 :
Consumer Request : data = test and submit the form. the others text box I want it blank and mydatabase only Consumer Request data insert into database.
Example 1 :
Check & Verification : data = 'test', and submit the form. the others text box I want it blank and mydatabase only Check & Verification data insert into database.
The real issue is If I only insert 1 text box the system cannot work. but if I insert all 4 texbox the data will insert into database without no issue.
Sorry if my explaination a bit confius and my bad English.
<div align="center">
<h2>Add Product</h2>
<form onSubmit="return saveData();" action="user.php" method="post">
<ul style="text-decoration: none; list-style: none">
<li>Consumer Request :</li>
<li><input type="text" name="cons_req"></li>
<li>Check & Verification</li>
<li><input type="text" name="chk_ver"></li>
<li>MNP Transaction</li>
<li><input type="text" name="mnp_trns"></li>
<li>Point</li>
<li><input type="text" name="point"></li><br>
<li><input type="submit" id="save" name="save" value="save" class="btn-danger"><br><br><br><br>
</li>
</ul>
</form>
</div>
<div align="center">
<table style="color: #fff; background: #333; border: 2px solid #fff">
<tr style="color: #fff; background:rgba(201,5,8,1.00); border: 2px solid #fff">
<th style="border: 2px solid #fff; padding: 5px">Consumer Request</th>
<th style="border: 2px solid #fff; padding: 5px">Check & Verification</th>
<th style="border: 2px solid #fff; padding: 5px">MNP Transaction</th>
<th style="border: 2px solid #fff; padding: 5px">Point</th>
<th style="border: 2px solid #fff; padding: 5px">Update</th>
<th style="border: 2px solid #fff; padding: 5px">Delete</th>
</tr>
<tbody id="data" style="color: #333; background: #fff; border: 2px solid #fff" align="center"></tbody>
</table>
</div>
and below is my process code.
<?php
$db = mysqli_connect("localhost", "root", "", "mifaresystem"); // Create database connection
$msg = ""; // Initialize message variable
if(isset($_POST['save'])) // If upload button is clicked ...
{
$cons_req = mysqli_real_escape_string($db, $_POST['cons_req']);
$chk_ver = mysqli_real_escape_string($db, $_POST['chk_ver']);
$mnp_trns = mysqli_real_escape_string($db, $_POST['mnp_trns']);
$point = mysqli_real_escape_string($db, $_POST['point']);
$sql = "INSERT INTO productivity_request (`consumer_request`, `check_ver`, `mnp_transaction`, `point`) VALUES ('$cons_req', '$chk_ver', '$mnp_trns', '$point')";
// execute query
if(mysqli_query($db, $sql))
{
header("Location: javainsert.php");
exit;
}else{
echo json_encode('problem');
}
}
?>
javascript php jquery html
I already know the issue. It because mydatabase for 1 of the data type is INT. Anyone how to insert empty string to INT?
– Redline
Nov 11 at 14:26
stackoverflow.com/questions/28606483/… but it is definitely a bad idea! Rather change the data type of your field!
– rf1234
Nov 11 at 15:33
Thanks. I already change my data type. and it work. :)
– Redline
Nov 12 at 4:05
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to ask if anyone know how to solved my issue.
I have Form with 4 and I want save the data into the database.
the problem is I want add data with blank input.
Example 1 :
Consumer Request : data = test and submit the form. the others text box I want it blank and mydatabase only Consumer Request data insert into database.
Example 1 :
Check & Verification : data = 'test', and submit the form. the others text box I want it blank and mydatabase only Check & Verification data insert into database.
The real issue is If I only insert 1 text box the system cannot work. but if I insert all 4 texbox the data will insert into database without no issue.
Sorry if my explaination a bit confius and my bad English.
<div align="center">
<h2>Add Product</h2>
<form onSubmit="return saveData();" action="user.php" method="post">
<ul style="text-decoration: none; list-style: none">
<li>Consumer Request :</li>
<li><input type="text" name="cons_req"></li>
<li>Check & Verification</li>
<li><input type="text" name="chk_ver"></li>
<li>MNP Transaction</li>
<li><input type="text" name="mnp_trns"></li>
<li>Point</li>
<li><input type="text" name="point"></li><br>
<li><input type="submit" id="save" name="save" value="save" class="btn-danger"><br><br><br><br>
</li>
</ul>
</form>
</div>
<div align="center">
<table style="color: #fff; background: #333; border: 2px solid #fff">
<tr style="color: #fff; background:rgba(201,5,8,1.00); border: 2px solid #fff">
<th style="border: 2px solid #fff; padding: 5px">Consumer Request</th>
<th style="border: 2px solid #fff; padding: 5px">Check & Verification</th>
<th style="border: 2px solid #fff; padding: 5px">MNP Transaction</th>
<th style="border: 2px solid #fff; padding: 5px">Point</th>
<th style="border: 2px solid #fff; padding: 5px">Update</th>
<th style="border: 2px solid #fff; padding: 5px">Delete</th>
</tr>
<tbody id="data" style="color: #333; background: #fff; border: 2px solid #fff" align="center"></tbody>
</table>
</div>
and below is my process code.
<?php
$db = mysqli_connect("localhost", "root", "", "mifaresystem"); // Create database connection
$msg = ""; // Initialize message variable
if(isset($_POST['save'])) // If upload button is clicked ...
{
$cons_req = mysqli_real_escape_string($db, $_POST['cons_req']);
$chk_ver = mysqli_real_escape_string($db, $_POST['chk_ver']);
$mnp_trns = mysqli_real_escape_string($db, $_POST['mnp_trns']);
$point = mysqli_real_escape_string($db, $_POST['point']);
$sql = "INSERT INTO productivity_request (`consumer_request`, `check_ver`, `mnp_transaction`, `point`) VALUES ('$cons_req', '$chk_ver', '$mnp_trns', '$point')";
// execute query
if(mysqli_query($db, $sql))
{
header("Location: javainsert.php");
exit;
}else{
echo json_encode('problem');
}
}
?>
javascript php jquery html
I would like to ask if anyone know how to solved my issue.
I have Form with 4 and I want save the data into the database.
the problem is I want add data with blank input.
Example 1 :
Consumer Request : data = test and submit the form. the others text box I want it blank and mydatabase only Consumer Request data insert into database.
Example 1 :
Check & Verification : data = 'test', and submit the form. the others text box I want it blank and mydatabase only Check & Verification data insert into database.
The real issue is If I only insert 1 text box the system cannot work. but if I insert all 4 texbox the data will insert into database without no issue.
Sorry if my explaination a bit confius and my bad English.
<div align="center">
<h2>Add Product</h2>
<form onSubmit="return saveData();" action="user.php" method="post">
<ul style="text-decoration: none; list-style: none">
<li>Consumer Request :</li>
<li><input type="text" name="cons_req"></li>
<li>Check & Verification</li>
<li><input type="text" name="chk_ver"></li>
<li>MNP Transaction</li>
<li><input type="text" name="mnp_trns"></li>
<li>Point</li>
<li><input type="text" name="point"></li><br>
<li><input type="submit" id="save" name="save" value="save" class="btn-danger"><br><br><br><br>
</li>
</ul>
</form>
</div>
<div align="center">
<table style="color: #fff; background: #333; border: 2px solid #fff">
<tr style="color: #fff; background:rgba(201,5,8,1.00); border: 2px solid #fff">
<th style="border: 2px solid #fff; padding: 5px">Consumer Request</th>
<th style="border: 2px solid #fff; padding: 5px">Check & Verification</th>
<th style="border: 2px solid #fff; padding: 5px">MNP Transaction</th>
<th style="border: 2px solid #fff; padding: 5px">Point</th>
<th style="border: 2px solid #fff; padding: 5px">Update</th>
<th style="border: 2px solid #fff; padding: 5px">Delete</th>
</tr>
<tbody id="data" style="color: #333; background: #fff; border: 2px solid #fff" align="center"></tbody>
</table>
</div>
and below is my process code.
<?php
$db = mysqli_connect("localhost", "root", "", "mifaresystem"); // Create database connection
$msg = ""; // Initialize message variable
if(isset($_POST['save'])) // If upload button is clicked ...
{
$cons_req = mysqli_real_escape_string($db, $_POST['cons_req']);
$chk_ver = mysqli_real_escape_string($db, $_POST['chk_ver']);
$mnp_trns = mysqli_real_escape_string($db, $_POST['mnp_trns']);
$point = mysqli_real_escape_string($db, $_POST['point']);
$sql = "INSERT INTO productivity_request (`consumer_request`, `check_ver`, `mnp_transaction`, `point`) VALUES ('$cons_req', '$chk_ver', '$mnp_trns', '$point')";
// execute query
if(mysqli_query($db, $sql))
{
header("Location: javainsert.php");
exit;
}else{
echo json_encode('problem');
}
}
?>
<div align="center">
<h2>Add Product</h2>
<form onSubmit="return saveData();" action="user.php" method="post">
<ul style="text-decoration: none; list-style: none">
<li>Consumer Request :</li>
<li><input type="text" name="cons_req"></li>
<li>Check & Verification</li>
<li><input type="text" name="chk_ver"></li>
<li>MNP Transaction</li>
<li><input type="text" name="mnp_trns"></li>
<li>Point</li>
<li><input type="text" name="point"></li><br>
<li><input type="submit" id="save" name="save" value="save" class="btn-danger"><br><br><br><br>
</li>
</ul>
</form>
</div>
<div align="center">
<table style="color: #fff; background: #333; border: 2px solid #fff">
<tr style="color: #fff; background:rgba(201,5,8,1.00); border: 2px solid #fff">
<th style="border: 2px solid #fff; padding: 5px">Consumer Request</th>
<th style="border: 2px solid #fff; padding: 5px">Check & Verification</th>
<th style="border: 2px solid #fff; padding: 5px">MNP Transaction</th>
<th style="border: 2px solid #fff; padding: 5px">Point</th>
<th style="border: 2px solid #fff; padding: 5px">Update</th>
<th style="border: 2px solid #fff; padding: 5px">Delete</th>
</tr>
<tbody id="data" style="color: #333; background: #fff; border: 2px solid #fff" align="center"></tbody>
</table>
</div>
<div align="center">
<h2>Add Product</h2>
<form onSubmit="return saveData();" action="user.php" method="post">
<ul style="text-decoration: none; list-style: none">
<li>Consumer Request :</li>
<li><input type="text" name="cons_req"></li>
<li>Check & Verification</li>
<li><input type="text" name="chk_ver"></li>
<li>MNP Transaction</li>
<li><input type="text" name="mnp_trns"></li>
<li>Point</li>
<li><input type="text" name="point"></li><br>
<li><input type="submit" id="save" name="save" value="save" class="btn-danger"><br><br><br><br>
</li>
</ul>
</form>
</div>
<div align="center">
<table style="color: #fff; background: #333; border: 2px solid #fff">
<tr style="color: #fff; background:rgba(201,5,8,1.00); border: 2px solid #fff">
<th style="border: 2px solid #fff; padding: 5px">Consumer Request</th>
<th style="border: 2px solid #fff; padding: 5px">Check & Verification</th>
<th style="border: 2px solid #fff; padding: 5px">MNP Transaction</th>
<th style="border: 2px solid #fff; padding: 5px">Point</th>
<th style="border: 2px solid #fff; padding: 5px">Update</th>
<th style="border: 2px solid #fff; padding: 5px">Delete</th>
</tr>
<tbody id="data" style="color: #333; background: #fff; border: 2px solid #fff" align="center"></tbody>
</table>
</div>
<?php
$db = mysqli_connect("localhost", "root", "", "mifaresystem"); // Create database connection
$msg = ""; // Initialize message variable
if(isset($_POST['save'])) // If upload button is clicked ...
{
$cons_req = mysqli_real_escape_string($db, $_POST['cons_req']);
$chk_ver = mysqli_real_escape_string($db, $_POST['chk_ver']);
$mnp_trns = mysqli_real_escape_string($db, $_POST['mnp_trns']);
$point = mysqli_real_escape_string($db, $_POST['point']);
$sql = "INSERT INTO productivity_request (`consumer_request`, `check_ver`, `mnp_transaction`, `point`) VALUES ('$cons_req', '$chk_ver', '$mnp_trns', '$point')";
// execute query
if(mysqli_query($db, $sql))
{
header("Location: javainsert.php");
exit;
}else{
echo json_encode('problem');
}
}
?>
<?php
$db = mysqli_connect("localhost", "root", "", "mifaresystem"); // Create database connection
$msg = ""; // Initialize message variable
if(isset($_POST['save'])) // If upload button is clicked ...
{
$cons_req = mysqli_real_escape_string($db, $_POST['cons_req']);
$chk_ver = mysqli_real_escape_string($db, $_POST['chk_ver']);
$mnp_trns = mysqli_real_escape_string($db, $_POST['mnp_trns']);
$point = mysqli_real_escape_string($db, $_POST['point']);
$sql = "INSERT INTO productivity_request (`consumer_request`, `check_ver`, `mnp_transaction`, `point`) VALUES ('$cons_req', '$chk_ver', '$mnp_trns', '$point')";
// execute query
if(mysqli_query($db, $sql))
{
header("Location: javainsert.php");
exit;
}else{
echo json_encode('problem');
}
}
?>
javascript php jquery html
javascript php jquery html
asked Nov 11 at 12:35
Redline
252
252
I already know the issue. It because mydatabase for 1 of the data type is INT. Anyone how to insert empty string to INT?
– Redline
Nov 11 at 14:26
stackoverflow.com/questions/28606483/… but it is definitely a bad idea! Rather change the data type of your field!
– rf1234
Nov 11 at 15:33
Thanks. I already change my data type. and it work. :)
– Redline
Nov 12 at 4:05
add a comment |
I already know the issue. It because mydatabase for 1 of the data type is INT. Anyone how to insert empty string to INT?
– Redline
Nov 11 at 14:26
stackoverflow.com/questions/28606483/… but it is definitely a bad idea! Rather change the data type of your field!
– rf1234
Nov 11 at 15:33
Thanks. I already change my data type. and it work. :)
– Redline
Nov 12 at 4:05
I already know the issue. It because mydatabase for 1 of the data type is INT. Anyone how to insert empty string to INT?
– Redline
Nov 11 at 14:26
I already know the issue. It because mydatabase for 1 of the data type is INT. Anyone how to insert empty string to INT?
– Redline
Nov 11 at 14:26
stackoverflow.com/questions/28606483/… but it is definitely a bad idea! Rather change the data type of your field!
– rf1234
Nov 11 at 15:33
stackoverflow.com/questions/28606483/… but it is definitely a bad idea! Rather change the data type of your field!
– rf1234
Nov 11 at 15:33
Thanks. I already change my data type. and it work. :)
– Redline
Nov 12 at 4:05
Thanks. I already change my data type. and it work. :)
– Redline
Nov 12 at 4:05
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248813%2fdata-not-insert-not-insert-with-blank-textbox-using-php-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I already know the issue. It because mydatabase for 1 of the data type is INT. Anyone how to insert empty string to INT?
– Redline
Nov 11 at 14:26
stackoverflow.com/questions/28606483/… but it is definitely a bad idea! Rather change the data type of your field!
– rf1234
Nov 11 at 15:33
Thanks. I already change my data type. and it work. :)
– Redline
Nov 12 at 4:05