Problem is in the INSERT INTO statement. I'm trying to insert $today, $id, $stat_sum, $klientas. Everything is inserting except the $id. After I press the submit button, everything is inserting, but where there should be the $id, it shows NULL. I tried to echo $id , it showing normally as it should be.
$today = date('Y-m-d G:i:s');
if( isset($_GET['pas']) )
{
$id = $_GET['pas'];
$res= mysql_query("SELECT MAX(statymo_suma) FROM statymai WHERE aukciono_id = '$id'");
$row= mysql_fetch_array($res);
echo $id;
}
if( isset($_POST['stat_sum']) )
{
echo '<input type="hidden" name="id" value="<?php echo $row[2]; ?>">';
$stat_sum = $_POST['stat_sum'];
$id = $_POST['id'];
$res1= mysql_query("SELECT kliento_id FROM klientai WHERE vartotojo_vardas = '$user_check'");
$row1 = mysql_fetch_assoc($res1);
$klientas = $row1['kliento_id'];
$sql = "INSERT INTO statymai (statymo_laikas,aukciono_id,statymo_suma,kliento_id) VALUES ('$today','$id','$stat_sum','$klientas')";
$res =mysql_query($sql)
or die("Negaliu redaguoti".mysql_error());
//echo "<meta http-equiv='refresh' content='0;url=redaguoti.php'>";
}
?>
<form action="pasiulymas.php" method="POST">
Statymo suma: <input type="text" name="stat_sum" value="<?php echo $row[0]; ?>"><br />
<input type="hidden" name="id" value="<?php echo $row[2]; ?>">
<input type="submit" value=" =Redaguoti "/>
</form>
var_dump($sql) result:
string(123) "INSERT INTO statymai (statymo_laikas,aukciono_id,statymo_suma,kliento_id) VALUES ('2015-12-20 15:04:50','','123456','KL01')"