我在运行脚本时收到这些警告:
Notice: Undefined variable: varName in C:\wamp\www\dash\index.php on line 38
Notice: Undefined variable: varMsg in C:\wamp\www\dash\index.php on line 38
Notice: Undefined variable: varDate in C:\wamp\www\dash\index.php on line 38
此外,我可以将详细信息插入数据库,但每次刷新页面时都会插入查询。
脚本的重要部分:
<?php
date_default_timezone_set('UTC');
if(isset($_POST['formSumbit']))
{
$varName = $_POST['formName'];
$varMsg = $_POST['formMsg'];
$varDate = date(d/m/y);
$errorMessage = "";
}
//line 38
$order ="INSERT INTO dash (name,msg,msg_date) VALUES ('$varName','$varMsg','$varDate')";
$result = mysql_query($order);
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
name
<input type="text" name="formName" maxlength="25" />
msg
<input type="text" name="formMsg" maxlength="1500" />
<input type="submit" name="formSumbit" value="Submit" />
</form>