空白条目以及有效条目

时间:2014-02-07 18:19:27

标签: php

我正在开发一个项目,可用于预订数据存储在数据库中的事件,其他一切正常,但是当我通过Web界面手动插入新条目时,会输入事件但会添加另一个事件没有任何日期,时间或事件名称或位置,我是新手,似乎无法弄清楚,有人可以帮助我吗?

这是代码....................

<?php
 $target = "upload/"; 
 $target = $target . basename( $_FILES['photo']['name']); 


 $name=$_POST['eventname']; 
 $description=$_POST['eventdescription'];
 $edate=$_POST['eventdate'];
 $etime=$_POST['eventtime'];
 $location=$_POST['eventlocation'];
 $speaker=$_POST['eventspeaker'];
 $pic=($_FILES['photo']['name']);
 $n="upload/$pic"; 
 $duration=$_POST['eventduration'];
 $created=$_POST['createdby'];

 mysql_connect("localhost", "root", "password") or die(mysql_error()) ; 
 mysql_select_db("event") or die(mysql_error()) ; 


 mysql_query("INSERT INTO `events` (eventname, eventdescription, eventdate, eventtime,    eventlocation, eventspeaker, speakerphoto, eventduration, createdby) VALUES ('$name', '$description', '$edate', '$etime', '$location', '$speaker', '$n', '$duration', '$created')") ; 



 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 

  } 
 else {


 ?> 

这是创建表并插入到我的数据库中。

<?
$query[5] = "CREATE TABLE IF NOT EXISTS `events` (

eventsID int(11)NOT NULL AUTO_INCREMENT,   eventname varchar(30)NOT NULL,   eventdescription小文字,   eventdate日期非空,   eventlocation varchar(30)NOT NULL,   eventspeaker varchar(25)DEFAULT NULL,   speakerphoto varchar(25)DEFAULT NULL,   eventduration varchar(10)DEFAULT NULL,   createdby varchar(40)NOT NULL,   eventtime varchar(12)DEFAULT NULL,   PRIMARY KEY(eventsID),   独特的钥匙eventsIDeventsID) )ENGINE = InnoDB DEFAULT CHARSET = latin1 PACK_KEYS = 0 AUTO_INCREMENT = 4“;

插入代码:

$query[4] = "INSERT INTO `attendees` (`attID`, `username`, `lastname`, `firstname`,    `age`, `postaladdress`, `Event`, `attendance`, `comments`) VALUES

0 个答案:

没有答案