کد PHP:
<?php
session_start();
require("dbConnect.php");
?>
<?php
if (isset($_POST['action']))
{
$action = addslashes($_POST['action']);
$subject = addslashes($_POST['subject']);
$person = addslashes($_POST['person']);
$text = addslashes($_POST['text']);
if ($action == 'new')
{
$sql = "INSERT INTO `shekayat`(`subject`,`text`,`person`)"
."VALUES('$subject','$text','$person')";
mysql_query($sql);
$id = mysql_insert_id();
$uploaddir = 'pic/';
$path = $_FILES['pic']['name'];
$file_ext = pathinfo($path, PATHINFO_EXTENSION);
if ($file_ext=='gif') {
$uploadfile = $uploaddir . $id . '.gif';
}
elseif ($file_ext=='zip')
{
$uploadfile = $uploaddir . $id . '.zip';
}
elseif ($file_ext=='rar')
{
$uploadfile = $uploaddir . $id . '.rar';
}
else
{
die ("<br><br>پسوند مجاز نیست<br><br>$file_ext");
}
!move_uploaded_file($_FILES['pic']['tmp_name'], $uploadfile);
header('Location: shekayat.php');
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>سايت تاکسیرانی</title>
<style type="text/css">
.auto-style1 {
font-family: Tahoma;
}
</style>
</head>
<body style="background-image: url('pic/Abstract%20Green%20Wallpaper.jpg')">
<div id="main">
<div id="banner">
<img alt="" height="132" src="pic/banner.jpg" width="751"></div>
<?php
require("menu.php");
?>
<div id="rbody">
<form action="#" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="new" />
<table>
<tr>
<td>موضوع شکايت/تشویق</td>
<td>
<input name="subject" type="text" value="" class="auto-style1" /> </td>
</tr>
<tr>
<td>نام شخص</td>
<td>
<input name="person" type="text" value="" class="auto-style1" /> </td>
</tr>
<tr>
<td>متن</td>
<td><textarea name="text" class="auto-style1" ></textarea> </td>
</tr>
<tr>
<td>تصوير</td>
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<td><input name="pic" type="file" class="auto-style1"/> </td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="ثبت" class="auto-style1" />
<input type="reset" value="پاک" class="auto-style1" />
</td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>