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');
}
}
?>












share|improve this question






















  • 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















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');
}
}
?>












share|improve this question






















  • 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













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');
}
}
?>












share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Bressuire

Vorschmack

Quarantine