|
|
|
ช่วยแก้โค้ดอัพโหลดรูปหน่อยคะติดerrorช่วยดูหน่อยนะคะ |
|
|
|
|
|
|
|
material_form_insert.php
Code (PHP)
<!-- html -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>ข้อมูลวัสดุ</title>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<link rel="stylesheet" type="text/css" href="../scsticker/css/formstyle.css"/>
<link rel="stylesheet" href="../scsticker/css/buttons.css">
<script type="text/javascript" src="../buttons/js/buttons.js"></script>
<script src="../scsticker/js/jquery-1.10.1.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="../scsticker/css/customize-template.css" type="text/css" media="screen, projection" rel="stylesheet" />
<link rel="stylesheet" href="assets/css/styles.css" />
<link rel="stylesheet" href="../scsticker/css/fonts_googleapis.css" />
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
</head>
<body>
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button class="btn btn-navbar" data-toggle="collapse" data-target="#app-nav-top-bar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="index.html" class="brand"><i class="icon-lemon"> SCSTICKER</i></a>
<div id="app-nav-top-bar" class="nav-collapse">
<ul class="nav pull-right">
<li>
<a href="login.php"><i class="icon-user">logout</i></a>
</li>
</ul>
</div>
</div>
</div>
</div><br/><br/><br/><br/><br/>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<section class="page container">
<div class="row">
<div class="span16">
<div class="box">
<a href="index.html" class="button button-rounded button-flat">หน้าหลัก</a>
<a href="datamain.html" class="button button-rounded button-flat">ข้อมูลหลัก</a>
<a href="material.php" class="button button-rounded button-flat">ข้อมูลวัสดุ</a>
<div class="box-header">
<i class="icon-bookmark"></i>
<h5>เพิ่มข้อมูลวัสดุ</h5></div><br/>
<div class="box-content">
<center>
<div class="btn-group-box">
<div class="col-lg-6">
<div class="table-responsive">
<!-- ตาราง insert -->
<?php
include("connect.php");
$db = "scsticker";
$result = mysql_select_db($db);
if(!$result){
die('Could not find database called material: '. mysql_error());
}
$test_id = "select MAX(SUBSTRING(id_material,5)) as num from material ";
$tmp = mysql_query($test_id) or die (mysql_error()." Error Query [".$test_id."]");
$rows = mysql_fetch_array($tmp);
if($rows){
$num = $rows['num'];
if($num==Null){
$num = 0;
}
$test_id = $num+1;
if($test_id < 10){
$id_material = "MAT00".$test_id;
}
elseif ($test_id < 100) {
$id_material= "MAT0".$test_id;
}
elseif ($test_id < 1000) {
$id_material = "MAT".$test_id;
}
}
?>
<!--
<?
// if($_FILES["picture_material"]["name"] != "")
// {
// //*** Read file BINARY ***'
// $fp = fopen($_FILES["picture_material"]["tmp_name"],"r");
// $ReadBinary = fread($fp,filesize($_FILES["picture_material"]["tmp_name"]));
// fclose($fp);
// $FileData = addslashes($ReadBinary);
// //*** Insert Record ***//
// $objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
// $objDB = mysql_select_db("mydatabase");
// $strSQL = "INSERT INTO files ";
// $strSQL .="(name_material,id_color,id_brand,id_type_material,amount_material,id_unit,costprice,point_of_order_material)
// VALUES ('".$_POST["name_material"]."','".$_POST["id_color"]."','".$_POST["id_brand"]."','".$_POST["id_type_material"]."','".$_POST["amount_material"]."','".$_POST["id_unit"]."','".$_POST["costprice"]."','".$_POST["point_of_order_material"]."','".$FileData."')";
// $objQuery = mysql_query($strSQL);
// echo "Copy/Upload Complete<br>";
// mysql_close($objConnect);
// }
?>-->
<!-- table -->
<div>
<!-- ส่งค่าไปเช็คที่ material_in.php -->
<form method="post" action="material_in.php">
<div data-role="fieldcontain">
<label for="id_material" class="col-lg-3 control-label"><b> รหัสวัสดุ </b>
<input type="text" name="id_material" id="id_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" readonly="readonly" value="<?=$id_material?>" /></label>
</div>
<div data-role="fieldcontain">
<label for="name_material" class="col-lg-3 control-label"><b> ชื่อวัสดุ </b>
<input type="text" name="name_material" id="name_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="id_color" class="col-lg-3 control-label"><b> สี </b>
<input type="text" name="id_color" id="id_color" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="id_brand" class="col-lg-3 control-label"><b> ยี่ห้อ </b>
<input type="text" name="id_brand" id="id_brand" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="picture_material" class="col-lg-3 control-label"><b> รูปภาพวัสดุ </b>
<input type="file" name="picture_material" id="picture_material">
<input name="hidAction" id="hidAction" type="hidden" value="Add">
</div>
<div data-role="fieldcontain">
<label for="id_type_material" class="col-lg-3 control-label"><b>ประเภทวัสดุ </b>
<input type="text" name="id_type_material" id="id_type_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="point_of_order_material" class="col-lg-3 control-label"><b>จุดสั่งซื้อวัสดุ </b>
<input type="text" name="point_of_order_material" id="point_of_order_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="amount_material" class="col-lg-3 control-label"><b> จำนวน </b>
<input type="text" name="amount_material" id="amount_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="id_unit" class="col-lg-3 control-label"><b> หน่วยนับ </b>
<input type="text" name="id_unit" id="id_unit" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="costprice" class="col-lg-3 control-label"><b> ราคาต้นทุน </b>
<input type="text" name="costprice" id="costprice" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div class="row">
<div class="col-xs-10 col-sm-4 col-md-6"></div>
<div class="col-xs-8 col-md-6">
<input class="button button-rounded button-flat-action" type="submit" value="เพิ่ม" style="width:100px">
<input class="button button-rounded button-flat" type="button" value="ยกเลิก" style="width:100px" ONCLICK="window.location.href='material.php'">
</div>
</div>
</div>
</form>
</body>
</html><!-- html -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>ข้อมูลวัสดุ</title>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<link rel="stylesheet" type="text/css" href="../scsticker/css/formstyle.css"/>
<link rel="stylesheet" href="../scsticker/css/buttons.css">
<script type="text/javascript" src="../buttons/js/buttons.js"></script>
<script src="../scsticker/js/jquery-1.10.1.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="../scsticker/css/customize-template.css" type="text/css" media="screen, projection" rel="stylesheet" />
<link rel="stylesheet" href="assets/css/styles.css" />
<link rel="stylesheet" href="../scsticker/css/fonts_googleapis.css" />
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
</head>
<body>
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button class="btn btn-navbar" data-toggle="collapse" data-target="#app-nav-top-bar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="index.html" class="brand"><i class="icon-lemon"> SCSTICKER</i></a>
<div id="app-nav-top-bar" class="nav-collapse">
<ul class="nav pull-right">
<li>
<a href="login.php"><i class="icon-user">logout</i></a>
</li>
</ul>
</div>
</div>
</div>
</div><br/><br/><br/><br/><br/>
<!-- //////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<section class="page container">
<div class="row">
<div class="span16">
<div class="box">
<a href="index.html" class="button button-rounded button-flat">หน้าหลัก</a>
<a href="datamain.html" class="button button-rounded button-flat">ข้อมูลหลัก</a>
<a href="material.php" class="button button-rounded button-flat">ข้อมูลวัสดุ</a>
<div class="box-header">
<i class="icon-bookmark"></i>
<h5>เพิ่มข้อมูลวัสดุ</h5></div><br/>
<div class="box-content">
<center>
<div class="btn-group-box">
<div class="col-lg-6">
<div class="table-responsive">
<!-- ตาราง insert -->
<?php
include("connect.php");
$db = "scsticker";
$result = mysql_select_db($db);
if(!$result){
die('Could not find database called material: '. mysql_error());
}
$test_id = "select MAX(SUBSTRING(id_material,5)) as num from material ";
$tmp = mysql_query($test_id) or die (mysql_error()." Error Query [".$test_id."]");
$rows = mysql_fetch_array($tmp);
if($rows){
$num = $rows['num'];
if($num==Null){
$num = 0;
}
$test_id = $num+1;
if($test_id < 10){
$id_material = "MAT00".$test_id;
}
elseif ($test_id < 100) {
$id_material= "MAT0".$test_id;
}
elseif ($test_id < 1000) {
$id_material = "MAT".$test_id;
}
}
?>
<!--
<?
// if($_FILES["picture_material"]["name"] != "")
// {
// //*** Read file BINARY ***'
// $fp = fopen($_FILES["picture_material"]["tmp_name"],"r");
// $ReadBinary = fread($fp,filesize($_FILES["picture_material"]["tmp_name"]));
// fclose($fp);
// $FileData = addslashes($ReadBinary);
// //*** Insert Record ***//
// $objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database");
// $objDB = mysql_select_db("mydatabase");
// $strSQL = "INSERT INTO files ";
// $strSQL .="(name_material,id_color,id_brand,id_type_material,amount_material,id_unit,costprice,point_of_order_material)
// VALUES ('".$_POST["name_material"]."','".$_POST["id_color"]."','".$_POST["id_brand"]."','".$_POST["id_type_material"]."','".$_POST["amount_material"]."','".$_POST["id_unit"]."','".$_POST["costprice"]."','".$_POST["point_of_order_material"]."','".$FileData."')";
// $objQuery = mysql_query($strSQL);
// echo "Copy/Upload Complete<br>";
// mysql_close($objConnect);
// }
?>-->
<!-- table -->
<div>
<!-- ส่งค่าไปเช็คที่ material_in.php -->
<form method="post" action="material_in.php">
<div data-role="fieldcontain">
<label for="id_material" class="col-lg-3 control-label"><b> รหัสวัสดุ </b>
<input type="text" name="id_material" id="id_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" readonly="readonly" value="<?=$id_material?>" /></label>
</div>
<div data-role="fieldcontain">
<label for="name_material" class="col-lg-3 control-label"><b> ชื่อวัสดุ </b>
<input type="text" name="name_material" id="name_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="id_color" class="col-lg-3 control-label"><b> สี </b>
<input type="text" name="id_color" id="id_color" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="id_brand" class="col-lg-3 control-label"><b> ยี่ห้อ </b>
<input type="text" name="id_brand" id="id_brand" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="picture_material" class="col-lg-3 control-label"><b> รูปภาพวัสดุ </b>
<input type="file" name="picture_material" id="picture_material">
<input name="hidAction" id="hidAction" type="hidden" value="Add">
</div>
<div data-role="fieldcontain">
<label for="id_type_material" class="col-lg-3 control-label"><b>ประเภทวัสดุ </b>
<input type="text" name="id_type_material" id="id_type_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="point_of_order_material" class="col-lg-3 control-label"><b>จุดสั่งซื้อวัสดุ </b>
<input type="text" name="point_of_order_material" id="point_of_order_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="amount_material" class="col-lg-3 control-label"><b> จำนวน </b>
<input type="text" name="amount_material" id="amount_material" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="id_unit" class="col-lg-3 control-label"><b> หน่วยนับ </b>
<input type="text" name="id_unit" id="id_unit" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div data-role="fieldcontain">
<label for="costprice" class="col-lg-3 control-label"><b> ราคาต้นทุน </b>
<input type="text" name="costprice" id="costprice" placeholder="กรอกข้อมูล" aria-describedby="sizing-addon2" style="height:30" /></label>
</div>
<div class="row">
<div class="col-xs-10 col-sm-4 col-md-6"></div>
<div class="col-xs-8 col-md-6">
<input class="button button-rounded button-flat-action" type="submit" value="เพิ่ม" style="width:100px">
<input class="button button-rounded button-flat" type="button" value="ยกเลิก" style="width:100px" ONCLICK="window.location.href='material.php'">
</div>
</div>
</div>
</form>
</body>
</html>
material_in.php // error line 65 if($hidAction == "Add") {
Code (PHP)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>ข้อมูลวัสดุ</title>
<!-- ///////////////////////////////////////////////////// css,js ///////////////////////////////////////////////////// -->
<link rel="stylesheet" type="text/css" href="../scsticker/css/formstyle.css"/>
<link rel="stylesheet" href="../scsticker/css/buttons.css">
<script type="text/javascript" src="../buttons/js/buttons.js"></script>
<script src="../scsticker/js/jquery-1.10.1.min.js"></script>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<link href="../scsticker/css/customize-template.css" type="text/css" media="screen, projection" rel="stylesheet"/>
<link rel="stylesheet" href="assets/css/styles.css"/>
<link rel="stylesheet" href="../scsticker/css/fonts_googleapis.css"/>
<!-- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
</head>
<body>
<h4>
<!-- //////////////////////////////////////////////// connect database //////////////////////////////////////////////// -->
<?php
include("connect.php");
$db = "scsticker";
$result = mysql_select_db($db);
if(!$result){
die('Could not find database called material: '. mysql_error());
}
$id_material = $_POST["id_material"];
$name_material = $_POST["name_material"];
$id_color = $_POST["id_color"];
$id_brand = $_POST["id_brand"];
$picture_material = $_POST["picture_material"];
$id_type_material= $_POST["id_type_material"];
$amount_material= $_POST["amount_material"];
$id_unit= $_POST["id_unit"];
$costprice= $_POST["costprice"];
$point_of_order_material= $_POST["point_of_order_material"];
$test_id = "select id_material from material where id_material ='".$id_material."'";
$tmp = mysql_query($test_id);
$rows = mysql_num_rows($tmp);
if($rows != 0){
echo "<br/>";
echo "<br/>";
echo "<section class='page container'>";
echo "<div class='row'>";
echo "<div class='span16'>";
echo "<div class='box'>";
echo "<a href='index.html' class='button button-rounded button-flat'>หน้าหลัก</a>";
echo "<a href='datamain.html' class='button button-rounded button-flat'>ข้อมูลหลัก</a>";
echo "<a href='material.php' class='button button-rounded button-flat'>ข้อมูลวัสดุ</a>";
echo "<div class='box-header'>";
echo "<i class='icon-bookmark' align='left'></i>";
echo "<h5>เพิ่มข้อมูลวัสดุ</h5>";
echo "</div><br/>";
echo "<div class='box-content'>";
echo "<center> <div class='btn-group-box'> ";
echo "<div class='col-lg-6'>";
echo "<h2></h2>";
echo "<div class='table-responsive'>";
echo "<center>";
echo "ไม่สามารถเพิ่มข้อมูลได้มีรหัสวัสดุนี้อยู่ในระบบแล้ว<br><br>";
echo "<input class='button button-rounded button-flat-highlight' type='submit' value='ย้อนกลับ' ONCLICK=window.location.href='material_form_insert.php'>";
}
if($hidAction == "Add") { //เช็คค่า hidAction ที่ส่งมาถ้าเท่ากับ Add ให้โปรแกรทำงานต่อ
$date = date("MAT"); // สร้าเลข 10 หลักมาจากเวลาเพื่อนำไปเป็นชื่อรูปภาพ
if($file != "") {
$type = getimagesize($file); // หาประเภทของรูปภาพ
if($type[2] == 1) {
$picture_material = $date.".gif"; // เมื่อรูปเป็น .gif
} else if($type[2] == 2) {
$picture_material = $date.".jpg"; // เมื่อรูปเป็น .jpg
}
else if($type[3] == 3) {
$picture_material = $date.".png"; // เมื่อรูปเป็น .png
}
else if($type[4] == 4) {
$picture_material = $date.".tif"; // เมื่อรูปเป็น .jpg
}
else {
$picture_material = $date.".bmp"; // เมื่อรูปเป็น .bmp
}
copy($file, "images/$picture_material"); // copy รูปไว้ในโฟลเดอร์ image
chmod("images/$picture_material", 0777); // ทำการ changmode
}
exit();
}else{
$sql = "insert into `scsticker`.`material` (`id_material`, `name_material`, `id_color`, `id_brand`, `picture_material`, `id_type_material`, `amount_material`, `id_unit`, `costprice`, `point_of_order_material`)
values ('".$id_material."', '".$name_material."', '".$id_color."', '".$id_brand."', '".$picture_material."', '".$id_type_material."', '".$amount_material."', '".$id_unit."', '".$costprice."', '".$point_of_order_material."')";
$result = mysql_query($sql);
if(!$result){
die('Insert not success !!!: '. mysql_error());
}
}
?>
</h4></center>
<script>
location="material.php";
</script>
<script>
location="material_form_list.php";
</script>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2015-11-19 21:58:37 |
By :
POMP |
View :
796 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error ตรงนี้แค่นี้หรอคับ
material_in.php // error line 65 if($hidAction == "Add") {
$hidAction <= รับค่ามาจากตรงไหน กดปุ่มมาก็เป็น POST ไม่ก็ GETตาม method ของ form
แต่ยังไม่เห็น ตัวรับค่าเลย
|
|
|
|
|
Date :
2015-11-19 22:35:01 |
By :
progamer2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อันนั้นส่ง คับ แล้วรับละ รับมาจากตรงไหน ?
|
|
|
|
|
Date :
2015-11-20 01:00:58 |
By :
progamer2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|