<form action="" method="POST"> <div class="col-md-6 wthree_contact_left_grid"> <input type="text" name="name" value="Name*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name*';}" required> <input type="text" name="subject" value="Subject*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Subject*';}" required> </div> <div class="col-md-6 wthree_contact_left_grid"> <input type="text" name="phone" value="Telephone*" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Telephone*';}" required> <input style="margin-top:20px;padding:4px;" name="image" type="file" accept="image/gif, image/jpeg"/> </div> <div class="clearfix"> </div> <textarea style="height:4px;" name="ms" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message...';}" required>物品描述...</textarea> <input style="width:97%;" type="submit" name="submit" value="发布" > </form> <?php if(isset($_POST['submit'])){ //$username=$_POST['username']; $name = $_POST['name']; $subject = $_POST['subject']; $phone = $_POST['phone']; $image = $_POST['image']; $ms = $_POST['ms']; if($_FILE["image"]["error"]) { echo $_FILE["image"]["error"]; }else{ if(($_FILE["image"]["type"]=="image/jpeg" || $_FILE["image"]["type"]=="image/jpg")&& $_FILE["image"]["size"]<1024000) { $image = "photo/".date("YmdHis").$_FILE["image"]["name"]; //图片存储的路径 $filename = iconv("UTF-8","gb2312",$image); if(file_exists($filename)) { echo "<script>alert('该文件已存在!');</script>"; }else{ //包含数据库连接文件 include('conn.php'); //检测用户名是否已经存在 /*$check_query = mysql_query("select * from userinfo where username='$username' "); $rs = mysql_fetch_array($check_query);//获得结果集 if($rs['username']==1) { echo "<script language='javascript'> alert('禁止访问!'); location.href= 'index.php'; </script>"; exit; } else{*/ //写入数据 $sql = "INSERT INTO mail(name, subject, phone, image,ms)VALUES('$name', '$subject', $phone, '$filename', '$ms')"; if(mysql_query($sql,$conn)){ exit('用户发布成功!点击此处 <a href="event.php">详情</a>'); } else { echo '抱歉!发布失败:',mysql_error(),'<br />'; echo '点击此处.<a href="javascript:history.back(-1);">返回</a> 重试'; } } } } }?>
- 1 回答
- 0 关注
- 1423 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消