|
|
|
ช่วยด้วยครับ ไม่ส่งข้อมูลขึ้นดาต้าเบส ผมทำตรงไหนผิดครับ ช่วยดูให้หน่อย |
|
|
|
|
|
|
|
form.php (PHP)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Form</title>
</head>
<body>
<form name="frm" method="post" action="save.php">
<label>Tille:</label> <input type="text" name="rank_title" ><br>
<label>Min:</label><input type="text" name="rank_min"><br>
<label>Special:</label>
<input type="radio" name="rank_special" id="rank_special1" value="1" checked="checked">
<label for="rank_special1">ใช่</label>
<input type="radio" name="rank_special" id="rank_special2" value="0">
<label for="rank_special2">ไม่ใช่</label><br>
<label>Image:</label><input type="file" name="rank_image"><br>
<input type="submit" name="save" value="Save">
</form>
</body>
</html>
save.php (PHP)
<?php
require_once 'connection.php';
print_r($_POST);
if ( isset( $_POST['save'])) {
$rank_title =$_POST['$rank_title'];
$rank_min =$_POST['$rank_min'];
$rank_special =$_POST['$rank_special'];
$sql = "INSERT INTO tb_image (rank_title,rank_min,rank_special)
VALUES ('$rank_title','$rank_min','$rank_special')";
mysqli_query($connection,$sql) or die ('Insert Error') ;
echo 'Insert Success';
}
?>
connection.php (PHP)
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_connection = "localhost";
$database_connection = "img";
$username_connection = "root";
$password_connection = "root";
$connection = mysqli_connect($hostname_connection, $username_connection, $password_connection, $database_connection) or trigger_error(mysqli_connect_errno(),E_USER_ERROR);
mysqli_set_charset($connection, "utf8");
?>
Code (SQL)
CREATE TABLE IF NOT EXISTS `tb_image` (
`rank_id` mediumint(8) NOT NULL,
`rank_title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`rank_min` mediumint(8) NOT NULL,
`rank_special` tinyint(1) NOT NULL,
`rank_image` varchar(255) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `tb_image`
--
ALTER TABLE `tb_image`
ADD PRIMARY KEY (`rank_id`);
เช็คค่าที่ส่งไปหน้า save.php มีค่าส่งไป
แค่ค่าไม่ขึ้น ดาต้าเบส ผมทำตรงไหนผิดครับ
Tag : PHP
|
|
|
|
|
|
Date :
2018-05-02 11:09:37 |
By :
skyblack2009 |
View :
566 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันขาด require column ไปตัวนึงนะครับ
|
|
|
|
|
Date :
2018-05-02 13:03:27 |
By :
mongkon.k |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|