{"id":557,"date":"2017-01-27T14:26:47","date_gmt":"2017-01-27T07:26:47","guid":{"rendered":"http:\/\/www.yellowweb.id\/blog\/?p=557"},"modified":"2017-01-27T14:26:47","modified_gmt":"2017-01-27T07:26:47","slug":"membuat-random-password-di-php","status":"publish","type":"post","link":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/","title":{"rendered":"Membuat Random Password di PHP"},"content":{"rendered":"<p>Halo teman-teman pasti kalian pernah, misalnya daftar di forum atau di situs tertentu lalu mereka melakukan konfirmasi balasan dengan mengirimkan password untuk login. Password tersebut dalam kondisi acak atau random. Untuk tutorial kali ini kita akan mencoba membuat password acak dengan menggunakan PHP.<br \/>\n<!--more--><br \/>\nFile yang akan kita buat diantaranya:<br \/>\n<span style=\"color: #0000ff;\">File fungsi-acak.php<\/span><br \/>\n<span style=\"color: #0000ff;\">File koneksi.php<\/span><br \/>\n<span style=\"color: #0000ff;\">File insert-userpass.php<\/span><\/p>\n<p>Buat file untuk membuat fungsi acaknya.<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\tfunction acakpass($long){\r\n\t\t$huruf = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';\/\/buat karakter yang akan digunakan sebagai password\r\n\t\t$st = '';\r\n\t\tfor($i=0; $i&lt;$long; $i++){\r\n\t\t\t$p = rand(0, strlen($huruf)-1);\r\n\t\t\t$st .=$huruf{$p};\r\n\t\t}\r\n\t\treturn $st;\r\n\t}\r\n\t$us = acakpass(6); \/\/ untuk mencetak\r\n\t$ps = acakpass(8);\r\n?&gt;<\/pre>\n<p>Kita sudah membuat sebuah fungsi berikutnya, bagaimana caranya melakukan insert ke database?<br \/>\nBuat databasenya terlebih dahulu ya<\/p>\n<pre class=\"lang:default decode:true \">-- phpMyAdmin SQL Dump\r\n-- version 4.5.2\r\n-- http:\/\/www.phpmyadmin.net\r\n--\r\n-- Host: localhost\r\n-- Generation Time: Jan 27, 2017 at 08:15 AM\r\n-- Server version: 10.1.16-MariaDB\r\n-- PHP Version: 5.6.24\r\n\r\nSET SQL_MODE = \"NO_AUTO_VALUE_ON_ZERO\";\r\nSET time_zone = \"+00:00\";\r\n\r\n\r\n\/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT *\/;\r\n\/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS *\/;\r\n\/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION *\/;\r\n\/*!40101 SET NAMES utf8mb4 *\/;\r\n\r\n--\r\n-- Database: `db_userpass`\r\n--\r\n\r\n-- --------------------------------------------------------\r\n\r\n--\r\n-- Table structure for table `user`\r\n--\r\n\r\nCREATE TABLE `user` (\r\n  `id` int(5) NOT NULL,\r\n  `username` text NOT NULL,\r\n  `password` text NOT NULL\r\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r\n\r\n--\r\n-- Dumping data for table `user`\r\n--\r\n\r\nINSERT INTO `user` (`id`, `username`, `password`) VALUES\r\n(1, 'e0dE6o', 'eOUYbJx3');\r\n\r\n--\r\n-- Indexes for dumped tables\r\n--\r\n\r\n--\r\n-- Indexes for table `user`\r\n--\r\nALTER TABLE `user`\r\n  ADD PRIMARY KEY (`id`);\r\n\r\n--\r\n-- AUTO_INCREMENT for dumped tables\r\n--\r\n\r\n--\r\n-- AUTO_INCREMENT for table `user`\r\n--\r\nALTER TABLE `user`\r\n  MODIFY `id` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;\r\n\/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT *\/;\r\n\/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS *\/;\r\n\/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION *\/;\r\n<\/pre>\n<p>Saya sudah coba memasukan satu record, teman-teman jangan lupa buat file koneksinya beserta file prosesnya.<\/p>\n<pre class=\"lang:default decode:true \">&lt;?php\r\n\t$server = \"localhost\";\r\n\t$user = \"root\";\r\n\t$pass = \"\";\r\n\t$db = \"db_userpass\";\r\n\r\n\t$koneksi = mysql_connect($server, $user, $pass) or die (mysql_error());\r\n\t$dbase = mysql_select_db($db, $koneksi) or die (mysql_error());\r\n<\/pre>\n<p>untuk file prosesnya, sebagai berikut:<\/p>\n<pre class=\"lang:default decode:true\">&lt;?php\r\n\t\/\/sertakan file koneksi.php dan fungsi-acak.php\r\n\tinclude \"koneksi.php\";\r\n\tinclude \"fungsi-acak.php\";\r\n\r\n\t$sql_query = mysql_query(\"INSERT INTO user(username, password) VALUES('$us','$ps')\") or die (mysql_error());<\/pre>\n<p>Silahkan teman-teman lakukan ekplorasi sendiri, disesuaikan dengan kebutuhan aplikasi yang sedang dibuat. Oke samapi bertemu di artikel berikutnya. Caio,&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Halo teman-teman pasti kalian pernah, misalnya daftar di forum atau di situs tertentu lalu mereka melakukan konfirmasi balasan dengan mengirimkan password untuk login. Password tersebut dalam kondisi acak atau random. Untuk tutorial kali ini kita akan mencoba membuat password acak dengan menggunakan PHP.<\/p>\n","protected":false},"author":1,"featured_media":560,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[190,110,11],"tags":[299,298,297,88,296],"class_list":["post-557","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mysql","category-php","category-tutorial","tag-hak-akses","tag-login","tag-password-acak","tag-php","tag-random-password"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Membuat Random Password di PHP - YELLOWWEB.ID<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Membuat Random Password di PHP - YELLOWWEB.ID\" \/>\n<meta property=\"og:description\" content=\"Halo teman-teman pasti kalian pernah, misalnya daftar di forum atau di situs tertentu lalu mereka melakukan konfirmasi balasan dengan mengirimkan password untuk login. Password tersebut dalam kondisi acak atau random. Untuk tutorial kali ini kita akan mencoba membuat password acak dengan menggunakan PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/\" \/>\n<meta property=\"og:site_name\" content=\"YELLOWWEB.ID\" \/>\n<meta property=\"article:published_time\" content=\"2017-01-27T07:26:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/01\/pass.png?fit=590%2C429&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"590\" \/>\n\t<meta property=\"og:image:height\" content=\"429\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"yellowweb\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yellowweb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/\"},\"author\":{\"name\":\"yellowweb\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\"},\"headline\":\"Membuat Random Password di PHP\",\"datePublished\":\"2017-01-27T07:26:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/\"},\"wordCount\":125,\"image\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/pass.png\",\"keywords\":[\"hak akses\",\"login\",\"password acak\",\"php\",\"random password\"],\"articleSection\":[\"MySQL\",\"PHP\",\"Tutorial\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/\",\"name\":\"Membuat Random Password di PHP - YELLOWWEB.ID\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/pass.png\",\"datePublished\":\"2017-01-27T07:26:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/pass.png\",\"contentUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/01\\\/pass.png\",\"width\":590,\"height\":429,\"caption\":\"Random Password\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/membuat-random-password-di-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Membuat Random Password di PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/\",\"name\":\"YELLOWWEB.ID\",\"description\":\"Kursus Web Design | Kursus Web Programming | Mobile Web Apps | Digital Marketing\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\",\"name\":\"yellowweb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"caption\":\"yellowweb\"},\"sameAs\":[\"https:\\\/\\\/www.yellowweb.id\"],\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/author\\\/yellowweb\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Membuat Random Password di PHP - YELLOWWEB.ID","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/","og_locale":"en_GB","og_type":"article","og_title":"Membuat Random Password di PHP - YELLOWWEB.ID","og_description":"Halo teman-teman pasti kalian pernah, misalnya daftar di forum atau di situs tertentu lalu mereka melakukan konfirmasi balasan dengan mengirimkan password untuk login. Password tersebut dalam kondisi acak atau random. Untuk tutorial kali ini kita akan mencoba membuat password acak dengan menggunakan PHP.","og_url":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/","og_site_name":"YELLOWWEB.ID","article_published_time":"2017-01-27T07:26:47+00:00","og_image":[{"width":590,"height":429,"url":"https:\/\/i0.wp.com\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/01\/pass.png?fit=590%2C429&ssl=1","type":"image\/png"}],"author":"yellowweb","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yellowweb","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/#article","isPartOf":{"@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/"},"author":{"name":"yellowweb","@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829"},"headline":"Membuat Random Password di PHP","datePublished":"2017-01-27T07:26:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/"},"wordCount":125,"image":{"@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/01\/pass.png","keywords":["hak akses","login","password acak","php","random password"],"articleSection":["MySQL","PHP","Tutorial"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/","url":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/","name":"Membuat Random Password di PHP - YELLOWWEB.ID","isPartOf":{"@id":"https:\/\/www.yellowweb.id\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/#primaryimage"},"image":{"@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/01\/pass.png","datePublished":"2017-01-27T07:26:47+00:00","author":{"@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829"},"breadcrumb":{"@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/#primaryimage","url":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/01\/pass.png","contentUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2017\/01\/pass.png","width":590,"height":429,"caption":"Random Password"},{"@type":"BreadcrumbList","@id":"https:\/\/www.yellowweb.id\/blog\/membuat-random-password-di-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.yellowweb.id\/blog\/"},{"@type":"ListItem","position":2,"name":"Membuat Random Password di PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.yellowweb.id\/blog\/#website","url":"https:\/\/www.yellowweb.id\/blog\/","name":"YELLOWWEB.ID","description":"Kursus Web Design | Kursus Web Programming | Mobile Web Apps | Digital Marketing","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.yellowweb.id\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829","name":"yellowweb","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","caption":"yellowweb"},"sameAs":["https:\/\/www.yellowweb.id"],"url":"https:\/\/www.yellowweb.id\/blog\/author\/yellowweb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/comments?post=557"}],"version-history":[{"count":3,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/557\/revisions"}],"predecessor-version":[{"id":561,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/557\/revisions\/561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/media\/560"}],"wp:attachment":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/media?parent=557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/categories?post=557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/tags?post=557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}