Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-05-2008, 12:30 PM Form Error - Help
mattbtay's Avatar
Average Talker

Posts: 15
Name: Matt
Trades: 0
I have an upload form that i am using to submit resumes when the form is submitted i get the error message:
Quote:
Warning: Cannot modify header information - headers already sent by (output started at /home/horizonr/public_html/upload.processor.php:101) in /home/horizonr/public_html/upload.processor.php on line 102
Here is the PHP:

PHP Code:
<?php  
require("class.phpmailer.php");

$emp_name $_POST['name'];
$emp_phone $_POST['phone'];
$emp_email $_POST['email'];
$emp_pos $_POST['positions'];
$emp_geo $_POST['geographic'];
$emp_obj $_POST['objective'];

// filename: upload.processor.php

// first let's set some variables

// make a note of the current working directory, relative to root.
$directory_self str_replace(basename($_SERVER['PHP_SELF']), ''$_SERVER['PHP_SELF']);

// make a note of the directory that will recieve the uploaded files
$uploadsDirectory $_SERVER['DOCUMENT_ROOT'] . $directory_self 'upload/';

// make a note of the location of the upload form in case we need it
$uploadForm 'http://' $_SERVER['HTTP_HOST'] . $directory_self 'employment.php';

// make a note of the location of the success page
$uploadSuccess 'http://' $_SERVER['HTTP_HOST'] . $directory_self 'index.htm';

// name of the fieldname used for the file in the HTML form
$fieldname 'file';



// Now let's deal with the upload

// possible PHP upload errors
$errors = array(=> 'php.ini max file size exceeded'
                
=> 'html form max file size exceeded'
                
=> 'file upload was only partial'
                
=> 'no file was attached');

// check the upload form was actually submitted else print form
isset($_POST['submit'])
    or 
error('the upload form is neaded'$uploadForm);

// check for standard uploading errors
($_FILES[$fieldname]['error'] == 0)
    or 
error($errors[$_FILES[$fieldname]['error']], $uploadForm);
    
// check that the file we are working on really was an HTTP upload
@is_uploaded_file($_FILES[$fieldname]['tmp_name'])
    or 
error('not an HTTP upload'$uploadForm);
    
// validation... since this is an image upload script we 
// should run a check to make sure the upload is an image
//@getimagesize($_FILES[$fieldname]['tmp_name'])
//    or error('only image uploads are allowed', $uploadForm);
function test_file_type($filetype)
{
    if (
$filetype=="application/msword" || $filetype=="application/pdf"
    {
    }
    else
    {
        
error('not correct file type'$uploadForm);
    }
// end error handler
test_file_type($test_type $_FILES[$fieldname]["type"]);

// make a unique filename for the uploaded file and check it is 
// not taken... if it is keep trying until we find a vacant one
$now time();
while(
file_exists($uploadFilename $uploadsDirectory.$emp_name.'-'.$_FILES[$fieldname]['name']))
{
    
$now++;
}

// now let's move the file to its final and allocate it with the new filename
@move_uploaded_file($_FILES[$fieldname]['tmp_name'], $uploadFilename)
    or 
error('receiving directory insuffiecient permission'$uploadForm);

$mail = new PHPMailer();
$mail->From "resume@horizon.com";
$mail->AddAddress("matt@texasadvertising.net");
$mail->AddAddress("randy@horizonrvresorts.com");
$mail->AddAddress("tacoexec@swbell.net");
$mail->AddAttachment("$uploadFilename");
$mail->Subject "$name has Submitted a Resume";
$mail->IsHTML(true);
$mail->Body "Hi Randy<br><br>$emp_name has submitted a resume for employment.\n His information is as follows:<br><br>\n Name: $emp_name<br> Phone: $emp_phone<br> Email: $emp_email<br>
Position(s): 
$emp_pos<br> Geographic Preference: $emp_geo<br> Description of Objective: $emp_obj";
$mail->WordWrap 50;

if(!
$mail->Send())
{
   echo 
'Message was not sent.';
   echo 
'Mailer error: ' $mail->ErrorInfo;
}
else
{
        echo 
"<script language='text/javascript'>
        alert ('Thank You')
        </script>"
;
   
header('Location: ' $uploadSuccess); 
   
}    
    
// If you got this far, everything has worked and the file has been successfully saved.
// We are now going to redirect the client to the success page.


// make an error handler which will be used if the upload fails
function error($error$location$seconds 5)
{
    
header("Refresh: $seconds; URL=\"$location\"");
    echo 
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'."\n".
    
'"http://www.w3.org/TR/html4/strict.dtd">'."\n\n".
    
'<html lang="en">'."\n".
    
'    <head>'."\n".
    
'        <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">'."\n\n".
    
'        <link rel="stylesheet" type="text/css" href="stylesheet.css">'."\n\n".
    
'    <title>Upload error</title>'."\n\n".
    
'    </head>'."\n\n".
    
'    <body>'."\n\n".
    
'    <div id="Upload">'."\n\n".
    
'        <h1>Upload failure</h1>'."\n\n".
    
'        <p>An error has occured: '."\n\n".
    
'        <span class="red">' $error '...</span>'."\n\n".
    
'         The upload form is reloading</p>'."\n\n".
    
'     </div>'."\n\n".
    
'</html>';
    exit;
// end error handler
?>
Line 92-104:

PHP Code:
if(!$mail->Send())
{
   echo 
'Message was not sent.';
   echo 
'Mailer error: ' $mail->ErrorInfo;
}
else
{
        echo 
"<script language='text/javascript'>
        alert ('Thank You')
        </script>"
;
   
header('Location: ' $uploadSuccess); 
   

Line 102:

PHP Code:
header('Location: ' $uploadSuccess); 
I took this site over from a buddy, and am having the hardest time figuring out all of his code. Any help would be appricated
mattbtay is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-05-2008, 03:53 PM Re: Form Error - Help
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
This should help out: http://www.php.net/manual/en/function.header.php
__________________
DVD Movie Release Database:
Please login or register to view this content. Registration is FREE
Truly is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Form Error - Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10693 seconds with 12 queries