dougaimian1143 2019-03-11 09:52
浏览 65
已采纳

Codeigniter使用相同的表单进行保存和编辑

I am using the same view in CodeIgniter to save and edit. Successfully completed the saving functionality, when using the same form to edit the user. I am getting the error

Message: Undefined variable lastname

<form>
     <input type="text" class="form-control" id="lastname" name="lastname" placeholder="Last name" value="<?php echo $user->lastname; ?>">
</form>
  • 写回答

2条回答 默认 最新

  • douchun5976 2019-03-11 09:53
    关注
    <?php
    
    $last_name=NULL;
    if(isset($user->lastname)){
    $last_name=$user->lastname;
    }
    
    ?>
    
    
    <form>
         <input type="text" class="form-control" id="lastname" name="lastname" placeholder="Last name" value="<?php echo $lastname; ?>">
    </form>
    

    I hope this will work

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?