?
Solved

Trouble uploading Word Doc

Posted on 2012-03-26
14
Medium Priority
?
473 Views
Last Modified: 2012-03-27
It seems all of a sudden having trouble uploading word documents.

Getting this error: There were the following Errors:
This form only accepts Microsoft Word Documents as valid. The header of the uploaded file returned was: application/octet-stream. If you believe this to be in error please contact the webmaster with a copy of this error message.

It's when I try to submit any application on this page: http://www.keokukhealthsystems.org/joblist-apply.php?J=51

Ideas? Code attached
CodeJobApply.txt
0
Comment
Question by:edvinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
14 Comments
 
LVL 32

Expert Comment

by:DrDamnit
ID: 37768639
Do you have application/msword setup as a MIME type on the server? If the server doesn't recognize the type, it will assume it is data (application/octet-stream).
0
 
LVL 1

Author Comment

by:edvinson
ID: 37768759
Will, inquire of them tomorrow. thanks
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37768844
Try uploading to this script.  It recognizes Word by file extensions .doc and .docx and seems to work fine.  See line 125.
http://www.laprbass.com/RAY_temp_edvinson.php

HTH, ~Ray
<?php // RAY_temp_edvinson.php
error_reporting(E_ALL);


// MANUAL REFERENCE PAGES YOU MUST UNDERSTAND TO UPLOAD FILES
// http://php.net/manual/en/features.file-upload.php
// http://php.net/manual/en/features.file-upload.common-pitfalls.php
// http://php.net/manual/en/function.move-uploaded-file.php
// http://php.net/manual/en/reserved.variables.files.php

// MANUAL PAGES THAT ARE IMPORTANT IF YOU ARE DEALING WITH LARGE FILES
// http://php.net/manual/en/ini.core.php#ini.upload-max-filesize
// http://php.net/manual/en/ini.core.php#ini.post-max-size
// http://php.net/manual/en/info.configuration.php#ini.max-input-time


// PHP 5.1+  SEE http://php.net/manual/en/function.date-default-timezone-set.php
date_default_timezone_set('America/Chicago');

// ESTABLISH THE NAME OF THE 'uploads' DIRECTORY (MUST ALREADY EXIST)
$uploads = 'RAY_junk';

// ESTABLISH THE BIGGEST FILE SIZE WE CAN ACCEPT - ABOUT 8 MB
$max_file_size = '8000000';

// ESTABLISH THE MAXIMUM NUMBER OF FILES WE CAN UPLOAD
$nf = 1;

// ESTABLISH THE KINDS OF FILE EXTENSIONS WE CAN ACCEPT
$file_exts = array
( 'doc'
, 'docx'
)
;

// LIST OF THE ERRORS THAT MAY BE REPORTED IN $_FILES[]["error"] (THERE IS NO #5)
$errors = array
( 0 => "Success!"
, 1 => "The uploaded file exceeds the upload_max_filesize directive in php.ini"
, 2 => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"
, 3 => "The uploaded file was only partially uploaded"
, 4 => "No file was uploaded"
, 5 => "UNDEFINED ERROR"
, 6 => "Missing a temporary folder"
, 7 => "Cannot write file to disk"
)
;




// IF THERE IS NOTHING IN $_POST, PUT UP THE FORM FOR INPUT
if (empty($_POST))
{
    ?>
    <h2>Upload <?php echo $nf; ?> file(s)</h2>

    <!--
        SOME THINGS TO NOTE ABOUT THIS FORM...
        ENCTYPE IN THE HTML <FORM> STATEMENT
        MAX_FILE_SIZE MUST PRECEDE THE FILE INPUT FIELD
        INPUT NAME= IN TYPE=FILE DETERMINES THE NAME YOU FIND IN $_FILES ARRAY
        ABSENCE OF ACTION= ATTRIBUTE IN FORM TAG CAUSES POST TO SAME SCRIPT
    -->

    <form name="UploadForm" enctype="multipart/form-data" method="post">
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size; ?>" />
    <p>
    Find the file(s) you want to upload and click the "Upload" button below.
    </p>

    <?php // CREATE INPUT STATEMENTS FOR UP TO $n FILE NAMES
    for ($n = 0; $n < $nf; $n++)
    {
        echo "<input name=\"userfile$n\" type=\"file\" size=\"80\" /><br/>\n";
    }
    ?>

    <br/>Check this box <input autocomplete="off" type="checkbox" name="overwrite" /> to <strong>overwrite</strong> existing files.
    <input type="submit" value="Upload" />
    </form>
    <?php
    die();
}
// END OF THE FORM SCRIPT



