Blogs
Silahkan tonton video Membuat Halaman Admin Pengaturan Web di atas untuk mengikuti tutorial. Untuk mempermudah dalam pembelajaran, salin source code di bawah ini sesuai dengan tutorial Membuat Halaman Admin Pengaturan Web yang ada dalam video
Kode 1
use App\Models\AdminModel;
Kode 2
public function __construct() {
$this->callMdl = new AdminModel();
}
Kode 3
$data['item'] = $this->callMdl->where('id', 1)->first();
if($this->request->getVar('namaweb'))
{
$id = 1;
$data = [
'namaweb' => $this->request->getVar('namaweb'),
'copyright' => $this->request->getVar('copyright'),
];
$this->callMdl->update($id,$data);
return redirect()->to( base_url('admin/pengaturan') );
}
$data['title'] = 'Pengaturan Web';
echo view('admin/header', $data);
echo view('admin/pengaturan', $data);
echo view('admin/footer');
Kode 4
<?php namespace App\Models;
use CodeIgniter\Database\ConnectionInterface;
use CodeIgniter\Model;
class AdminModel extends Model
{
protected $table = 'admin';
protected $allowedFields = ['namaweb','copyright'];
}
?>
Kode 5
<div class="papan">
<form action="<?php echo base_url('admin/pengaturan');?>">
<div class="form-dft">
<label for="namaweb"><b>Nama web</b></label>
<input type="text" name="namaweb" value="<?php echo $item['namaweb']; ?>" required>
<label for="copyright"><b>Copyright</b></label>
<input type="text" name="copyright" value="<?php echo $item['copyright']; ?>" required>
<button type="submit" class="daftarbtn">Submit</button>
</div>
</form>
</div>
Posted in: CodeIgniter 4
Topics:
web berita
Be the first person to like this.
Hotelempfehlung
Ringhotel Zum Kreuz
736 | Hotels
Das Ringhotel Zum Kreuz befindet sich in Hauptstr. 26 - Steinheim am Albuch. Besteht aus 29 Zimmern
Steinheim am Albuch - Deutschland
Hotel Bartholomäus
725 | Hotels
Das Hotel Bartholomäus befindet sich in Hauptstrasse 81 - Zeitlarn. Besteht aus 38 Zimmern
Zeitlarn - Deutschland
Hotel Fischzucht
855 | Hotels
Das Hotel Fischzucht befindet sich in Julius-Echter-Straße 15 - Würzburg. Besteht aus 24 Zimmern
Würzburg - Deutschland