我制作了这个小代码来跟踪我的日常开支和各种来源的收入。无论如何,第一个查询会增加记录 id + 添加时间。但是,第二个查询似乎没有做任何事情。有任何想法吗?这是代码:-
<?php
error_reporting(E_ALL);
include('dbconnector.php');
if(isset($_REQUEST['action']))
{
switch($_REQUEST['action'])
{
case 'inpute':
$amt=(isset($_POST['amt'])) ? $_POST['amt'] : '';
$desc=(isset($_POST['desc'])) ? $_POST['desc'] : '';
if(!empty($amt) && !empty($desc))
{
$query = 'insert into tb1(record_id,record_date) values (NULL,now())';
$result = mysql_query($query, $db);
$query2='insert into input(record_input_id,amt_in,in_desc) values (NULL,"' . $amt . '", "' . $desc . '"';
$result2=mysql_query($query2, $db);
if($result && $result2)
{
header('Location: index.php');
}
else
{
echo "Error";
}
}
else
{
echo "value cannot be null";
header('Refresh:3;URL = index.php');
}
break;
case 'outpute':
$amt=(isset($_POST['amt'])) ? $_POST['amt'] : '';
$desc=(isset($_POST['desc'])) ? $_POST['desc'] : '';
if(!empty($amt) && !empty($desc))
{
$query = 'insert into tb1(record_id,record_date) values (NULL,now())';
$result = mysql_query($query, $db);
$query2='insert into output(record_output_id,amt_out,out_desc) values(NULL,$amt, "' . $desc . '"';
$result2=mysql_query($query, $db);
if($result && $result2)
{
header('Location: index.php');
}
else
{
echo "Error";
}
}
else
{
echo "value cannot be null";
header('Refresh:3;URL = index.php');
}
break;
default:
header('Location: index.php');
}
}
?>