// WE HAVE GOT SOMETHING IN $_POST - RUN THE ACTION SCRIPT
else
{
    // THERE IS POST DATA - PROCESS IT
    echo "<h2>Results: File Upload</h2>\n";

    // ACTIVATE THIS TO SEE WHAT IS COMING THROUGH
    echo "<pre>"; var_dump($_FILES); var_dump($_POST); echo "</pre>\n";

    // ITERATE OVER THE CONTENTS OF $_FILES
    foreach ($_FILES as $my_uploaded_file)
    {
        // SKIP OVER EMPTY SPOTS - NOTHING UPLOADED
        $error_code = $my_uploaded_file["error"];
        if ($error_code == 4) continue;

        // SYNTHESIZE THE NEW FILE NAME
        $f_type    = trim(strtolower(end    (explode( '.', basename($my_uploaded_file['name'] )))));
        $f_name    = trim(strtolower(current(explode( '.', basename($my_uploaded_file['name'] )))));
        $my_new_file
        = getcwd()
        . DIRECTORY_SEPARATOR
        . $uploads
        . DIRECTORY_SEPARATOR
        . $f_name
        . '.'
        . $f_type
        ;
        $my_file
        = $uploads
        . DIRECTORY_SEPARATOR
        . $f_name
        . '.'
        . $f_type;

        // OPTIONAL TEST FOR ALLOWABLE EXTENSIONS
        if (!in_array($f_type, $file_exts)) die("Sorry, $f_type files not allowed");

        // IF THERE ARE ERRORS
        if ($error_code != 0)
        {
            $error_message = $errors[$error_code];
            die("Sorry, Upload Error Code: $error_code: $error_message");
        }

        // GET THE FILE SIZE
        $file_size = number_format($my_uploaded_file["size"]);

        // IF THE FILE IS NEW (DOES NOT EXIST)
        if (!file_exists($my_new_file))
        {
            // IF THE MOVE FUNCTION WORKED CORRECTLY
            if (move_uploaded_file($my_uploaded_file['tmp_name'], $my_new_file))
            {
                $upload_success = 1;
            }
            // IF THE MOVE FUNCTION FAILED
            else
            {
                $upload_success = -1;
            }
        }

        // IF THE FILE ALREADY EXISTS
        else
        {
            echo "<br/><b><i>$my_file</i></b> already exists.\n";

            // SHOULD WE OVERWRITE THE FILE? IF NOT
            if (empty($_POST["overwrite"]))
            {
                $upload_success = 0;
            }
            // IF WE SHOULD OVERWRITE THE FILE, TRY TO MAKE A BACKUP
            else
            {
                $now    = date('Y-m-d');
                $my_bak = $my_new_file . '.' . $now . '.bak';
                if (!copy($my_new_file, $my_bak))
                {
                    echo "<br/><strong>Attempted Backup Failed!</strong>\n";
                }
                if (move_uploaded_file($my_uploaded_file['tmp_name'], $my_new_file))
                {
                    $upload_success = 2;
                }
                else
                {
                    $upload_success = -1;
                }
            }
        }

        // REPORT OUR SUCCESS OR FAILURE
        if ($upload_success == 2) { echo "<br/>It has been overwritten.\n"; }
        if ($upload_success == 1) { echo "<br/><strong>$my_file</strong> has been saved.\n"; }
        if ($upload_success == 0) { echo "<br/><strong>It was NOT overwritten.</strong>\n"; }
        if ($upload_success < 0)  { echo "<br/><strong>ERROR: $my_file NOT SAVED - SEE WARNING FROM move_uploaded_file() COMMAND</strong>\n"; }
        if ($upload_success > 0)
        {
            echo "$file_size bytes uploaded.\n";
            if (!chmod ($my_new_file, 0755))
            {
                echo "<br/>chmod(0755) FAILED: fileperms() = ";
                echo substr(sprintf('%o', fileperms($my_new_file)), -4);
            }
            echo "<br/><a target=\"_blank\" href=\"$my_file\">See the file $my_file</a>\n";
        }
    // END FOREACH ITERATOR - EACH ITERATION PROCESSES ONE FILE
    }
}

