close

2014/09/20 (性別、年紀、喜好)欄位(新增頁)  
<?php require_once('../Connections/allianz.php'); ?>
<?php

// 檔案處理區 ( "../../../../upload/news")
function isUploadFile($tmpFileName, $newFileName){
$isUpload = false;
if ( copy($tmpFileName, $newFileName) ){ // 更改檔名前置動作
$isUpload = true;
}
unlink($tmpFileName); // 清除暫存檔案
return $isUpload;
}
// 取得檔名
function getDateTimeFileName( $Picname ){
$temp = explode(".",$Picname);
return date("ymdHis") . "." . $temp[1];
}


$varMM_form = ""; if (isset($_POST["mm_form"]) ){ $varMM_form=$_POST["mm_form"];}
//echo " mm_form =" . $varMM_form."<br>";

 

if( $varMM_form == "form1"){

// 上傳圖片的程式
// 1.接file型態圖片檔案的資料,放到暫存檔案上
// 2.拷貝暫存檔案到images\upload目錄下
// 3.刪除暫存檔案

$oldFileName = $_FILES["pic"]["name"]; //--讀取參數
$tmpFileName = $_FILES["pic"]["tmp_name"];
$fileType = $_FILES["pic"]["type"];
$fileSize = $_FILES["pic"]["size"];

//$newFileName = getDateTimeFileName($oldFileName);
//$newFileName = $oldFileName; // "a.txt"; // 以原檔名存
$newFileName=mb_convert_encoding($_FILES["pic"]["name"],"big5","utf8"); // 以原檔名存

//echo "原始=" . $_FILES["picname"]["name"]. "<Br>";
//echo "轉碼=" . $newFileName . "<Br>";
//exit();
$path = "../images/upload"; // images/upload/

if ( chdir($path) ){ // 是否有切換目錄成功
//echo "tmp=" . $tmpFileName . "<br>";
//echo "new=" . $newFileName . "<Br>";
if ( isUploadFile($tmpFileName, $newFileName) ){ // 上傳成功
$msg .= "檔名=" . $oldFileName . "\\n";
$msg .= "大小=". ceil($fileSize / 1024) . " KB\\n";
$msg .= "\\n 成功上傳了 <br>";
} else {
$msg.= "\\n 上傳失敗,有可能您上傳的檔案太大了,";
$msg.= "不合規定,如有任何問題,請洽系統設計服務人員";
}
} else {
$msg.= "上傳檔案到指定的目錄 失敗\\n";
}
$varName = ""; if (isset($_POST["name"]) ){ $varName =$_POST["name"];}
//echo " name = " .$varName ."<br>";

$varSex = ""; if (isset($_POST["sex"]) ){ $varSex =$_POST["sex"];}

$varAge = ""; if (isset($_POST["age"]) ){ $varAge =$_POST["age"];}

$varAbout = ""; if (isset($_POST["about"]) ){ $varAbout = implode(",", $_POST["about"]); }

$varFavor = ""; if (isset($_POST["favor"]) ){ $varFavor =$_POST["favor"];}

$varOther = ""; if (isset($_POST["other"]) ){ $varOther =$_POST["other"];}

mysql_select_db($database_allianz,$allianz); // ³s½u¸ꯆ®w
$insert = " insert into abc01 ( ";
$insert.= " name, sex, age, ";
$insert.= " favor, about, other, ";
$insert= substr($insert, 0, strlen($insert)-2);
$insert.= " ) value ( ";
$insert.= " '".$varName."', ";
$insert.= " '".$varSex."', ";
$insert.= " '".$varAge."', ";
$insert.= " '".$varFavor."', ";
$insert.= " '".$varAbout."', ";
$insert.= " '".$varOther."', ";

$insert = substr($insert, 0, strlen($insert)-2);
$insert.= ");";

//echo " insert = " . $insert . "<br>";
//exit();
$Recordset1=mysql_query($insert,$allianz) or die(mysql_error());// °�d¸߻yªk
header(sprintf("Location: %s", "abc01_qry.php" ));
}
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- <script src="../js/jquery-2.1.1.js"></script> -->
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="../js/jquery-ui-1.11.1.custom/jquery-ui.js"></script>
<link rel="stylesheet" href="../js/jquery-ui-1.11.1.custom/jquery-ui.structure.css">
<link rel="stylesheet" href="../js/jquery-ui-1.11.1.custom/jquery-ui.theme.css">
<script>
<!--
$(function(){
$('#form1').submit(function() {
var s = "";
if ( $("input[name='name']").val().length==0 ){
s += " 沒輸入名字 \n ";
}


if( $("input[type=radio]:checked").length==0 ){
s += " 沒輸入性別 \n ";
}

if ( $("age option:selected").val().length==0 ){
s += " 沒輸入年紀 \n ";
}

if( $("input[type=checkbox][name='favor']:checked").length==0 ){
s += " 沒輸入興趣 \n ";
}

if ( $("input[name='about']").val().length==0 ){
s += " 沒輸入關於 \n ";
}
if ( s.length >0 ){
alert(s);
return false;
}
});
});
-->
</script>
<style>
.nofind{
background-color:pink;
}
.eachrow{
background-color:#C1FFC1;
}
</style>

</head>
<body>
<form method="post" name="form1" id="form1" action="" >
<table border="1">
<tr>
<td colspan="2">新增</td>
</tr>

<tr>
<td>名字</td><td><input type="text" name="name" value=""></td>
</tr>
<tr>
<td>性別</td>
<td>
女生<input type="radio" id="sex" name="sex" value="0">
男生<input type="radio" id="sex" name="sex" value="1">

</td>
<td>年紀</td>
<td>
<select id="age" name="age">
<?php for($i=18;$i<=80;$i++){?>
<option value="<?php echo $i;?>"><?php echo $i;?></option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>喜好</td>
<td colspan="3">
編號<input type="checkbox" id="favor" name="favor[]" value="0">
名字<input type="checkbox" id="favor" name="favor[]" value="1">
性別<input type="checkbox" id="favor" name="favor[]" value="2">
年紀<input type="checkbox" id="favor" name="favor[]" value="3">
</td>
</tr>
<tr>
<td>關於</td><td><textarea name="about" id="about" style="width:500px; hight:100; overflow:auto;"></textarea></td>
<td>其他</td><td><input type="text" id="other" name="other" value=""></td>
</tr>
<tr>
<td><input type="submit" value="新增"></td>
</tr>
</table>
<input type="hidden" name="mm_form" value="form1">
</form>
</body>

</html>

arrow
arrow
    文章標籤
    程式
    全站熱搜

    ab1628 發表在 痞客邦 留言(0) 人氣()