Skip to content

Instantly share code, notes, and snippets.

View ridoansaleh's full-sized avatar
🎯
Focusing

RSN ridoansaleh

🎯
Focusing
  • Indonesia
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Belajar React</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
</head>
form {
border: 3px solid #f1f1f1;
width: 350px;
}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<form action="" method="post">
<h2>Login here..</h2>
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>Session 2</title>
</head>
<body>
<?php
if(isset($_SESSION['login'])){
echo "Selamat datang, <b>".$_SESSION['login']."</b>.";
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'music',
)
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include('music.urls')),
]
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name="index"),
url(r'^edit/(?P<pk>\d+)$', views.edit, name='edit'),
url(r'^delete/(?P<pk>\d+)$', views.delete, name='delete'),
]
from django.db import models
class Song(models.Model):
genre_choices = (
('Pop', 'Pop'),
('Reggae', 'Reggae'),
('Country', 'Country'),
('Jazz', 'Jazz'),
('Hip Hop', 'Hip Hop'),
('Rock', 'Rock'),
from django.forms import ModelForm
from .models import Song
class SongForm(ModelForm):
class Meta:
model = Song
fields = ['title', 'genre', 'singer', 'rating']
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponseRedirect
from .forms import SongForm
from .models import Song
def index(request):
status = ''
if request.method == 'POST':
form = SongForm(request.POST)
if form.is_valid():