Open in new window

0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 1

Author Comment

by:edvinson
ID: 37771353
Ray, Where do I upload this to please? Does this replace my current page?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37771380
The script I posted above is just a teaching example, not a replacement for any application code.  Try uploading a Word document from your computer to my server using the URL I posted above.  The upload will dump out the contents of $_FILES so you can see what my server sees when you upload a file.  In your upload script, you might try using a similar strategy to print out the contents of $_FILES.

The way I determine that a file is a Word document is by looking at the file extension.  

You might also consider allowing clients to upload PDF files, too.  If they have a resume in PDF form it would probably make sense to accept that.  Just a thought... ~Ray
0
 
LVL 1

Author Comment

by:edvinson
ID: 37771477
Works good it appears.

Now I need someone to speak to me on how to put that into my page script please.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37771678
Are you a professional PHP programmer?  If not, you might want to have a consultant on retainer for things like this.  If you are professionally responsible for the script, please post the PHP script and I will try to suggest where you might put the changes.  Thanks, ~Ray
0
 
LVL 1

Author Comment

by:edvinson
ID: 37771801
I am a Dreamweaver WYSIWYG level and occasionally dig deeper. As you may know if you aren't in it all the time, things get forgotten and technology changes.
So, I keep paying my Experts bill each month so that I can get the answers.

So far, it's been a worthwhile investment.

Thank you for your time!

The page code is above under CodeJobApply.txt
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37771941
Got it.  Let me look at that script and see if I can figure it out.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37771952
Whoa!  You have some unrelated scary stuff in there.  Check the large red warning box about the ereg() functions.
http://us3.php.net/manual/en/function.ereg.php

I'll look at the other parts now.
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 37772027
See changes near the top and near line 67.
<?php // RAY_temp_edvinson.php

require_once('Connections/local.php'); 


// ESTABLISH THE KINDS OF FILE EXTENSIONS WE CAN ACCEPT
$file_exts = array
( 'pdf'       // NOT SURE IF YOU WANT THIS, BUT I MIGHT WANT TO KEEP IT?
, 'doc'       // FILE EXTENSION FOR OLDER WORD
, 'docx'      // FILE EXTENSION FOR NEWER WORD
)
;

function checkEmail($email) {
  // First, we check that there's one @ symbol, and that the lengths are right
  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
    // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
    return false;
  }
  // Split it into sections to make life easier
  $email_array = explode("@", $email);
  $local_array = explode(".", $email_array[0]);
  for ($i = 0; $i < sizeof($local_array); $i++) {
     if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
      return false;
    }
  }  
  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
    $domain_array = explode(".", $email_array[1]);
    if (sizeof($domain_array) < 2) {
        return false; // Not enough parts to domain
    }
    for ($i = 0; $i < sizeof($domain_array); $i++) {
      if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
        return false;
      }
    }
  }
  return true;
}

