ニュースレターを購読または購読解除できるフォームがあります(これは機能します)。問題は、データベースにデータを挿入したいときに問題が発生することです。フォーム自体は次のとおりです。
<form action="subscriptionsedit2.php?CusID=<?=$_GET[">
" name="frmEdit" method="post"> <?php
$objConnect = mysql_connect("localhost","root","root") or die(mysql_error());
$objDB = mysql_select_db("NAW");
$strSQL1 = "SELECT ID, Titel FROM Mail";
$strSQL = "SELECT * FROM Klant WHERE ID = '".$_GET["ID"]."' ";
$objQuery = mysql_query($strSQL);
$objQuery1 = mysql_query($strSQL1);
$objResult = mysql_fetch_array($objQuery);
if(!$objResult)
{
echo "Not found ID=".$_GET["ID"];
}
else
{
?>
<fieldset>
<legend>Wijzig</legend>
<table width="600" border="1">
<tr>
<th width="91">
<div align="center">
ID
</div>
</th>
</tr>
<tr>
<td>
<div align="center">
<?=$objResult["ID"];?>
</div>
</td>
</tr>
</table><br>
<table width="600" border="1">
<tr>
<th width="91">
<div align="center">
ID
</div>
</th>
<th width="91">
<div align="center">
Subscribe
</div>
</th>
<th width="91">
<div align="center">
Unsubscribe
</div>
</th>
</tr><?php
$i = 0;
while($objResult1 = mysql_fetch_array($objQuery1))
{
$i++;
?>
<tr>
<td>
<div align="center">
<?=$objResult1["ID"];?>
</div>
</td>
<td>
<div align="center">
<input type="checkbox" name="sub" value="10">
</div>
</td>
<td>
<div align="center">
<input type="checkbox" name="sub" value="90">
</div>
</td>
</tr><?php
}
?>
</table>
</fieldset><!-- content --><input type="submit" name="submit" value="Submit"> <input type="button" name="cancel" value="Cancel" onclick="window.location='klanten.php'"> <?php
}
mysql_close($objConnect);
?>
</form>
Subscriptionsedit2.phpの場合データは次のようにデータベースに挿入されます。
mysql_connect('localhost','root','root');
mysql_select_db('NAW') or die (mysql_error());
$Klant_ID = $objResult["ID"];
$Mail_ID = $objResult1["ID"];
$Status = $_POST['sub'];
$Datum = date("d-m-y");
$sql = mysql_query("INSERT INTO Subscriptions (Klant_ID, Mail_ID, Status, Datum) VALUES ('".$Klant_ID."', '".$Mail_ID."', '".$Status."', '".$Datum."')") or die (mysql_error());
これは私が得るエラーです:注意:未定義の変数:16行目の/var/www/Mail/subscriptionsedit2.phpのobjResult注意:未定義の変数:17行目の/var/www/Mail/subscriptionsedit2.phpのobjResult1
ご覧のとおり、変数$Klant_IDと$Mail_IDには値がありません。<?=$objResult["ID"];?>
だから私の質問は、Klant_ID( )とMail_ID(<?=$objResult1["ID"];?>
)を変数に正しく格納するにはどうすればよいですか?この質問が十分に明確であることを願っていますが、質問がある場合はコメントしてください^^。誰かがこれを行う方法についてアイデアを持っているなら、それは素晴らしいことです!