誰かが私を助けてくれるのではないかと思います。
私はこれに慣れていないので、最初に謝罪します。そのため、これは非常に基本的なエラーのように見えるかもしれません。
以下のフォームを使用して、ユーザーがすべて「場所」レコードに基づいて異なるページ間を移動できるようにしています。
<form name="locations" id="locations" method="post" action="locationsaction.php">
<?php
<table width="538" border="0">
<tr>
<th width="119"><div align="left">Location Name</div></th>
<th width="159"><div align="left">Address</div></th>
<th width="94"><div align="center">No. Of Finds</div></th>
<th width="69"></th>
<th width="66"></th>
<th width="5"></th>
</tr>
<tr>
<td><div align="left"><?php echo $lid;?></div></td>
<td><div align="left"><?php echo $lname;?></div></td>
<td><div align="left"><?php echo $laddress;?></div></td>
<td><div align="center"><?php echo $findscount?></div></td>
<td><div align="center"><input name="type" type="submit" value="View Details"/></div></td>
<td><div align="center"><input name="type" type="submit" value="Add Finds"/></div></td>
<td><div align="center"><input name="type" type="submit" value=" Add Images"/></div></td>
</tr>
<tr><th colspan="8"><br/><hr width="100%"></th></tr>
</table>
<?php
</form>
フォームの最後に、ユーザーを別のページに移動させる 3 つの [送信] ボタンがあることに気付くでしょう。次の PHP スクリプトは、どのボタンが選択されているかを判断するために使用され、上記のForm POST
アクションでは次のように示されています。locationsaction.php
<?php
if (isset($_POST['type'])) {
$urls = array(
'View Details' => 'updatelocation.php',
'Add Finds' => 'addfinds.php',
'Add Images' => 'image.php'
);
$url = $urls[$_POST['type']];
header("Location: " . $url);
}
?>
ボタンは正常に機能しますが、ユーザーを正しいページに移動させるため$lid
、3 つの受信ページのいずれにも変数を渡すことができず、次のエラーが表示されます。
Notice: Undefined index: lid in /homepages/2/d333603417/htdocs/updatelocation.php
$lid
これは、すべての受信ページで変数を取得しようとしている方法です。
$lid = $_POST['lid'];
このサイトのいくつかのチュートリアルと投稿に目を通しましたが、どこが間違っているのかわかりません。
誰かがこれを見て、どこが間違っているのか教えてくれるかどうか疑問に思いましたか?
多くの感謝と親切な敬意