//Step 1, did they submit the form?
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
$errStr = NULL;
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
	if (empty($_POST['name'])){
		$errStr .= "You must provide your name.<BR>";
	}
	if (empty($_POST['city'])){
		$errStr .= "You must provide your city.<BR>";
	}
	if ($_POST['state'] == '---'){
		$errStr .= "You must select a state from the list.<BR>";
	}
	if (empty($_POST['email'])){
		$errStr .= "You must provide an email address.<BR>";
	}
	if ( !(empty($_POST['email'])) && (checkEmail(trim($_POST['email'])) == FALSE) ) 
	{
		$errStr .= "The email address you have provided is invalid, please try again.<BR>";
	}
	if($_FILES['resume']['error'] == 0){
	
		// THIS LINE REMOVED
		// if ($_FILES['resume']['type'] !== 'application/msword') {
		
		// THIS INSERTED
		$ext = end(explode('.', $_FILES['resume']['name']));
		if (!in_array($ext, $file_exts))
		{
			$errStr .= "This form only accepts Microsoft Word Documents as valid. The file extension <i>$ext</i> does not match the expected pattern. If you believe this to be in error please contact the webmaster at <a href=\"mailto:webmaster@pccon1.com\">webmaster@pccon1.com</a> with a copy of this error message.<BR>";
		}
	}
	if( ($_FILES['resume']['error'] !== 0) && ($_FILES['resume']['error'] !== 4) ){
		$errStr .= "There was a problem uploading your resume, please try again.<BR>";
	}
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") && (empty($errStr))) {
	$thePerson	= $_POST['name'];
	$theAddress	= $_POST['address'];
	$theCity	= $_POST['city'];
	$theState	= $_POST['state'];
	$thePhone	= $_POST['phone'];
	$theEmail	= $_POST['email'];
	$thePosit	= $_POST['position'];
	$newFile	= 'resume/'.$_FILES['resume']['name'];
	$theFile	= move_uploaded_file($_FILES['resume']['tmp_name'],$newFile); // move the file to the server so it can be emailed
	$theBody = "
	\tName: $thePerson\r
	\tAddress: $theAddress\r
	\tCity: $theCity\r
	\tState: $theState\r
	\tPhone: $thePhone\r
	";
	if($_FILES['resume']['error'] == 0){
		$theBody .= "\nThere is a resume attached with this application.";
	}
	// Klasse einbinden
	include("email/sendmail.class.php");

	// Neue Instanz der Klasse erstellen (Ab jetzt kann auf die Funktionen der Klasse zugegriffen werden)
	$mail = new sendmail();

	// Angeben des zu verwendenden CharSet´s
	$mail->SetCharSet("ISO-8859-1");

	// Angeben des Absenders und der Absenderemailadresse
	$mail->from($thePerson, $theEmail);

	// Angeben der Empfängeremailadresse
	$mail->to("rhonda@kah.kahnet.com");

	// Angeben des Cc Empfänger
/*	$mail->cc("webmaster@pccon1.com");
/*	$mail->cc("Email@Adresse.de");

	// Angeben dec Bcc Empfänger
	$mail->bcc("matt@pccon1.com");
/**/
	// Angeben des Betreff´s
	$mail->subject("Job Application for $thePosit from $thePerson");

	// Angeben des Textes (Auch HTML möglich)
	// Beim eingeben des HTML Textes bitte <HTML><BODY></BODY></HTML> weglassen,
	// da dies automatisch hinzugefügt wird
	$mail->text(nl2br($theBody));

	// Anegeben eines Attachment´s (sind auch mehrere möglich)
	$mail->attachment($newFile);
//	$mail->attachment("test2.zip");

	// Versenden der E-Mail
	$mail->send();
	
	unlink($newFile); // delete the file from the server after emailing it
	
	$insertGoTo = "email-success.php";
	header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php
$colname_theJob = "-1";
if (isset($_GET['J'])) {
  $colname_theJob = (get_magic_quotes_gpc()) ? $_GET['J'] : addslashes($_GET['J']);
}
mysql_select_db($database_local, $local);
$query_theJob = sprintf("SELECT jPosition FROM jobs WHERE jID = %s AND jActive = 1", $colname_theJob);
$theJob = mysql_query($query_theJob, $local) or die(mysql_error());
$row_theJob = mysql_fetch_assoc($theJob);
$totalRows_theJob = mysql_num_rows($theJob);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>http://www.keokukhealthsystems.org/</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
		<link rel="stylesheet" href="styles/default.css" type="text/css" />

	    <style type="text/css">
