Jump to content

when the form is filled out brings back fields are empty please help :(


Recommended Posts

<?php

session_start();

include "/iws/b2107945/hnd/common.php";

include("/iws/b2107945/hnd/class.upload.php");

//Check if the user has logged in

include "/iws/b2107945/hnd/checkLoginSession.php";

//COLLECT POST data

$Staring = $_POST['Staring'];

$Staring = strip_tags($Staring);

$Staring = strtoupper($Staring);

$Ditributor = $_POST['Ditributor'];

$Ditributor = strip_tags($Ditributor);

$branch = $_POST['branch'];

$branch = strip_tags($branch);

$Length = $_POST['Length'];

$Length  = strip_tags($Length);

$Releasedate = $_POST['Releasedate'];

$Releasedate  = strip_tags($Releasedate);

$Title  = $_POST['Title'];

$Title  = strip_tags($Title);

$Directedby  = $_POST['Directedby'];

$Directedby  = strip_tags($Directedby);

 

$Description = $_POST['Description'];

$Description  = strip_tags($Description);

 

 

//$propWeek = $_POST['propWeek'];

//$propWeek  = strip_tags($propWeek);

$Propertyid = $_POST['Propertyid'];

$Propertyid  = strip_tags($Propertyid);

$img = $_FILES['img']['name'];

$img  = strip_tags($img);

$imgFullPath = $_POST['img'];

$imgFullPath  = strip_tags($imgFullPath);

 

 

//Form Error Indicators

 

 

//Collect GET vars

$message = $_GET['message'];

//$message = strip_tags($message);

$StaringError = $_GET['StaringError'];

$StaringError = strip_tags($StaringError);

$DitributorError = $_GET['DitributorError'];

$DitributorError = strip_tags($DitributorError);

$branchError = $_GET['branchError'];

$branchError = strip_tags($branchError);

$LengthError = $_GET['LengthError'];

$LengthError = strip_tags($LengthError);

$ReleasedateError = $_GET['ReleasedateError'];

$ReleasedateError = strip_tags($ReleasedateError);

$TitleError = $_GET['TitleError'];

$TitleError = strip_tags($TitleError);

$DirectedbyError = $_GET['DirectedbyError'];

$DirectedbyError = strip_tags($DirectedbyError);

$DescriptionError = $_GET['DescriptionError'];

$DescriptionError = strip_tags($DescriptionError);

$propWeekError = $_GET['propWeekError'];

$propWeekError = strip_tags($propWeekError);

$CreateRecord = $_GET['CreateRecord'];

$CreateRecord = strip_tags($CreateRecord);

//Collect GET data for SAVED data

 

//$savedData.=

$StaringSave = $_GET['StaringSave']; $savedData.= "StaringSave=$Staring&" ;

$DitributorSave = $_GET['DitributorSave']; $savedData.= "DitributorSave=$Ditributor&";

$LengthSave = $_GET['LengthSave']; $savedData.= "LengthSave=$Length&";

$ReleasedateSave = $_GET['ReleasedateSave']; $savedData.= "ReleasedateSave=$Releasedate&"; 

$TitleSave  = $_GET['TitleSave']; $savedData.= "TitleSave=$Title&";

$DirectedbySave  = $_GET['DirectedbySave']; $savedData.= "DirectedbySave=$Directedby&";

$DescriptionSave = $_GET['DescriptionSave']; $savedData.= "DescriptionSave=$Description&";

$propWeekSave = $_GET['propWeekSave']; $savedData.= "propWeekSave=$propWeek&";

$agentIDSave = $_GET['agentIDSave']; $savedData.= "agentIDSave=$agentID&";

$imgSave = $_GET['imgSave']; $savedData.= "imgSave=$img&";

 

 

 

if($CreateRecord==1){

 

//Check for empty fields and setup css error var

if(empty($Staring)){

//Sets up a css class to indicate the field error on the form

$StaringError = "StaringError";

$errorString.= "StaringError=$StaringError&";

}

if(empty($Ditributor)){

//Sets up a css class to indicate the field error on the form

$DitributorError = "DitributorError";

$errorString.= "DitributorError=$DitributorError&";

}

if(empty($Length)){

//Sets up a css class to indicate the field error on the form

$LengthError = "LengthError";

$errorString.= "LengthError=$LengthError&";

}

if(empty($Title)){

//Sets up a css class to indicate the field error on the form

$TitleError = "TitleError";

$errorString.= "TitleError=$TitleError&";

}

if(empty($Directedby)){

//Sets up a css class to indicate the field error on the form

$DirectedbyError = "DirectedbyError";

$errorString.= "DirectedbyError=$DirectedbyError&";

}

if(empty($Description)){

//Sets up a css class to indicate the field error on the form

$DescriptionError = "DescriptionError";

$errorString.= "DescriptionError=$DescriptionError&";

}

 

//Combine Error Data into one string

$errorString .= $savedData ;

$errorParse .= $errorString ;

 

//New routine for generating errors -- Uses $errorString to construct the GET vars

if(empty($Staring) || empty($Ditributor) || empty($branch) || empty($Length) || empty($Title) || empty($Directedby) || empty($Description)){

$message = "Please check the form for missing data in hightlighted fields";

header("location: $PHP_SELF?message=$message&$errorParse");

exit();

}

 

DBConnect();

$Link = mysql_connect($Host, $User, $Password);

$agentID = $_SESSION['userID'];

 

//-------Routine for Dealing With Property Of Week-------//

//Sets the Flag to NO for all properties if the current property is SET to YES

$Query_propWeek= "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";

 

$Result_propWeek = mysql_db_query ($DBName, $Query_propWeek, $Link);

 

 

while($Row_propWeek = mysql_fetch_array($Result_propWeek)){

 

$Row = $Row_propWeek[id] ;

 

$Query_updatePropWeek = "UPDATE $table1 SET propWeek = 'No' WHERE id = $Row";

if (mysql_db_query ($DBName, $Query_updatePropWeek, $Link)){

 

//echo "Properties Propweek changed";

}else{

//echo "Properties Propweek could NOT be changed";

 

}

 

}

 

 

$propWeek = "Yes";

$imgpath = "propertyImages/tmp.jpg";

$imgpath2 = "propertyImages/tmp2.jpg";

 

 

$Query = "INSERT INTO $table1 VALUES ('0', '$Staring', '$Ditributor', '$branch', '$Length', '$Releasedate', '$Title', '$Directedby', '$Description', '$propWeek', '$agentID', '$imgpath', '$imgpath2')";

 

 

if (mysql_db_query ($DBName, $Query, $Link)){

 

//Need to copy the img file

//Bug fix on 27.07.07 we were not getting reliable number matches for the img fields

//This new routine is more complex but fixes the bug

//We now need to change to add image routine so that the image matches the id exactly

if(empty($img)){

$img = "none";

$img2 = "none";

}else{

//Peform Select Query To Find THIS record only - It must match exactly

$Query = "SELECT id, propWeek FROM $table1 WHERE propWeek = 'Yes'";

$Result = mysql_db_query ($DBName, $Query, $Link);

$Row = mysql_fetch_array($Result);

$Propertyid = $Row[id];

//Generate the new img paths

$file1 = $Propertyid;

$file2 = $Propertyid;

$file1 = "propertyThumb".$file1 ;

$f = "propertyThumb".$file2 ;

$f = $f.=".jpg";

$fileLarge = "propertyLarge".$file2 ;

$fileLarge = $fileLarge.=".jpg";

$imgpath = "propertyImages/$f";

$imgpath2 = "propertyImages/$fileLarge";

 

//Peform UPDATE query to add in the new data for the img feilds

$Query2 = "UPDATE $table1 SET img = '$imgpath', img2 = '$imgpath2' WHERE id = $Propertyid";

mysql_db_query ($DBName, $Query2, $Link)or die(mysql_error());

}

 

copy($_FILES['img']['tmp_name'], "../propertyImages/$fileLarge");

 

//Handle the image processing in the class

 

$handle = new upload($_FILES['img']);

if ($handle->uploaded) {

$handle->file_new_name_body = $file1;

$handle->file_new_name_ext = 'jpg';

$handle->image_resize = true;

$handle->image_x = 200;

$handle->image_y = 200;

$handle->image_ratio_y = true;

$handle->image_ratio_x = true;

$handle->jpeg_quality = 100;

//$handle->image_text = '$title';

//$handle->image_text_direction = 'h';

//$handle->image_text_color = '#FF0000';

//$handle->image_text_percent = 50;

//$handle->image_text_font = 4;

//$handle->image_text_y = 5;

//$handle->image_text_x = 5;

$handle->process('../propertyImages');

if ($handle->processed) {

          //echo 'image resized';

          $handle->clean();

      } else {

          echo 'error : ' . $handle->error;

      }

  }

 

$Query3 = "SELECT MAX(id) FROM $table1";

$Result = mysql_db_query ($DBName, $Query3, $Link);

$Row = mysql_fetch_array($Result);

$new = $Row['MAX(id)'];

 

$message = "Film added Successfully! <br /><a href='ourURL../displayPropFullDetails.php?propertySelect=$new  target=_blank'><br />Click Here To Review add new Film</a>";

header("location: $PHP_SELF?message=$message");

}else{

$message = "Error Creating Film";

header("location: $PHP_SELF?message=$message");

 

}

mysql_close($Link);

 

}

 

 

?>

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>BigScreen</title>

<link rel="stylesheet" type="text/css" href="../stylesheet.css"/><link rel="stylesheet" type="text/css" href="../mainstyle.css"/><link rel="stylesheet" type="text/css" href="../dataDisplay.css"/><link rel="stylesheet" type="text/css" href="../AdminSmartmove.css"/>

</head>

 

<body>

<div id="body">

<div id="header">

</div>

<div id="navbuttons">

  <ul>

 

    <li><span id="left"><a  href="#"><b>Home</b></a></span></li>

    <li><span id="middle"><a  href="#"><b>Coming Soon</b></a></span></li>

    <li><span id="middle"><a  href="#" ><b>New Releases</b></a></span></span></li>

<li><span id="middle"><a  href="#" ><b>Cinemas</b></a></span></li>

    <li><span id="middle"><a  href="#" ><b>Films A to Z</b></a></span></li>

    <li><span id="middle"><a  href="#" ><b>Actors</b></a></span></li>

    <li><span id="middle"><a  href="#" ><b>Login</b></a></span></li>

    <li><span id="right"><a  href="#" ><b>Profile</b></a></span></li>

</ul>

   

</div>

<div id="container">

 

<div id="adminText">

      <form action="adminaddfilm.php?CreateRecord=1" method="post" enctype="multipart/form-data" name="form1" id="genericForm">

 

<fieldset>

    <legend>Add New Film</legend>

<div><label for="Title">Title</label><input id="address2" name="Title" type="text" class="<?php echo $TitleError ; ?>"  value="<?php echo $TitleSave ; ?>" /></div>

<div><label for="Directedby">Directed by</label><input id="address3" name="Directedby" type="text" class="<?php echo $DirectedbyError ; ?>" value="<?php echo $DirectedbySave ; ?>" /></div>

<div><label for="Staring">Staring</label><input id="postcode" name="Staring" type="text" size="20" class="<?php echo $StaringError ; ?>" value="<?php echo $StaringSave ; ?>" />

</div>

       

        <div><label for="Length">Length</label>

  <input id="bedrooms" name="Length" type="text" class="<?php echo $LengthError ; ?>" value="<?php echo $LengthSave ; ?>" size="4" />

</div>

       

       

<div><label for="Ditributor">Ditributor</label><input id="price" name="Ditributor" type="text" size="8" class="<?php echo $DitributorError ; ?>" value="<?php echo $DitributorSave ; ?>"  />

</div>

<div>

<label for="Releasedate">Release date</label><input id="price" name="Releasedate" type="text" size="8" class="<?php echo $ReleasedateError ; ?>" value="<?php echo $ReleasedateSave ; ?>"  />

  </div>

 

<div><label for="Description">Description</label>

  <textarea id="Description" name="Description" class="<?php echo $DescriptionError  ; ?>"><?php echo $DescriptionSave ; ?></textarea>

         

         

</div>

 

 

<div><label for="file">Film poster</label>

<input id="img" name="img" type="file" value="<?php echo $imgSave ; ?>" /></div>

<div class="submit"><input name="Submit" type="Submit" class="btn" value="Add Film" /></div>

</fieldset>

        </form>

    </div>

 

</div>

<div id="footer">

</div>

 

 

 

 

 

</div>

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.