Page 1 of 1

Upload and Add Record

Posted: Wed Mar 16, 2005 11:07 pm
by thesimon
Hello,

I use Dreamweaver to aid me in my design because while i can logically think things through i couldnt write syntax to save myself.

I have a form for users to upload newsletters, it has two objectives,

Upload the newsletter file
Record information about the file in a table,

I have gotten all this to work, however unlike my other data entry forms without the upload, i cannot get this script to redirect to another page after it has uploaded and made the database entry.

This is the code that is supposed to do it

Code: Select all

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO newsletters (`path`, userid, `day`, `month`, `year`, `size`, type) VALUES ( %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_FILES['userfile']['name'], "text"),
                       GetSQLValueString($_POST['userid'], "text"),
                       GetSQLValueString($_POST['day'], "int"),
                       GetSQLValueString($_POST['month'], "int"),
                       GetSQLValueString($_POST['year'], "int"),
                       GetSQLValueString($_FILES['userfile']['size'], "text"),
                       GetSQLValueString($_FILES['userfile']['type'], "text"));

  mysql_select_db($database_thesimon_db, $thesimon_db);
  $Result1 = mysql_query($insertSQL, $thesimon_db) or die(mysql_error());

$uploaddir = '/apache2triad/htdocs/knewsl/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
 $logoutGoTo = "cms-newsletterview.php";
 
    header("Location: $logoutGoTo");
Can you please help me so i make make it redirect to another page after it has uploaded the file.

Cheers,
Simon


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Wed Mar 16, 2005 11:28 pm
by feyd
what's being output? Did you check your error logs to make sure there are no errors showing in there? Some servers/browsers require fully-qualified URLs for the Location header.

Posted: Thu Mar 17, 2005 12:15 am
by thesimon
output? ive checked the logs nothing unusal, however if line 21 works why wouldnt line 22 and 24

Posted: Thu Mar 17, 2005 12:26 am
by feyd
thesimon wrote:if line 21 works why wouldnt line 22 and 24
:arrow:
feyd wrote:Some servers/browsers require fully-qualified URLs for the Location header.

There's also a potential that Dreamweaver added invisible character(s) to your code.. it's happened plenty of times before..

Posted: Thu Mar 17, 2005 1:53 am
by thesimon
thankyou so much, i didnt see the bit before about output stuffing up the location change, thus i just used a meta refresh

Thanks,
one very happy child