This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php session_start(); ?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Login</title> | |
</head> | |
<body> | |
<form action="" method="post"> | |
<h2>Login here..</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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>."; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = ( | |
'django.contrib.admin', | |
'django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', | |
'django.contrib.messages', | |
'django.contrib.staticfiles', | |
'music', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.forms import ModelForm | |
from .models import Song | |
class SongForm(ModelForm): | |
class Meta: | |
model = Song | |
fields = ['title', 'genre', 'singer', 'rating'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(): |
OlderNewer