我真的越来越沮丧。我正在将我的网站从 php 5.2 移动到 php 5.3。将信息从我的表单添加到 mysql 数据库时,会添加一条空记录,并且我收到此错误消息,它们是相互连接的。错误日志消息是:
[Tue Jul 16 12:37:08 2013] [warn] [client XX.XX.XXX.XXXX] mod_fcgid: stderr: PHP Notice: Undefined variable: prijs in XXX/page.php on line 100, referer: XXX/page.php
[Tue Jul 16 12:37:08 2013] [warn] [client XX.XX.XXX.XXXX] mod_fcgid: stderr: PHP Notice: Undefined index: type_contract in XXX/page.php on line 116, referer: XXX/page.php
[Tue Jul 16 12:37:08 2013] [warn] [client XX.XX.XXX.XXXX] mod_fcgid: stderr: PHP Notice: Undefined index: klantnummer in XXX/page.php on line 117, referer: XXX/page.php
[Tue Jul 16 12:37:08 2013] [warn] [client XX.XX.XXX.XXXX] mod_fcgid: stderr: PHP Notice: Undefined index: datum in XXX/page.php on line 118, referer: XXX/page.php
[Tue Jul 16 12:37:08 2013] [warn] [client XX.XX.XXX.XXXX] mod_fcgid: stderr: PHP Notice: Undefined index: omschrijving in XXX/page.php on line 119, referer: XXX/page.php
我已经尝试了一切,比如添加
if (isset($_POST['prijs'])) { $prijs = $_POST['prijs']; }
它所指的代码是:
<?php if (isset($_GET['action']) && ($_GET['action'] == "abonnement_toevoegen")) {
$prijs = $_POST['prijs']; <=== this is the code is referring to!!!
$prijs_comma = str_ireplace(",", ".", "$prijs");
$prijs = $prijs_comma;
$btw = $prijs * 0.21;
$totaal = $prijs + $btw;
$prijs = round($prijs, 2);
$btw = round($btw, 2);
$totaal = round($totaal, 2);
$prijs_weergave = str_ireplace(".", ",", "$prijs");
$btw_weergave = str_ireplace(".", ",", "$btw");
$totaal_weergave = str_ireplace(".", ",", "$totaal");
include("include_addslashes.php");
$type_contract = $_POST['type_contract']; <=== this is the code is referring to!!!
$klantnummer = $_POST['klantnummer']; <=== this is the code is referring to!!!
$datum = $_POST['datum']; <=== this is the code is referring to!!!
$omschrijving = $_POST['omschrijving']; <=== this is the code is referring to!!!
$sql = "INSERT INTO wi_abonnementen
(
type_contract,
klant_id,
factuurdatum,
omschrijving,
prijs,
btw,
totaal
)
VALUES
(
'$type_contract',
'$klantnummer',
'$datum',
'$omschrijving',
'$prijs_weergave',
'$btw_weergave',
'$totaal_weergave'
)";
if (!mysql_query($sql, $con)) {
die('Error: ' . mysql_error());
}
include("include_stripslashes.php");
var_dump($_POST);
?>
请帮忙,我在不同的网站上一遍又一遍地收到此错误消息。
表单的 HTML 代码为:
<form action="finance.php?action=abonnement_toevoegen" method="post" name="abonnement_toevoegen">
<table>
<tr>
<td>Type</td>
<td><select name="type_contract" size="1">
<option value="">Kies een optie</option>
<option value="tco">TouringcarOfferte</option>
<option value="tao">TaxiOfferte</option>
<option value="wih">Wi4 Hosting</option>
<option value="wii">Wi4 Internet diensten</option>
</select></td>
</tr>
<tr>
<td>Klant</td>
<td><select name="klantnummer" size="1">
<option value="">Kies een optie</option>
<option value=""> ()</option>
<option value="wi126">XXX (wi126)</option>
<option value="Wi154">XXX (Wi154)</option>
<option value="wi108">XXX (wi108)</option>
</select>
</td>
</tr>
<tr>
<td>Factuurdatum</td>
<td><input class="form" type="Text" name="datum" value="2013-07-17" size="10"> </td>
</tr>
<tr>
<td valign="top">Omschrijving</td>
<td><textarea class="form" name="omschrijving" cols="25" rows="4"></textarea> </td>
</tr>
<tr>
<td>Prijs (excl. BTW)</td>
<td>€ <input class="form" type="Text" name="prijs" value="" size="10"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td><input type="submit" class="form" value="Voeg toe"></td>
</tr>
</table>
<div id='abonnement_toevoegen_errorloc' class='error_strings'></div>
</form>
谢谢!