線上書籍

Home

[1032]PHP入門

<?php $news_title=isset($_COOKIE['news_title'])?$_COOKIE['news_title']:""; $news_content=isset($_COOKIE['news_content'])?$_COOKIE['news_content']:""; ?> <!DOCTYPE html> <html lang="zh-TW"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>編輯新聞</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> </head> <body> <div class="container"> <h1>編輯新聞</h1> <div class="row"> <div class="col-md-9"> <!-- 表單 action指定變數欲送至的目的地,method指定變數傳送方式 --> <form action="index.php" method="post" role="form"> <div class="form-group"> <input type="text" name="news_title" placeholder="請輸入新聞標題" class="form-control" value="<?php echo $news_title;?>"> </div> <div class="form-group"> <textarea name="news_content" style="height:300px;" placeholder="請輸入新聞內容" class="form-control"><?php echo $news_content;?></textarea> </div> <div class="row"> <div class="col-md-3"> </div> <div class="col-md-3"> <?php echo $_SERVER['REMOTE_ADDR']; ?> </div> <div class="col-md-3"> <div class="form-group"> <input type="password" name="password" class="form-control" placeholder="請輸入密碼"> </div> </div> <div class="col-md-3"> <input type="hidden" name="op" value="save"> <input type="submit" value="儲存新聞" class="btn btn-info btn-block"> </div> </div> <?php $op=isset($_GET['op'])?$_GET['op']:""; if($op=="passwd_error"){ echo ' <div class="alert alert-danger"> 密碼錯誤!!請檢查密碼是否正確! </div> '; } ?> </form> </div> <div class="col-md-3"> <a href="index.php" class="btn btn-success btn-block">新聞列表</a> </div> </div> </div> </body> </html>