-1

I'm trying to insert records in a MySQL DB, but I'm getting no values from the POST variable.

I can see a new record is being entered with a record ID, but 0 in the next and only cell in the table. The cell type is a Double in form.html.

I've hidden the submit button for design purposes. This is developed for a mobile experience.

upload.php

<?php
$con=mysqli_connect("localhost","user","password","DB");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$cal = mysqli_real_escape_string($con, $_POST['cali']);
$sql="INSERT INTO `calibration` (`Calibration`) VALUES ('$cal')";
echo $sql;
if (!mysqli_query($con,$sql)) {
  die('Error: ' . mysqli_error($con));
}
echo "Calibration Complete!";

mysqli_close($con);
?> 

form.html

<form enctype="text/plain" action="upload.php" method="POST">
<input type="text" name="cali" value="Please calibration value" onclick='javascript: this.value = ""' >
<input type="submit" style="margin-left: -1000px;">
</form>

Thank you in advance!

Showcase Imagery
  • 372
  • 2
  • 19
ahmadux
  • 2,667
  • 3
  • 17
  • 15

1 Answers1

0

As per OP's request.

Another thing besides Björn's comment <= (giving credit to).

The onclick is setting the value to ""

Remove this enctype="text/plain" and you should be good to go.

A more detailed explanation about the use of enctype="text/plain" can be found on Stack, with the following answer given:

including a link to https://bugs.php.net/bug.php?id=33741

with the following at the end of that page:

Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you.

Thank you for your interest in PHP. Valid values for enctype in tag are:

  • application/x-www-form-urlencoded

  • multipart/form-data

Community
  • 1
  • 1
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141