我无法在更新/编辑php中执行我的代码

时间:2014-03-11 02:47:35

标签: php jquery search

这是我的代码,当我尝试执行任何内容时,我无法编辑...

<?php
include('conn.php');

$user=mysql_query("select * from tblreservation where id='$_REQUEST[edit_id]'");
$fuser=mysql_fetch_array($user);
if(isset($_POST['UPDATE']) && $_POST['UPDATE']=='Update')
{

$name=($_POST['name']);
$email=($_POST['email']);
$Packages=$_POST['Packages'];
$gender=$_POST['gender'];
$Contactno=$_POST['Contactno'];
$address=($_POST['adrs']);
$file=$_FILES['file']['name'];
 $error=array("name"=>"","email"=>"","Packages"=>"","Contactno"=>"","gender"=>"","address"=>"","file"=>"");
//********************name*********************
if($name=="")
{
    $error['name']="Name Is Required.";
}
else
{ 
    if(!preg_match('/^[a-zA-Z\s]+$/',$name))
    {
    $error['name']="Name Can't Contain Numeric Value.";
    }
    else
    {
        if(strlen($name)>6)
        {
            $valid_name=$name;
        }
        else
        {
        $error['name']="Name Should Be Greater Than 6 Characters.";
        }

    }
}

//********************email*********************
if($email=="")
{
    $error['email']="Email Is Required.";   
}
else
{
    if(preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email))                                                                                                                       {
        $valid_email=$email;
    }
    else 
    {
        $error['email']="Invalid Email Address.";
    }
}

//********************gender*********************
if($gender=="")
{
    $error['gender']="Select Gender.";  
}
else
{
    $valid_gender=$gender;
}   
//*******************Contactno********************
if($Contactno=="")
{
    $error['Contactno']="Select Contactno.";    
}
else
{
    $valid_contact=$Contactno;
}   

//********************address*********************
if(empty($address))
{
    $error['address']="Address Is Required.";   
}
else
{
    $valid_address=$address;
}

//********************file*********************
if($file=="")
{
    $error['file']="Image Is Required.";    
}
else
{
    if($_FILES['file']['type']=='image/jpeg' || $_FILES['file']['type']=='image/jpg')
    {
        $valid_file=$file;
    }
    else
    {
        $error['file']="Image Must Be .jpg or .jpeg";   
    }
}

//********************Packages*********************
if($Packages=="")
{
    $error['Packages']="Select A Package."; 
}
else
{
    $valid_Packages=$Packages;
}
if( (strlen($valid_name)>0) && (strlen($valid_email)>0) && (strlen($valid_Packages)>0) && (strlen($valid_gender)>0) && (strlen($valid_Contactno)>0) && (strlen($valid_adress)>0) && (strlen($valid_file)>0) )
{
    $sel=mysql_query("SELECT * FROM tblreservation WHERE email='$email' id!=$_REQUEST[edit_id]");
    $n=mysql_num_rows($sel);
    if($n==0)   
    {
        $path="f/";
        copy($_FILES['file']['tmp_name'],$path.$file);
        //echo "file successfully upload";
        $upd="update tblreservation set name='$name',email='$email',Packages='$Packages',gender='$gender',Contactno='$Contactno',file='$file',address='$address' where id=$_REQUEST[edit_id]";
        mysql_query($upd);
        echo "<script>
        alert('(Id No.$_REQUEST[edit_id]) Record Successfully Updated.');
        window.location='view.php';
        </script>";
    }
    else
    {
        $error['email'] = "Same Email Already Exist";
    }
}   



?>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Untitled Document</title>

 <style type="text/css">
 .err {
color:red;
}
h1
{
padding:0px;
margin:0px;
}
 table {
line-height:40px;
}
td
{
padding-left:20px;
font-weight:bold;
}
</style>
</head>

<form name="f1" method="post"  enctype="multipart/form-data">
<table border="1" align="center" width="70%" rules="groups" height="100%">
<tr bgcolor="#000000" >
  <th align="left" colspan="2"><h1 style="color:#FFF;">Edit Form</h1></th>
</tr>
<tr>
  <td>Name</td>
  <td><input type="text" name="name" id="n" value="<?php echo $fuser['name']; ?>"/>
    <span class="err"><?php echo $error["name"];?></span> </td>
</tr>
<tr>
  <td>Email</td>
  <td><input type="text" name="email" value="<?php echo $fuser['email'];?>"/>
    <span class="err"><?php echo $error["email"];?></span>
  </td>
</tr>
<tr>
  <td>Packages</td>
  <td><select name="Packages">
      <option value="">select Packages</option>
      <option value="budget" <?php if($fuser['Packages']=='budget') echo "selected='selected'";?>>budget</option>
      <option value="standard" <?php if($fuser['Packages']=='standard') echo "selected='selected'";?>>standard</option>
      <option value="super" <?php if($fuser['Packages']=='super') echo "selected='selected'";?>>super</option>
      <option value="mega" <?php if($fuser['Packages']=='mega') echo "selected='selected'";?>>mega</option>
    </select>
    <span class="err"><?php echo $error["Packages"];?>
  </td>
</tr>
<tr>
  <td>Gender</td>
  <td><input type="radio" name="gender" value="male" <?php if($fuser['gender']=='male') echo "checked='checked'";?> />
    Male
    <input type="radio" name="gender" value="female" <?php   if($fuser['gender']=='female') echo "checked='checked'";?>/>
    Female
    <span class="err"><?php echo $error["gender"];?></span>
    </td>
</tr>
<tr>
  <td width="21%">Contact No</td>
  <td width="79%"><input type="text" name="Contactno" class="fieldsize" value="<?php  echo $valid_Contactno;?>" />
    <span class="err"><?php echo $error["Contactno"];?></span></td>
</tr>
<tr>
  <td>Image</td>
  <td><input type="file" name="file" /><br />
  <img src="f/<?php echo $fuser[6]; ?>" height="150" width="150"/>
    <span class="err"><?php echo $error["file"];?></span></td>
</tr>
<tr>
  <td>Address</td>
  <td><textarea name="adrs"><?php echo $fuser['address'];?></textarea>
    <span class="err"><?php echo $error["address"];?></span>
  </td>
</tr>
<tr>
  <td><input type="submit" name="UPDATE" value="Update" />
    <input type="button" value="Cancel" onclick="alert('No Changes Have Been Made');window.location='view.php';" />
  </td>
</tr>
</table>

</form>
</div>
</div>
<?php
}
?>

0 个答案:

没有答案