$ _POST错误

时间:2015-07-08 03:52:41

标签: php mysql

好吧,我把问题缩小到一组代码,这里是:

<?php
  if( isset($_POST['submit'])){
    **if($_POST['shortsitename'] == ""){$newshortsitename = $shortsitename;}else{ $newshortsitename = $_POST['shortsitename'];}
    if($_POST['organization'] == ""){$neworganization = $organization;}else{$neworganization = $_POST['organization'];}
    if($_POST['city'] == ""){$newcity = $city;}else{$newcity = $_POST['city'];}
    if($_POST['state'] == ""){$newstate = $state;}else{$newstate = $_POST['state'];}**

      $user_lvl = \Fr\LS::getUser("user_lvl");
      $updateGroup = \Fr\LS::updateGroupinfo(
        array(
          "shortsitename" => $newshortsitename,
          "organization" => $neworganization,
          "city" => $newcity,
          "state" => $newstate
        ), $user_lvl
      );
      if($updateGroup === "success"){
        echo "<label>Success.</label>";
      }elseif($updateGroup === false){
        echo "<label>Update failed.";
      }
  ?>  

基本上,我有一个表单,允许用户在数据库中更改其组织的信息。但是,当我在站点中有此代码时,它返回内部服务器错误500.当我删除此代码块时,该站点显示正常。我的主要问题是,代码是否正确粗体,或者我是否想念它?

**编辑:它不会让我大胆的代码,但有&#34;明星&#34;围绕我正在谈论的代码。

1 个答案:

答案 0 :(得分:1)

您的更新失败<label>标记没有结束</label>,我认为您最终错过了2 }。上面定义了$shortsitename吗?

<?php
if( isset($_POST['submit'])){
    //**
    if($_POST['shortsitename'] == ""){
        $newshortsitename = $shortsitename;
    }else{ 
        $newshortsitename = $_POST['shortsitename'];
    }
    if($_POST['organization'] == ""){
        $neworganization = $organization;
    }else{
        $neworganization = $_POST['organization'];
    }
    if($_POST['city'] == ""){
        $newcity = $city;
    }else{      
        $newcity = $_POST['city']; 
    }           
    if($_POST['state'] == ""){
        $newstate = $state;}else{
            $newstate = $_POST['state'];
        }
        //**
        $user_lvl = \Fr\LS::getUser("user_lvl");
        $updateGroup = \Fr\LS::updateGroupinfo(
            array(                      
                "shortsitename" => $newshortsitename,
                "organization" => $neworganization,
                "city" => $newcity,         
                "state" => $newstate        
            ), $user_lvl                
        );                          
        if($updateGroup === "success"){
            echo "<label>Success.</label>";

        }elseif($updateGroup === false){
            echo "<label>Update failed.";
        }                           
?> 

以上是您的代码的重新格式化版本。