0

HTML とページにサイトがあり、訪問者を dj のプロファイルに移動するためのボタンがあります。

各ボタンは、訪問者を別の dj プロファイルに移動します。DJ の情報を取得する XML ドキュメントに移動する html でページを作成します。それで、私の質問は、どうすれば php ページのリンクに dj の名前を追加して、彼が個人的なリンクにとどまることができるかということです。

プロパティの取得を試みましたが、PHP がその dj の情報を取得するには、投稿も必要です。

djspace.html ページの html には次のものがあります。

<form name="form" id="form" method="post"  action="allProfiles.php">
  <input type="submit" name="dj_name" value="Blowdrop"/> 
</form>
...
<form name="form" id="form" method="post"  action="allProfiles.php">
  <input type="submit" name="dj_name" value="Psychokiller"/> 
</form>

そして、私の allprofiles.php ページ:

<?php
  $counter = 0;
  $dj_name = ($_POST['dj_name']);
  $xml = simplexml_load_file("Profiles.xml");

  foreach ($xml as $newprofile){
    if($xml->newprofile[$counter]->Anome == $dj_name){
      $Anome           = $xml->newprofile[$counter]->Anome;
      $nacionalidade   = $xml->newprofile[$counter]->nacionalidade;
      $naturalidade    = $xml->newprofile[$counter]->naturalidade;
      $residencia      = $xml->newprofile[$counter]->residencia;
      $emprego         = $xml->newprofile[$counter]->emprego;
      $generos         = $xml->newprofile[$counter]->generos;
      $disponibilidade = $xml->newprofile[$counter]->disponibilidade;
      $partilha        = $xml->newprofile[$counter]->partilha;
      $sitios          = $xml->newprofile[$counter]->sitios;
      $tempo           = $xml->newprofile[$counter]->tempo;
      $editora         = $xml->newprofile[$counter]->editora;
      $promotora       = $xml->newprofile[$counter]->promotora;
      $influencias     = $xml->newprofile[$counter]->influencias;
      $fblink          = $xml->newprofile[$counter]->fb;
      $scloud          = $xml->newprofile[$counter]->scloud;
      $mail            = $xml->newprofile[$counter]->email;
      $img             = $xml->newprofile[$counter]->foto;
    }
  $counter = $counter + 1;
}

?>

すべての情報を取得できますが、get を適用すると取得できません。

明らかに、php ページに直接アクセスすると、何も情報が得られません。 http://roundhillevents.com/allProfiles.php

ただし、このリンクに移動し、次に dj's、dj space をクリックして、情報を表示したいものをクリックしてください。

4

2 に答える 2

1

@Marc Bが提案したように、ボタン付きのフォームの代わりにリンクを使用してください。

何らかの理由でボタンを使い続けたい場合は、 に変更method="post"してmethod="get"ください。次に、ブラウザは dj 参照をページの URL に追加します。

もちろん、$_GET['dj_name'])代わりに$_POST['dj_name']PHP コードで使用する必要があります。GETこれは、メソッド付きのボタンとリンクの両方の場合です。

于 2013-04-12T16:49:53.000 に答える
0

これは、php で $_POST を使用しているためです。$_POST の代わりに $_REQUEST または $_GET グローバル変数を使用してみてください

これを試して

<?php
$counter = 0;
$dj_name = ($_REQUEST['dj_name']);
$xml = simplexml_load_file("Profiles.xml");
foreach ($xml as $newprofile){
if($xml->newprofile[$counter]->Anome == $dj_name){
$Anome = $xml->newprofile[$counter]->Anome;
$nacionalidade = $xml->newprofile[$counter]->nacionalidade;
$naturalidade = $xml->newprofile[$counter]->naturalidade;
$residencia = $xml->newprofile[$counter]->residencia;
$emprego = $xml->newprofile[$counter]->emprego;
$generos = $xml->newprofile[$counter]->generos;
$disponibilidade = $xml->newprofile[$counter]->disponibilidade;
$partilha = $xml->newprofile[$counter]->partilha;
$sitios = $xml->newprofile[$counter]->sitios;
$tempo = $xml->newprofile[$counter]->tempo;
$editora = $xml->newprofile[$counter]->editora;
$promotora = $xml->newprofile[$counter]->promotora;
$influencias = $xml->newprofile[$counter]->influencias;
$fblink = $xml->newprofile[$counter]->fb;
$scloud = $xml->newprofile[$counter]->scloud;
$mail = $xml->newprofile[$counter]->email;
$img = $xml->newprofile[$counter]->foto;
}
$counter = $counter + 1;
}
?>
于 2013-04-12T16:49:36.830 に答える