<!--
		#errorbox{
	color: #CC3333;
	background-color: #FFFFFF;
	border: 1px dashed #000000;
	padding: 2px;
	margin: 2px;
}
-->
        </style>
	</head>
	<body>
		<div id="topOfPage">
			<a name="topOfPage">&nbsp;</a>
		</div><?php
// Note that !== did not exist until 4.0.0-RC2
$thePath = 'images/top/general/';
$backgrounds = array();
if ($handle = opendir($thePath)) {
	/* This is the correct way to loop over the directory. */
	while (false !== ($file = readdir($handle))) {   		if(!($file == '.') && !($file == '..') && !($file == 'Thumbs.db')){ $backgrounds[] = $thePath.$file;
		}
	}
	closedir($handle);
}
$theMax = count($backgrounds);
$i = rand(0, $theMax-1);
?> 
	<div id="conteiner">
<?php include('./include/headtable.php'); ?>
            <table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding:0; margin:0;">
              <tr style="padding:0; margin:0;">
                <td height="200" class="word_box" style="padding:0; margin:0;"><div id="word_float">
                    <h1>Apply for Position <span class="highlight"><?php echo $row_theJob['jPosition']; ?></span> </h1>
                </div></td>
                <td width="330" height="200" align="right" valign="middle" background="<?php echo $backgrounds[$i]; ?>" style="padding:0; margin:0;">&nbsp;</td>
              </tr>
            </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="80%" align="left" valign="top" id="body">
