|
|
|
ช่วยดู upload ภาพเข้าไปในฐานข้อมูลให้หน่อยครับ ผิดพลาดตรงไหน |
|
|
|
|
|
|
|
ทำตามวิธีในเว็บ แต่มันยังอับโหลดไม่เข้าฐานข้อมูลเลยครับ
Code (PHP)
<form name="form1" method="post" action="insert_sql.php">
Register Form <br>
<table width="400" border="1" style="width: 400px">
<tbody>
<tr>
<td> picture</td>
<td><input name="picupload" type="file" >
</td>
</tr>
<tr>
<td width="125"> Username</td>
<td width="180">
<input name="user" type="text" size="20">
</td>
</tr>
<tr>
<td> Password</td>
<td><input name="pass" type="password" >
</td>
</tr>
<tr>
<td> Confirm Password</td>
<td><input name="cpass" type="password">
</td>
</tr>
<tr>
<td> fname</td>
<td><input name="fname" type="text" size="35"></td>
</tr>
<tr>
<td> lname</td>
<td><input name="lname" type="text" size="35"></td>
</tr>
<tr>
<tr>
<td> email</td>
<td><input name="email" type="text" size="35"></td>
</tr>
<tr>
<td> tel</td>
<td><input name="tel" type="text" size="35"></td>
</tr>
<tr>
<td> address</td>
<td><textarea name="address" cols="50" rows="5"></textarea></td>
</tr>
<td> Status</td>
<td>
<select name="status">
<option value="admin">admin</option>
<option value="user">user</option>
<option value="member">member</option>
</select>
</td>
</tr>
</tbody>
</table>
<br>
<input type="submit" name="Submit" value="Save">
</form>
นำเข้าฐานข้อมูล
Code (PHP)
<?
mysql_connect("localhost","root","1234");
mysql_select_db("my");
if(trim($_POST["user"]) == "")
{
echo "Please input Username!";
exit();
}
if(trim($_POST["pass"]) == "")
{
echo "Please input Password!";
exit();
}
if($_POST["cpass"] != $_POST["cpass"])
{
echo "Password not Match!";
exit();
}
if(trim($_POST["fname"]) == "")
{
echo "Please input Name!";
exit();
}
$strSQL = "SELECT * FROM account WHERE acc_user = '".trim($_POST['user'])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "Username already exists!";
}
else
{
if(copy($_FILES["picupload"]["tmp_name"],"picture/".$_FILES["picupload"]["name"]))
{
$strSQL = "INSERT INTO account (acc_user,acc_pass,acc_fname,acc_lname,acc_email,acc_tel,acc_address,acc_st,acc_pic) VALUES ('".$_POST["user"]."',
'".$_POST["pass"]."',
'".$_POST["fname"]."',
'".$_POST["lname"]."',
'".$_POST["email"]."',
'".$_POST["tel"]."',
'".$_POST["address"]."',
'".$_POST["status"]."',
'".$_FILES["picupload"]["name"]."'
)";
$objQuery = mysql_query($strSQL);
}
echo "Register Completed!<br>";
echo "<br> Go to <a href='login.php'>Login page</a>";
}
?>
Tag : PHP, CakePHP
|
|
|
|
|
|
Date :
2011-05-27 21:36:00 |
By :
พัช |
View :
682 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แย่จังเรา!!! ขอบคุณมากครับ
|
|
|
|
|
Date :
2011-05-27 22:19:51 |
By :
พัช |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|