$ _Get和$ _POST正在杀了我

时间:2017-08-01 17:16:40

标签: php html mysql phpmyadmin

我有2个包含$ _GET $ _POST的代码,结果它没有出现在页面中,当我写var_dump($ _ GET)时,它会在其中打印正确的值,但我不知道为什么不显示在这里的页面是代码

def user_place_review(request,slug):
    place = PlaceReview.objects.get(slug=slug)

    form = UserPlaceReviewForm(request.POST or None)
    if form.is_valid():
        instance = form.save(commit=False)
        review = form.cleaned_data['review']
        instance.place = place
        instance.review = review
        instance.save()
        return redirect('/')




    context = {
    "form": form,
    }



    return render(request,"places/user_review.html", context)

这是其他页面中的$ _GET:

   <?php            
     $sql="SELECT OrgName, City, OrgEmail, OrgPhoneNO, Workfield, Trainingrequirements, WebsiteLink,OrgID
     FROM oraganzation";

   $result= mysqli_query($con,$sql) or die ("could not found; 
        ".mysqli_error($con));

      while ($row=mysqli_fetch_array($result) )
        {
          $name=$row['OrgName'];
          ?>

          <div class="content "> 
     <a href="training.php?name=<?php echo $name ?> "><?php echo $name;?> 
                    </a>
            <?php
        echo "<br><strong> City : </strong>". $row['City'].
        "<br><strong>
       Email: </strong>" . $row['OrgEmail'].
       "<br><strong>
       PhoneNO: </strong>". $row['OrgPhoneNO'].
      "<br> <strong>
     Work field: </strong> " . $row['Workfield'].
      "<br><strong>
      Training requirements:</strong> " . $row['Trainingrequirements'].
       "<br> <strong>
      Website Link: </strong> " . $row['WebsiteLink']. 


            "</div> ";} ?>       

}

输出显示此

     var_dump($_GET);
   if (isset($_GET['$name']))
       {
      $namet=$_GET['$name'];


     $sql="SELECT OrgID , OrgName, City, OrgEmail, OrgPhoneNO, Workfield, Trainingrecruitment, WebsiteLink
          FROM oraganzation
           WHERE OrgName='$namet'";

      $result= mysqli_query($sql) or die ("could not found; ".mysqli_error($con));

        while ($row=mysqli_fetch_array($result) )
        {
       $id=$row['OrgID'];   
         echo "<br><strong> Name : </strong>". $row['OrgName'].
       "<br><strong>
       <br><strong> City : </strong>". $row['City'].
      "<br><strong>
      Email: </strong>" . $row['OrgEmail'].
     "<br><strong>
     PhoneNO: </strong>". $row['OrgPhoneNO'].
     "<br> <strong>
     Work field: </strong> " . $row['Workfield'].
    "<br><strong>
    Training recruitment:</strong> " . $row['Trainingrecruitment'].
    "<br> <strong>
      Website Link: </strong> " . $row['WebsiteLink']."<br>" ;
            }

1 个答案:

答案 0 :(得分:4)

您正试图从此GET变量访问您的数据

$namet=$_GET['$name'];

GET中没有$ name,它应该是

$namet=$_GET['name'];