· 9 years ago · Jul 06, 2017, 04:06 AM
1<!DOCTYPE html>
2<html>
3<head>
4 <title>form1</title>
5</head>
6<body>
7<form action="form1.php" method="POST">
8 <table class="tabel-beli">
9 <tr>
10 <td>Username</td>
11 <td>:</td>
12 <td><input type="text" name="username" placeholder="masukan username" /></td>
13 </tr>
14 <tr>
15 <td>Password</td>
16 <td>:</td>
17 <td><input type="password" name="password" placeholder="password"></td>
18 </tr>
19 <tr>
20 <td>Metode Pembayaran</td>
21 <td>:</td>
22 <td><select name="bayar">
23 <option>Telkomsel</option>
24 <option>BNI</option>
25 </select>
26 </td>
27 </tr>
28 <tr>
29 <td><input type="submit" name="submit" value="Beli"></td>
30 </tr>
31 </table>
32</form>
33</body>
34</html>
35<?php
36if (isset($_POST['submit'])) {
37/*
38CREATE TABLE IF NOT EXISTS `user` (
39 `user_id` int(11) NOT NULL AUTO_INCREMENT,
40 `username` varchar(32) NOT NULL,
41 `password` varchar(32) NOT NULL,
42 `server` varchar(32) NOT NULL,
43 `status` enum('aktif','mati') NOT NULL,
44 `kode_bayar` varchar(64) NOT NULL,
45 PRIMARY KEY (`user_id`)
46) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
47*/
48 // include_once("/ssh/function/helper.php");
49 // include_once("/ssh/function/connection.php");
50
51 $connection=mysqli_connect("localhost","root","a","tes");
52 $username = $_POST['username'];
53 $password = $_POST['password'];
54 $server = "INDONESIA";
55 $status = "mati";
56
57 $dataForm = http_build_query($_POST);
58
59 $query = mysqli_query($connection, "SELECT * FROM user WHERE username='$username'");
60
61 if (empty($username) || empty($password)) {
62 // header("location: /ssh/index.php?page=main¬if=require&$data");
63 // }elseif (mysqli_num_rows($query) == 1) {
64 // header("location: /ssh/index.php?page=main¬if=username&data");
65 }else{
66 mysqli_query($connection, "INSERT INTO user (username, password, server, status)
67 VALUES ('$username', '$password', '$server', '$status')");
68 // header("location: /ssh/index.php?page=konfirm");
69 echo mysqli_error($connection);
70
71 }
72}
73?>