<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="發(fā)布" >?? ??? ??? ??? ??? ?</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"];? //圖片存儲(chǔ)的路徑??? ??? ??? ??? ?$filename = iconv("UTF-8","gb2312",$image);??? ??? ??? ??? ?if(file_exists($filename))? ??? ??? ??? ? {??? ??? ??? ? ?? ?echo "<script>alert('該文件已存在!');</script>";? ??? ??? ? ?? ? }else{?? ??? ??? ?//包含數(shù)據(jù)庫連接文件?? ??? ??? ?include('conn.php');???? ??? ??? ??? ??? ??? ?//檢測(cè)用戶名是否已經(jīng)存在?? ??? ??? ?/*$check_query = mysql_query("select * from userinfo where username='$username' ");?? ??? ??? ?$rs = mysql_fetch_array($check_query);//獲得結(jié)果集?? ??? ??? ?if($rs['username']==1)??? ??? ??? ?{??? ??? ??? ??? ?echo "<script language='javascript'> alert('禁止訪問!'); location.href= 'index.php'; </script>"; ?? ??? ??? ??? ?exit;?? ??? ??? ?}?? ??? ??? ?else{*/?? ??? ??? ??? ?//寫入數(shù)據(jù)?? ??? ??? ??? ?$sql = "INSERT INTO mail(name, subject, phone, image,ms)VALUES('$name', '$subject', $phone, '$filename', '$ms')";?? ??? ??? ??? ?if(mysql_query($sql,$conn)){?? ??? ??? ??? ??? ?exit('用戶發(fā)布成功!點(diǎn)擊此處 <a href="event.php">詳情</a>');?? ??? ??? ??? ?} else {?? ??? ??? ??? ??? ?echo '抱歉!發(fā)布失敗:',mysql_error(),'<br />';?? ??? ??? ??? ??? ?echo '點(diǎn)擊此處.<a href="javascript:history.back(-1);">返回</a> 重試';?? ??? ??? ??? ?}?? ??? ??? ?}?? ??? ??? ??? ?}??? ? }?? ?}?>
上傳到數(shù)據(jù)庫的圖片路徑?jīng)]有斜杠,怎么辦?
zhang1iang
2018-03-28 16:24:00