<?php if ($totalRows_theJob > 0) { // Show if recordset not empty
		$row_color = ( !($_GET['J'] % 2) ) ? "block" : "blockDistinct";
							?>
	    
        <div class="<?php echo $row_color; ?>">
	        <h2><a name="<?php echo $row_jobs['jID']; ?>" id="<?php echo $row_jobs['jID']; ?>">Please Fill Out the Form Below with all the Required Information </a></h2>
		<?php if (isset($errStr)) { ?>
		<div id="errorbox"><span class="style6"><strong>There were the following Errors:</strong><br>
		</span><span class="style47"><?php echo $errStr; ?></span></div>
		<?php } ?>
	        <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" id="form1">
      <table width="100%" border="0" cellpadding="4" cellspacing="2" class="">
		      <tr>
                <td width="30%" align="right" valign="top"><strong>Your Name </strong></td>
		        <td width="250" valign="top"><input name="name" type="text" id="name" size="36" /></td>
	          </tr>
              <tr>
                <td width="30%" align="right" valign="top"><strong>Address</strong></td>
                <td valign="top"><input name="address" type="text" id="address" size="36" /></td>
              </tr>
              <tr>
                <td width="30%" align="right" valign="top"><strong>City</strong></td>
                <td valign="top"><input name="city" type="text" id="city" size="36" /></td>
              </tr>
              <tr>
                <td width="30%" align="right" valign="top"><strong>State</strong></td>
                <td valign="top"><select name="state">
                  <option value="---" selected="selected">Choose a State</option>
                  <option value="UNK">Outside US / Canada</option>
                  <option value="AL">Alabama</option>
                  <option value="AK">Alaska</option>
                  <option value="AB">Alberta</option>
                  <option value="AS">American Samoa</option>
                  <option value="AZ">Arizona</option>
                  <option value="AR">Arkansas</option>
                  <option value="AA">Armed Forces Americas</option>
                  <option value="AE">Armed Forces Europe</option>
                  <option value="AP">Armed Forces Pacific</option>
                  <option value="BC">British Columbia</option>
                  <option value="CA">California</option>
                  <option value="CO">Colorado</option>
                  <option value="CT">Connecticut</option>
                  <option value="DE">Delaware</option>
                  <option value="DC">District Of Columbia</option>
                  <option value="FL">Florida</option>
                  <option value="GA">Georgia</option>
                  <option value="GU">Guam</option>
                  <option value="HI">Hawaii</option>
                  <option value="ID">Idaho</option>
                  <option value="IL">Illinois</option>
                  <option value="IN">Indiana</option>
                  <option value="IA">Iowa</option>
                  <option value="KS">Kansas</option>
                  <option value="KY">Kentucky</option>
                  <option value="LA">Louisiana</option>
                  <option value="ME">Maine</option>
                  <option value="MB">Manitoba</option>
                  <option value="MD">Maryland</option>
                  <option value="MA">Massachusetts</option>
                  <option value="MI">Michigan</option>
                  <option value="MN">Minnesota</option>
                  <option value="MS">Mississippi</option>
                  <option value="MO">Missouri</option>
                  <option value="MT">Montana</option>
                  <option value="NE">Nebraska</option>
                  <option value="NV">Nevada</option>
                  <option value="NB">New Brunswick</option>
                  <option value="NH">New Hampshire</option>
                  <option value="NJ">New Jersey</option>
                  <option value="NM">New Mexico</option>
                  <option value="NY">New York</option>
                  <option value="NF">Newfoundland</option>
                  <option value="NC">North Carolina</option>
                  <option value="ND">North Dakota</option>
                  <option value="MP">Northern Mariana Is</option>
                  <option value="NT">Northwest Territories</option>
                  <option value="NS">Nova Scotia</option>
                  <option value="OH">Ohio</option>
                  <option value="OK">Oklahoma</option>
                  <option value="ON">Ontario</option>
                  <option value="OR">Oregon</option>
                  <option value="PW">Palau</option>
                  <option value="PA">Pennsylvania</option>
                  <option value="PE">Prince Edward Island</option>
                  <option value="PQ">Province du Quebec</option>
                  <option value="PR">Puerto Rico</option>
                  <option value="RI">Rhode Island</option>
                  <option value="SK">Saskatchewan</option>
                  <option value="SC">South Carolina</option>
                  <option value="SD">South Dakota</option>
                  <option value="TN">Tennessee</option>
                  <option value="TX">Texas</option>
                  <option value="UT">Utah</option>
                  <option value="VT">Vermont</option>
                  <option value="VI">Virgin Islands</option>
                  <option value="VA">Virginia</option>
                  <option value="WA">Washington</option>
                  <option value="WV">West Virginia</option>
                  <option value="WI">Wisconsin</option>
                  <option value="WY">Wyoming</option>
                  <option value="YT">Yukon Territory</option>
                </select></td>
              </tr>
		      <tr>
		        <td width="30%" align="right" valign="top"><strong>Phone</strong></td>
                <td valign="top"><input name="phone" type="text" id="phone" size="36" /></td>
              </tr>
		      <tr>
		        <td width="30%" align="right" valign="top"><strong>Email</strong></td>
                <td valign="top"><input name="email" type="text" id="email" size="36" /></td>
              </tr>
		      <tr>
		        <td align="right" valign="top"><strong>Resume</strong></td>
		        <td valign="top"><input name="resume" type="file" id="resume" />
		          <br />
	            Optional. Please only submit resumes in Microsoft Word Document format. 
	            <input name="MM_insert" type="hidden" id="MM_insert" value="form1" />
	            <input name="position" type="hidden" id="position" value="<?php echo $row_theJob['jPosition']; ?>" /></td>
	          </tr>
		      <tr>
		        <td align="right" valign="top">&nbsp;</td>
                <td valign="top"><input type="submit" name="Submit" value="Submit your Application" /></td>
              </tr>
	        </table>
          </form>
        </div>
	    <?php
		} else { ?>
		<div class="blockDistinct">
		<h2>We're Sorry</h2>
		<p>There are no jobs listed matching those criteria . <span class="body"><a href="javascript:history.back()">Click here</a> or use your browser's &quot;Back&quot; button to try again. </span>		</p>
		</div>
		<?php } ?>
	  </td>
    <td align="left" valign="top" id="menu">
			  <?php include('./include/kahmenu.php'); ?></td>
  </tr>
