Hi,

I have put the header () in the php code which goes before the doctype html code, so why am I getting the error?

Thanks,

Phil

    If all that code is before the html, that's good. But, then you have parts like this:

    if (move_uploaded_file($_FILES['upload']['tmp_name'], "./uploads/$filename")) { 
                echo '<p>The file has been uploaded!</p>'; 
            } else { 
                echo '<p><font color="red">The file could not be moved.</font></p>';
    

    That's outputting html to your page before it gets to the header() bit.

    Which I'm not real sure why that's in there anyway since (unless I'm missing something) it seems like you'll be switching pages before the user sees that anyway. 🙂

      I have placed the header near the top before any html and I am still getting the error as above, how would you adapt the script to have the page redirect after submitting?

      Thanks,

      Phil

        Okay, analyzing your code...

        So, once your form is submitted...
        You go through some error checking...for which the code is not making much sense to me.

        if (!empty($_POST['type'])) { 
                $t = escape_data($_POST['type']); 
                $message .= '<p>You forgot to enter the property type!</p>'; 
            } else { 
                $t = '';
        }
        

        If you get a value for 'type', then set $t to the value and then print a message that says you didn't fill it in??? If you don't have a value, then $t is nothing???

        Why not do it this way:

        if (strlen($_POST['type'])) { 
                $t = escape_data($_POST['type']);
            } else { 
                $message .= '<p>You forgot to enter the property type!</p>';
        }
        

        So, that would say, if you have a value for 'type' then set $t to that value....otherwise, append an error to the $message var.

        Okay, after you check for the errors...
        You'll probably want to put an if statement around your sql query so that it doesn't occur if there were errors:

        if (empty($message)){
        $query = "INSERT INTO woodman (type, location, price, ref, high_lights, status, pics_thumburl, pdf, registration_date) VALUES ('$t', '$l', '$p', '$r', '$h', '$s', '$pics_thumburl', '$pdf', NOW())"; 
            $result = @mysql_query ($query);
        }
        

        Next...You have your file operations. That all looks fine...basically.

        What confuses me about all this is that you've got the header() there with only one condition on it. If the form is submitted, go to http://www.mysite.co.uk/woodman_confirm_detail.php. So, none of the error checking, confirm and failure messages matter at all. They're set and ready to go, but right before they're displayed to the user, the page changes. They'll never know if their operation worked or not.

        Where is $message printed?

        You should do the same type thing as $message with all the echos you've written for the file operations. Maybe even append those to the $message var. That way you can leave your header() where it is because you won't be echoing anything.

        The only case you'd need to echo something is in the event of an error. If everything goes fine, the page will redirect and you won't see any message unless you send it to the following page to be displayed.

        You'll need to put your redirect in a conditional statement as well. If there are errors, don't do it and print the message on the page instead.

        See what I mean?

          to use header even after output, set the value of your 'output_buffering' on php.ini to 'ON' or set it in bytes (e.g 4096)..., (set this on will make your page load slower in price),
          then to let your messages to be viewed for a few seconds before redirect, try to use this
          header("Refresh:3;url=http://www.mysite.co.uk/woodman_confirm_detail.php");
          it will wait for 3 seconds before redirecting to url you specified.
          other option to redirect? use js (make like a 'goto' function) instead of header.

            Pehape wrote:

            to use header even after output, set the value of your 'output_buffering' on php.ini to 'ON' or set it in bytes (e.g 4096)..., (set this on will make your page load slower in price),
            then to let your messages to be viewed for a few seconds before redirect, try to use this
            header("Refresh:3;url=http://www.mysite.co.uk/woodman_confirm_detail.php");
            it will wait for 3 seconds before redirecting to url you specified.
            other option to redirect? use js (make like a 'goto' function) instead of header.

            JS => not activated by everyone...

            Output buffering can also be set using ob_start() and other functions... (see php.net)

              yeah, that's what i said as an other option... use it with consideration and
              yeah like u said, it's better to let the ob value to 'off' and make it start using ob_start(), when u ready to throw the output , u can use ob_end_flush();

                Hi Guys,

                Thanks for your responses, I have made a few changes to the code to what you said tyree, but I still can't get it to work. Well, what I mean is I still can't get it to either show the error messages if there was an error or transfer to another page when it is submitted. When I use the ob_start, clean and flush with the script the script works as far as it will submit all of the boxes to the database and upload the files, but it won't then say after submitting that the file was trasferred. When I don't use the ob() function I get an error like this - Your submission could not be processed due to a system error. We apologize for any inconvenience.

                Warning: mysql_close(): no MySQL-Link resource supplied in /home/philweb/public_html/add_file6.php on line 114

                I am sorry but I am going to have to call on your expertise to get me out of this one again. Here is the code for what I have done, I have taken the ob() function out.

                Thanks,

                Phil

                // Set the page title and include the HTML header.
                $page_title = 'Upload a File';
                
                if (isset($_POST['submit'])) { // Handle the form.
                
                require_once ('./mysql_connect.php'); // Connect to the database.
                
                // Function for escaping and trimming form data.
                function escape_data ($data) { 
                	global $dbc;
                	if (ini_get('magic_quotes_gpc')) {
                		$data = stripslashes($data);
                	}
                	return mysql_real_escape_string (trim ($data), $dbc);
                } // End of escape_data() function.
                
                 // Check for a property type.
                if (strlen($_POST['type'])) { 
                    $t = escape_data($_POST['type']);
                } else { 
                    $message .= '<p>You forgot to enter the property type!</p>';
                }
                
                // Check for a location.
                if (strlen($_POST['location'])) { 
                    $l = escape_data($_POST['location']);
                } else { 
                    $message .= '<p>You forgot to enter the location!</p>';
                }
                
                // Check for a price.
                if (strlen($_POST['price'])) { 
                    $p = escape_data($_POST['price']);
                } else { 
                    $message .= '<p>You forgot to enter the price!</p>';
                }
                
                }
                // Check for a reference.
                if (strlen($_POST['ref'])) { 
                    $r = escape_data($_POST['ref']);
                } else { 
                    $message .= '<p>You forgot to enter the reference!</p>';
                }
                
                // Highlights.
                if (strlen($_POST['high_lights'])) { 
                    $h = escape_data($_POST['high_lights']);
                } else { 
                    $message .= '<p>You forgot to enter the highlights!</p>';
                }
                
                
                // Status.
                if (strlen($_POST['status'])) { 
                    $s = escape_data($_POST['status']);
                } else { 
                    $message .= '<p>You forgot to enter the status!</p>';
                }
                
                $pics_thumburl = "uploads/".$_FILES['upload']['name'];
                
                $pdf = "uploads/pdf".$_FILES['upload_pdf']['name'];
                
                // Add the record to the database.
                if (empty($message)){
                $query = "INSERT INTO woodman (type, location, price, ref, high_lights, status, pics_thumburl, pdf, registration_date) VALUES ('$t', '$l', '$p', '$r', '$h', '$s', '$pics_thumburl', '$pdf', NOW())"; 
                    $result = @mysql_query ($query);
                }
                
                if ($result) {
                
                
                
                	// Create the file name.
                	$extension = explode ('.', $_FILES['upload']['name']);
                	$uid = mysql_insert_id(); // Upload ID
                	$filename = $_FILES['upload']['name'];
                
                	// Move the file over.
                	if (move_uploaded_file($_FILES['upload']['tmp_name'], "./uploads/$filename")) {
                		echo '<p>The file has been uploaded!</p>';
                	} else {
                		echo '<p><font color="red">The file could not be moved.</font></p>';
                
                		// Remove the record from the database.
                		$query = "DELETE FROM woodman WHERE upload_id = $uid";
                		$result = @mysql_query ($query);
                	}
                	// Create the file name.
                	$extension = explode ('.', $_FILES['upload_pdf']['name']);
                	$uid = mysql_insert_id(); // Upload ID
                	$filename = $_FILES['upload_pdf']['name'];
                
                	// Move the file over.
                	if (move_uploaded_file($_FILES['upload_pdf']['tmp_name'], "./uploads/pdf/$filename")) {;
                
                	} else {
                		echo '<p><font color="red">The file could not be moved.</font></p>';
                
                		// Remove the record from the database.
                		$query = "DELETE FROM woodman WHERE upload_id = $uid";
                		$result = @mysql_query ($query);
                	} 
                	header ('Location: http://www.mysite.co.uk/woodman_confirm_detail.php');
                } else { // If the query did not run OK.
                	echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>'; 
                }
                
                
                mysql_close(); // Close the database connection.

                  Hi,

                  I have changed the mysql result line to what you said. The errors still say when I view the page "Your submission could not be processed due to a system error. We apologize for any inconvenience.

                  Warning: mysql_close(): no MySQL-Link resource supplied in /home/philweb/public_html/add_file6.php on line 114"

                  Line 114 is the

                  mysql_close();

                  However when I now upload the form there is a message that says the file has been uploaded but then a waning like this appears - Warning: Cannot modify header information - headers already sent by (output started at /home/philweb/public_html/add_file6.php:1) in /home/philweb/public_html/add_file6.php on line 108

                  Line 108 is this -

                  header ('Location: http://www.mysite.co.uk/woodman_confirm_detail.php');

                  Thanks,

                  Phil

                    yeah, that's because you remove the ob() function. header cannot be sent because an output has already started.
                    have u try what i said before, try to use like
                    header("Refresh:3;url=http://www.mysite.co.uk/woodman_confirm_detail.php");
                    it hold display for 3 second, that's enough for ur user to read the result information.
                    e.g:

                      if (move_uploaded_file($_FILES['upload']['tmp_name'], "./uploads/$filename")) { 
                               ob_start();
                               header("Refresh:3;url=http://www.mysite.co.uk/woodman_confirm_detail.php");
                               echo '<p>The file has been uploaded!</p>';
                               ob_end_flush();  
                    }

                    i assume the words 'file has been uploaded!' is ur first output.
                    user can read it for 3 secs before it moves to url you specify.
                    try to apply it in your code.

                      Phil,

                      The problem is you're still echoing before you get to the header(). Because of this you will always get the header error.

                      Before you can go any further, you have to decide if you want the user to see any confirmation message on this page before he/she is redirected.

                      Right now, if you were to set all those echos to be a variable...like you did with $message...you could echo them out after the redirect...BUT, that makes no sense because you'll be on another page before the message is ever printed.

                      So, right now you're between a rock and a hard place. The way I see it, you have 3 options:
                      1. Scrap confirmation messages to get the redirect working.
                      2. Set the confirmation messages as a variable and pass the variable to the next page to be displayed there.
                      3. Scrap the redirect and provide a link under the confirm messages to go to the next page.

                      Well, a fourth would be Pehape's suggestion...Although I've never done that and if you're not absolutley sure of yourself, I wouldn't go tinkering with the php.ini file. 🙂

                      Let me know which of those options you want to do.

                      Later!

                        if you are going to use ob_start(), put it as the FIRST line of the entire page, that'll supress the header error

                        of course, it is best to rethink how you are doing things so you can negate using the ob_start(), but it will work as suggested

                        stolzyboy

                          Hi,

                          Yes it has all got a bit confusing, so I think that I would like to scrap the message and just get the redirection working once the form is submitted. Is it possible to write a few lines for me to insert into the code to get this working?

                          As usual, I appreciate all of your help and one day I hope to be able to offer some help to other newbies.

                          Thanks,

                          Phil

                            if you decide to scrap the message, then do a usual insert routine and after that feel confident to place your header("location:url");,yeah it would work since you decided to scrap the output message, just remember that header location must takes place before any output. make sure there is no output before (including any html tag or the one you echoed), so you can place your header location anywhere in your code.
                            : in your code. e.g (form.php)

                                <?
                                   if (isset($_POST['submit'])) // true if submit button is pressed
                                  { cek post variable then do a insert process 
                                     header("location:url"); // redirect
                                   }
                                  else
                                  { ?> 
                                     <html>
                                            ...
                                               <form action=form.php method=post>
                                               ...       //input box here including submit button, name="submit"
                                              </form>
                                            ...
                                     </html>
                                <?  }
                            ?>
                            

                            see, each time this page is processed (start from top) until it found the header function, no output would be sent. the form is the else part, where the user first open your page, the isset submit s false since submit is not set yet. -- if submit is pressed then it will re-call the page and start from top again. where now, the isset is the true part. so no tag html will be sent. and your header will work fine.

                              Thanks Pehape,

                              I have tried putting in your code into my script but I can't seem to get it working, is the code you wrote correct? Is it possible you can adjust the code below so you can see what you are working with?

                              Thanks,

                              Phil

                              $page_title = 'Upload a File';
                              
                              if (isset($_POST['submit'])) { // Handle the form.
                                   require_once ('./mysql_connect.php'); // Connect to the database.
                              	 header ('Location: http://www.mysite.co.uk/woodman_confirm_detail.php'); // redirect
                              	// Function for escaping and trimming form data.
                              	function escape_data ($data) { 
                              		global $dbc;
                              		if (ini_get('magic_quotes_gpc')) {
                              			$data = stripslashes($data);
                              		}
                              		return mysql_real_escape_string (trim ($data), $dbc);
                              	} // End of escape_data() function.
                              
                               // Check for a property type.
                              if (strlen($_POST['type'])) { 
                                  $t = escape_data($_POST['type']);
                              } else { 
                                  $message .= NULL;
                              }
                              
                              // Check for a location.
                              if (strlen($_POST['location'])) { 
                                  $l = escape_data($_POST['location']);
                              } else { 
                                  $message .= NULL;
                              }
                              
                              // Check for a price.
                              if (strlen($_POST['price'])) { 
                                  $p = escape_data($_POST['price']);
                              } else { 
                                  $message .= NULL;
                              }
                              
                              }
                              // Check for a reference.
                              if (strlen($_POST['ref'])) { 
                                  $r = escape_data($_POST['ref']);
                              } else { 
                                  $message .= NULL;
                              }
                              
                              // Highlights.
                              if (strlen($_POST['high_lights'])) { 
                                  $h = escape_data($_POST['high_lights']);
                              } else { 
                                  $message .= NULL;
                              }
                              
                              
                              // Status.
                              if (strlen($_POST['status'])) { 
                                  $s = escape_data($_POST['status']);
                              } else { 
                                  $message .= NULL;
                              }
                              
                              $pics_thumburl = "uploads/".$_FILES['upload']['name'];
                              
                              $pdf = "uploads/pdf".$_FILES['upload_pdf']['name'];
                              
                              // Add the record to the database.
                              if (empty($message)){
                              $query = "INSERT INTO woodman (type, location, price, ref, high_lights, status, pics_thumburl, pdf, registration_date) VALUES ('$t', '$l', '$p', '$r', '$h', '$s', '$pics_thumburl', '$pdf', NOW())"; 
                                  $result = @mysql_query ($query) or die('MySQL error: ' . mysql_error() . '<hr>Query: ' . $query); 
                              }
                              
                              if ($result) {
                              
                              
                              
                              	// Create the file name.
                              	$extension = explode ('.', $_FILES['upload']['name']);
                              	$uid = mysql_insert_id(); // Upload ID
                              	$filename = $_FILES['upload']['name'];
                              
                              	// Move the file over.
                              	if (move_uploaded_file($_FILES['upload']['tmp_name'], "./uploads/$filename")) {
                              		echo '<p>The file has been uploaded!</p>';
                              	} else {
                              		echo '<p><font color="red">The file could not be moved.</font></p>';
                              
                              		// Remove the record from the database.
                              		$query = "DELETE FROM woodman WHERE upload_id = $uid";
                              		$result = @mysql_query ($query);
                              	}
                              	// Create the file name.
                              	$extension = explode ('.', $_FILES['upload_pdf']['name']);
                              	$uid = mysql_insert_id(); // Upload ID
                              	$filename = $_FILES['upload_pdf']['name'];
                              
                              	// Move the file over.
                              	if (move_uploaded_file($_FILES['upload_pdf']['tmp_name'], "./uploads/pdf/$filename")) {;
                              
                              	} else {
                              		echo '<p><font color="red">The file could not be moved.</font></p>';
                              
                              		// Remove the record from the database.
                              		$query = "DELETE FROM woodman WHERE upload_id = $uid";
                              		$result = @mysql_query ($query);
                              	} 
                              
                              } else { // If the query did not run OK.
                              	echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>'; 
                              }
                              
                              
                              mysql_close(); // Close the database connection.
                              
                               // End of the main Submit conditional.

                                what i wrote is just a code structure which showed the header place.
                                the code you showed us , was it the complete one? i don't see any <html> tag, you sure you don't use it in this php file,don't you?
                                sorry but it's hard for us to know where is the wrong part. perhaps you could tell us more detail :
                                you said it's not working...,it ran well but didn't redirect ? or there was errors that have made your code was not processed. if so, then could you tell us what it say?

                                --sorry for my bad english _--- are u find a hard time to read and understand my post? hehehe sorry for that ----

                                  Ok here goes, when the script is posted I can get the form to work perfectly and when the form is posted the message "The file has been uploaded" appears. But when I open the page to view it has two errors, 1, Your submission could not be processed due to a system error. We apologize for any inconvenience. 2, Warning: mysql_close(): no MySQL-Link resource supplied in /home/philweb/public_html/add_file6.php on line 114

                                  Line 114 is

                                  mysql_close(); // Close the database connection.

                                  So apart from the errors the form works perfectly, now when I posted the script earlier today I had changed the echo statements to NULL, this was causing more errors so I have returned them to something like they were before.

                                  So that is all I know. Here is the script as it stands and the form that goes with it.

                                  I really hope you can adapt the script so upon submit the page then redirects to the other page. Good luck, I will await your response.

                                  Thanks,

                                  Phil

                                  // Set the page title and include the HTML header.
                                  $page_title = 'Upload a File';
                                  
                                  if (isset($_POST['submit'])) { // Handle the form.
                                  
                                   require_once ('./mysql_connect.php'); // Connect to the database.
                                  
                                  // Function for escaping and trimming form data.
                                  function escape_data ($data) { 
                                  	global $dbc;
                                  	if (ini_get('magic_quotes_gpc')) {
                                  		$data = stripslashes($data);
                                  	}
                                  	return mysql_real_escape_string (trim ($data), $dbc);
                                  } // End of escape_data() function.
                                  
                                   // Check for a property type.
                                  if (strlen($_POST['type'])) { 
                                      $t = escape_data($_POST['type']);
                                  } else { 
                                      $message .= '<p>You forgot the type</p>';
                                  }
                                  
                                  // Check for a location.
                                  if (strlen($_POST['location'])) { 
                                      $l = escape_data($_POST['location']);
                                  } else { 
                                      $message .= '<p>You forgot the location</p>';
                                  }
                                  
                                  // Check for a price.
                                  if (strlen($_POST['price'])) { 
                                      $p = escape_data($_POST['price']);
                                  } else { 
                                      $message .= '<p>You forgot the price</p>';
                                  }
                                  
                                  }
                                  // Check for a reference.
                                  if (strlen($_POST['ref'])) { 
                                      $r = escape_data($_POST['ref']);
                                  } else { 
                                      $message .= '<p>You forgot the reference</p>';
                                  }
                                  
                                  // Highlights.
                                  if (strlen($_POST['high_lights'])) { 
                                      $h = escape_data($_POST['high_lights']);
                                  } else { 
                                      $message .= '<p>Highlights</p>';
                                  }
                                  
                                  
                                  // Status.
                                  if (strlen($_POST['status'])) { 
                                      $s = escape_data($_POST['status']);
                                  } else { 
                                      $message .= '<p>Status</p>';
                                  }
                                  
                                  $pics_thumburl = "uploads/".$_FILES['upload']['name'];
                                  
                                  $pdf = "uploads/pdf".$_FILES['upload_pdf']['name'];
                                  
                                  // Add the record to the database.
                                  if (empty($message)){
                                  $query = "INSERT INTO woodman (type, location, price, ref, high_lights, status, pics_thumburl, pdf, registration_date) VALUES ('$t', '$l', '$p', '$r', '$h', '$s', '$pics_thumburl', '$pdf', NOW())"; 
                                      $result = @mysql_query ($query) or die('MySQL error: ' . mysql_error() . '<hr>Query: ' . $query); 
                                  }
                                  
                                  if ($result) {
                                  
                                  
                                  
                                  	// Create the file name.
                                  	$extension = explode ('.', $_FILES['upload']['name']);
                                  	$uid = mysql_insert_id(); // Upload ID
                                  	$filename = $_FILES['upload']['name'];
                                  
                                  	// Move the file over.
                                  	if (move_uploaded_file($_FILES['upload']['tmp_name'], "./uploads/$filename")) {
                                  		echo '<p>The file has been uploaded!</p>';
                                  	} else {
                                  		echo '<p><font color="red">The file could not be moved.</font></p>';
                                  
                                  		// Remove the record from the database.
                                  		$query = "DELETE FROM woodman WHERE upload_id = $uid";
                                  		$result = @mysql_query ($query);
                                  	}
                                  	// Create the file name.
                                  	$extension = explode ('.', $_FILES['upload_pdf']['name']);
                                  	$uid = mysql_insert_id(); // Upload ID
                                  	$filename = $_FILES['upload_pdf']['name'];
                                  
                                  	// Move the file over.
                                  	if (move_uploaded_file($_FILES['upload_pdf']['tmp_name'], "./uploads/pdf/$filename")) {;
                                  
                                  	} else {
                                  		echo '<p><font color="red">The file could not be moved.</font></p>';
                                  
                                  		// Remove the record from the database.
                                  		$query = "DELETE FROM woodman WHERE upload_id = $uid";
                                  		$result = @mysql_query ($query);
                                  	} 
                                  
                                  } else { // If the query did not run OK.
                                  	echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>'; 
                                  }
                                  
                                  
                                  mysql_close(); // Close the database connection.
                                  <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
                                  
                                  <input type="hidden" name="MAX_FILE_SIZE" value="524288">
                                  
                                  <fieldset><legend>Fill out the form to upload a file:</legend>
                                  
                                  <p>&nbsp;</p>
                                  
                                  <table width="100%"  border="0" cellspacing="1" cellpadding="1">
                                    <tr>
                                      <td><b>House Picture :</b> </td>
                                      <td><input type="file" name="upload" /></td>
                                    </tr>
                                    <tr>
                                      <td><b>Pdf:</b> </td>
                                      <td><input type="file" name="upload_pdf" /></td>
                                    </tr>
                                    <tr>
                                      <td><b>Property Type:</b></td>
                                      <td><input name="type" type="text" id="type" value="<?php if (isset($_POST['type'])) echo $_POST['type']; ?>" size="15" maxlength="15" /></td>
                                    </tr>
                                    <tr>
                                      <td><b>Location:</b></td>
                                      <td><input name="location" type="text" id="location" value="<?php if (isset($_POST['location'])) echo $_POST['location']; ?>" size="15" maxlength="15" /></td>
                                    </tr>
                                    <tr>
                                      <td><b>Price:</b></td>
                                      <td><input name="price" type="text" id="price" value="<?php if (isset($_POST['price'])) echo $_POST['price']; ?>" size="15" maxlength="15" /></td>
                                    </tr>
                                    <tr>
                                      <td><b>Reference:</b></td>
                                      <td><input name="ref" type="text" id="ref" value="<?php if (isset($_POST['ref'])) echo $_POST['ref']; ?>" size="15" maxlength="15" /></td>
                                    </tr>
                                    <tr>
                                      <td valign="top"><strong>Highlights:</strong></td>
                                      <td><textarea name="high_lights" cols="30" id="high_lights"><?php if (isset($_POST['high_lights'])) echo $_POST['high_lights']; ?>
                                      </textarea></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Staus:</strong></td>
                                      <td><input name="status" type="text" id="status" value="<?php if (isset($_POST['status'])) echo $_POST['status']; ?>" size="15" maxlength="15" /></td>
                                    </tr>
                                    <tr>
                                      <td><strong>This entry will be active! </strong></td>
                                      <td></td>
                                    </tr>
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td><input type="submit" name="submit" value="Submit" /></td>
                                    </tr>
                                  </table>
                                  
                                  </fieldset>
                                  
                                  <div align="center"></div>
                                  </form><!-- End of Form -->

                                    if (move_uploaded_file($_FILES['upload_pdf']['tmp_name'], "./uploads/pdf/$filename")) {;

                                    remove the ;

                                    mysql_close(); // Close the database connection.

                                    try to add @ sign. so @mysql_close();

                                    sorry but i don't really get what you explained above,
                                    CMIIW - you success in uploading file (the data inserted on your db).
                                    - you don't use header anymore...
                                    - what you mean to 'open and view the page?' , it's on the same page...
                                    what page?
                                    - what you complained is about that two error,
                                    - error 1, that's not the error you've wrote on your code,right ?

                                    else { // If the query did not run OK.
                                    echo '<p><font color="red">Your submission could not be processed due to a system error. We apologize for any inconvenience.</font></p>';
                                    }

                                    error 2, thats just a warning, try adding @ on mysql_close()

                                    i'm sorry but, it seem we don't get too clear on express our meant.
                                    just try the trick above, see if it's not working..., post your next condition
                                    and perhaps the gurus could stop by and help us.

                                      Hi,

                                      The @ in front of the mysql_close(); worked - thank you. However, when I type in the web address into the browser I get this message at the top "Your submission could not be processed due to a system error. We apologize for any inconvenience." The form still works as far as it uploads all of the info into the db, but takes about 15 seconds to upload it. When it has done this I get two messages 1 is The file has been uploaded! and below that is message 2 which is The file could not be moved.

                                      I have removed the ; from the line that you said, so I guess it's back to you for more help please, and to think we haven't even got to inserting the header() yet!

                                      Thanks,

                                      Phil

                                        after read your code, i think of these:

                                        $pdf = "uploads/pdf".$_FILES['upload_pdf']['name'];

                                        - uploads/pdf/.... --add /
                                        - is your pdf dir. exist?

                                        // Check for a price.
                                        if (strlen($POST['price'])) {
                                        $p = escape_data($
                                        POST['price']);
                                        } else {
                                        $message .= NULL;
                                        }

                                           }  

                                        the last curly is closing your first isset conditional.
                                        you mean it? or it's a mistake... try to move it.
                                        your entire page should do this: when the page is loaded, check if there are post variables sent, (you've done this by place if (isset $_POST['submit'] ) . if true, then you write all the process like moving file etc...

                                        and if your isset is false then you show html form that has the submit button.

                                        make sure you do it in this way, so when user write the address on your url browser. it will show html form for them to submit file.

                                        if i'm not wrong, that curly should be placed on the bottom, below the mysql_close()

                                        so

                                            ...
                                               mysql_close(); // Close the database connection.
                                              }
                                           else  // this is your else part if isset is false
                                        {
                                          ... // html form 
                                        }
                                        

                                        it's your job to analize your code, you're the one who know exatctly how it should run. so try to debug it yourself, you can do this by split your code, i mean you could mark as comment several of your code and run it one by one to find where is the error... yeah.. that's a tedious task..