Upload and Add Record

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thesimon
Forum Commoner
Posts: 40
Joined: Sun Mar 13, 2005 9:44 pm

Upload and Add Record

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
thesimon
Forum Commoner
Posts: 40
Joined: Sun Mar 13, 2005 9:44 pm

Post by thesimon »

output? ive checked the logs nothing unusal, however if line 21 works why wouldnt line 22 and 24
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
thesimon
Forum Commoner
Posts: 40
Joined: Sun Mar 13, 2005 9:44 pm

Post 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
Post Reply