</table>
<?php include('./include/footer.php'); ?>
	</div>
</body>
</html>
<?php
mysql_free_result($theJob);
?>

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37772044
Bonus, as appreciation for using EE.  Try changing your email validation to something like the function shown in this example.  It will be a bit more future-proof.
<?php // RAY_email_validation.php
error_reporting(E_ALL);


// A FUNCTION TO TEST FOR A VALID EMAIL ADDRESS, RETURN TRUE OR FALSE
// SEE MAN PAGE: http://php.net/manual/en/intro.filter.php
function check_valid_email($email, $rout=TRUE)
{
    // LIST OF BLOCKED DOMAINS
    $bogus = array
    ( '@unknown.com'
    , '@example.com'
    , '@gooseball.org'
    )
    ;

    // IF PHP 5.2 OR ABOVE, WE CAN USE THE FILTER
    if (strnatcmp(phpversion(),'5.2') >= 0)
    {
        if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE) return FALSE;
    }

    // IF LOWER-LEVEL PHP, WE CAN CONSTRUCT A REGULAR EXPRESSION
    else
    {
        $regex
        = '/'                        // START REGEX DELIMITER
        . '^'                        // START STRING
        . '[A-Z0-9_-]'               // AN EMAIL - SOME CHARACTER(S)
        . '[A-Z0-9._-]*'             // AN EMAIL - SOME CHARACTER(S) PERMITS DOT
        . '@'                        // A SINGLE AT-SIGN
        . '([A-Z0-9][A-Z0-9-]*\.)+'  // A DOMAIN NAME PERMITS DOT, ENDS DOT
        . '[A-Z\.]'                  // A TOP-LEVEL DOMAIN PERMITS DOT
        . '{2,6}'                    // TLD LENGTH >= 2 AND =< 6
        . '$'                        // ENDOF STRING
        . '/'                        // ENDOF REGEX DELIMITER
        . 'i'                        // CASE INSENSITIVE
        ;
        // TEST THE STRING FORMAT
        if (!preg_match($regex, $email)) return FALSE;
    }

    // TEST TO SEE IF THE DOMAIN IS IN OUR BLOCKED LIST
    foreach ($bogus as $badguy)
    {
        if (stripos($email, $badguy)) return FALSE;
    }

    // FILTER_VAR OR PREG_MATCH DOES NOT TEST IF THE DOMAIN IS ROUTABLE
    if ($rout)
    {
        $domain = explode('@', $email);

        // MAN PAGE: http://php.net/manual/en/function.checkdnsrr.php
        if ( checkdnsrr($domain[1], "MX") || checkdnsrr($domain[1], "A") ) return TRUE;

        // EMAIL IS NOT ROUTABLE
        return FALSE;
    }
    return TRUE;
}



// DEMONSTRATE THE FUNCTION IN ACTION
$e = NULL;
if (!empty($_GET["e"]))
{
    $e = $_GET["e"];
    if (check_valid_email($e))
    {
        echo "<br/>VALID: $e \n";
    }
    else
    {
        echo "<br/>BOGUS: $e \n";
    }
}


// END OF PROCESSING - CREATE THE FORM USING HEREDOC NOTATION
$form = <<<ENDFORM
<form>
TEST A STRING FOR A VALID EMAIL ADDRESS:
<input name="e" value="$e" />
<input type="submit" />
</form>
ENDFORM;

echo $form;

Open in new window

Best regards, ~Ray
0
 
LVL 1

Author Closing Comment

by:edvinson
ID: 37772465
Works Great!!!!! Thank you and thanks for the extra effort. If I could award a thousand or more I would!!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37772475
Thanks for the points - I with I could test these things, but sometimes I just get lucky ;-)

All the best, ~Ray
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will learn how to dynamically set the form action using jQuery.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question