|
|
|
สอบถามเรื่อง mkdir ใน php หน่อยค่ะ Warning: mkdir() [function.mkdir]: File exists in |
|
|
|
|
|
|
|
สร้างโฟลเดอร์อันแรกโดยอ้างชื่อ user จากฟอร์มในหน้าสมัครสมาชิกได้ค่ะ แต่พอจะสร้างอันที่ สอง มันก็ฟ้อง
Code
Warning: mkdir() [function.mkdir]: File exists in C:\AppServ\www\mmm\insert_data.php on line 95
พอเข้าไปดูใน path ที่สั่งสร้างไว้...สมมติว่าสร้างชื่อ [email protected] แต่มันจะมีโฟลเดอร์ @it.bru.ac.th สร้างขึ้นมาด้วย ..งงค่ะ
นี่เป็นโค้ดทั้งหมดในหน้า สมัครสมาชิกค่ะ
-------------------------------------------------------------------------------------------------
Code (PHP)
<?php require_once('Connections/test.php'); ?>
<?php
//ใส่ @it ออโต้
$usr=$username."@it.bru.ac.th";
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$password=$_POST['password'];
$password2=$_POST['password2'];
if($password != $password2){
//echo "รหัสผ่านไม่ถูกต้อง"; exit();
echo "<script>alert(\"รหัสผ่านไม่ถูกต้อง.\");history.go(-1);</script>"; exit();
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO mailbox (username, password, mail_backup, name, id_stu, sex, program, `year`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($usr, "text"),
// GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($password, "text"),
GetSQLValueString($_POST['mail_backup'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['id_stu'], "text"),
GetSQLValueString($_POST['sex'], "text"),
GetSQLValueString($_POST['program'], "text"),
GetSQLValueString($_POST['year'], "date"));
mysql_select_db($database_test, $test);
$Result1 = mysql_query($insertSQL, $test) or die(mysql_error());
$insertGoTo = "welcome.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php
$usr=$username."@it.bru.ac.th";
chmod("C:\AppServ\www\mmm\user", 777);
$path="C:\AppServ\www\mmm\user";
//$flgCreate = mkdir($path."/".$usr);
$flg = mkdir($path."/".$usr);
if($flg)
{
echo "Folder Created.";
}
else
{
echo "Folder Not Create.";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>
<body onload="MM_preloadImages('home (1).png','home (3).png','home (4).png')">
<table width="800" border="0" align="center">
<tr>
<td><img src="sm_logo.png" width="308" height="111" /></td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><strong>กรอกข้อมูล เพื่อสร้างบัญชีอีเมล<br />
<br />
</strong></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table width="461" align="center">
<tr valign="baseline">
<td width="112" align="left" nowrap="nowrap">Username :</td>
<td width="200"><input type="text" name="username" value="" size="15" />
@it.bru.ac.th</td>
<td width="133"> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="left">Password :</td>
<td><input type="password" name="password" id="password" value="" size="32" /></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="left">ยืนยัน Password :</td>
<td><input type="password" name="password2" id="password2" value="" size="32" /></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="left">E-mail สำรอง :</td>
<td><input type="text" name="mail_backup" value="" size="32" /></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="left">ชื่อ - สกุล :</td>
<td><input type="text" name="name" value="" size="32" /></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="left">รหัสประจำตัว :</td>
<td><input type="text" name="id_stu" value="" size="32" /></td>
<td> </td>
</tr>
<tr valign="baseline">
<td align="left" valign="middle" nowrap="nowrap">เพศ :</td>
<td valign="baseline"><table>
<tr>
<td><input type="radio" name="sex" value="male" />
ชาย</td>
<td><input type="radio" name="sex" value="female" />
หญิง</td>
</tr>
</table></td>
<td valign="baseline"> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="left">สาขาวิชา :</td>
<td><input type="text" name="program" value="" size="32" /></td>
<td> </td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="left">ปีที่เข้าศึกษา :</td>
<td><input type="text" name="year" value="" size="32" /></td>
<td> </td>
</tr>
<tr valign="baseline">
<td height="43" align="left" nowrap="nowrap"> </td>
<td valign="middle"><input type="submit" value="สมัครสมาชิก" /></td>
<td valign="middle"> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td height="21" align="center" valign="middle"><p><br />
</p>
</td>
</tr>
</table>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-03-13 20:25:55 |
By :
เกือบสวย |
View :
2140 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|