Jump to content

File Submission, E-mail Notification Script Integration


mcatalf0221

Recommended Posts

I have a script to upload single files to a mySQL database.  Files are assigned consecutive ID numbers, able to be accessed through a respective URL.  The use for this script is a page on my website with five links, each of which opens up a file submission window (where one selects which file to submit, hits submit, and the file is added to the database, assigned the next ID number).

 

In addition to the file submission script, I have on a page previous to the file submission one a web form connected to a PHP script that submit results to me via e-mail.  My goal is to have the five file URLs (meaning the appropriate IDs based on this "session's" submission) sent out in the same e-mail as my form data.

 

Below are the scripts which I currently have.  I am not sure how to go about integrating their two different functions in order to have sent to me a single e-mail with all the form data and file URLs.

 

Form Data Submission PHP - brings you to the file submission page when complete

<?
session_save_path(http://cindtronix.com/cgi-bin/tmp); 
session_start(); 
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='')  { 
     echo  '<strong>Incorrect verification code. Go back and try again. </strong><br>'; 
} else { 
$name=$_POST['name'];
$street_address=$_POST['street_address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$email=$_POST['email'];
$home_phone=$_POST['home_phone'];
$cell_phone=$_POST['cell_phone'];
$additional_contact=$_POST['additional_contact'];
$dob=$_POST['dob'];
$parent=$_POST['parent'];
$parent_phone=$_POST['parent_phone'];
$emerg_name=$_POST['emerg_name'];
$emerg_prim_phone=$_POST['emerg_prim_phone'];
$emerg_street_address=$_POST['emerg_street_address'];
$emerg_city=$_POST['emerg_city'];
$emerg_state=$_POST['emerg_state'];
$emerg_zip=$_POST['emerg_zip'];
$emerg_additional=$_POST['emerg_additional'];
$course=$_POST['course'];
$waiver=$_POST['waiver'];
$suspension=$_POST['suspension'];
$accident=$_POST['accident'];
$insurance=$_POST['insurance'];
$guilty=$_POST['guilty'];
$drivers=$_POST['drivers'];
$drugs=$_POST['drugs'];
$felony=$_POST['felony'];
$certified=$_POST['certified'];
$to="EMAILREMOVED";
$message="This is an automated Cindtronix Student Application Submission.
	------PERSONAL DATA-----
	A. NAME 				$name
	B. ADDRESS				$street_address
	C. CITY					$city
	D. STATE				$state
	E. ZIP					$zip
	F. E-MAIL				$email
	G. HOME PHONE			$home_phone
	H. CELL PHONE			$cell_phone
	I. ADDITIONAL CONTACT	$additional_contact
	J. DOB					$dob
	-----PARENTS/EMERGENCY CONTACTS-----
	K. PARENT NAME			$parent
	L. PARENT PHONE			$parent_phone
	M. EMERG NAME			$emerg_name
	N. EMERG PHONE			$emerg_prim_phone
	O. EMERG ADDRESS		$emerg_street_address
	P. EMERG CITY			$emerg_city
	Q. EMERG STATE			$emerg_state
	R. EMERG ZIP			$emerg_zip
	S. EMERG ADDITIONAL		$emerg_additional
	-----COURSE INFORMATION-----
	T. COURSE SELECTION		$course
	U. OTHER INFO			$other
	V. WAIVER ($waiver) SUSPENSION($suspension) ACCIDENT($accident) INSURANCE($insurance) GUILTY($guilty) DRIVERS($drivers) DRUGS($drugs) FELONY($felony)
	----------------------------
	*** CONFIRMATION of ACCURACY:  	  $certified

	FILE SUBMISSIONS
		1) COVER LETTER				http://www.cindtronix.com/getpicture.php?fid=0
		2) EDUCATIONAL TRANSCRIPTS	http://www.cindtronix.com/getpicture.php?fid=1
		3) PHOTO(S)					http://www.cindtronix.com/getpicture.php?fid=2
		4) PASSPORT					http://www.cindtronix.com/getpicture.php?fid=3
		5) FINANCIAL SUPPORT		http://www.cindtronix.com/getpicture.php?fid=4
		6) OPTIONAL SUPPLEMENTS 	http://www.cindtronix.com/getpicture.php?fid=5

	*** IMPORTANT *** After files have been successfully downloaded, please use the following links to delete them from the database!

		http://www.cindtronix.com/remove.php?fid=0
		http://www.cindtronix.com/remove.php?fid=1
		http://www.cindtronix.com/remove.php?fid=2
		http://www.cindtronix.com/remove.php?fid=3
		http://www.cindtronix.com/remove.php?fid=4
		http://www.cindtronix.com/remove.php?fid=5

	--- END OF APPLICATION ---";
if(mail($to,"CINDTRONIX ELECTRONIC STUDENT APPLICATION SUBMISSION",$message,"From:$email\n")){
echo("
<html>

<head>
	<title>Cindtronix Aviation - Online Student Application Document Submission</title>

	<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">
	<link rel=\"stylesheet\" type=\"text/css\" href=\"spiffy.css\">
	<link rel=\"stylesheet\" type=\"text/css\" href=\"menu.css\">

	<script type=\"text/javascript\" src=\"js/animatedcollapse.js\"></script>
	<script type=\"text/javascript\" src=\"js/slide1.js\"></script>
	<script type=\"text/javascript\" src=\"drop_down.js\"></script>

	<SCRIPT LANGUAGE=\"JavaScript\">
	<!-- Begin
	function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval(\"page\" + id + \" = window.open(URL, '\" + id + \"', 'toolbar=0,scrollbars=0,loc		ation=0,statusbar=0,menubar=0,resizable=0,width=500,height=500');\");
	}
	// End -->
	</script>


</head>
<body>

<div id=\"logo\">
<img src=\"logo.jpg\" width=\"898\">
</div>

<table class=\"table_middle\" cellspacing=\"0\" cellpadding=\"0\">
<tr>

	<td width=\"153\" bgcolor=\"#9E9E9E\" valign=\"top\">
		<!--Filler-->
	</td>

	<td bgcolor=\"#9E9E9E\" width=\"40\">
		<!--Filler-->
	</td>

	<td class=\"login\" width=\"728\" bgcolor=\"#9E9E9E\">
		<p align=\"right\">
			<a href=\"http://s08.myfbo.com/link.asp?fbo=cina\"><font color=\"#000000\">Student Login</font></a>&nbsp
		</p>
	</td>

</tr>
</table>

<div id=\"container\"><div id=\"menu\">
<ul id=\"nav\"> 
  <li><a href=\"index.php\">Home</a></li> 
  <li><a href=\"news.html\">What's New?</a></li> 
  <li><a href=\"discover.html\">Discover Flying!</a></li> 
  <li><a href=\"flight_training.html\">Flight Training</a> 
    <ul> 
      <li><a href=\"discover.html\">Discovery Flights</a></li> 
      <li><a href=\"cpc.html\">Why Cindtronix?</a></li> 
      <li><a href=\"cbi.html\">Computer Based Instruction (CBI)</a></li> 
  <li><a href=\"ppl.html\">Private Pilot License</a></li> 
      <li><a href=\"advanced.html\">Advanced Ratings</a></li>	 
      <li><a href=\"accir.html\">12 Day Instrument Rating Course</a></li>  
      <li><a href=\"faq.html\">Frequently Asked Questions</a></li> 
      <li><a href=\"financing.html\">Financing Options</a></li>  
    </ul> 
  </li> 
  <li><a href=\"fleet.html\">Aircraft</a> 
    <ul> 
      <li><a href=\"fleet.html\">The Cindtronix Fleet</a></li> 
      <li><a href=\"g1000.html\">G1000 Equipped</a></li> 
      <li><a href=\"http://skyhawksp.cessna.com/\">Cessna Skyhawk (C172)</a></li> 
      <li><a href=\"http://skylane.cessna.com/\">Cessna Skylane (C182)</a></li> 
      <li><a href=\"http://www.cessnaskycatcher.com/\">Cessna Skycatcher (C162)</a></li> 
      <li><a href=\"http://www.newpiper.com/aircraft/arrow/\">Piper Arrow (PA-28RR)</a></li> 
      <li><a href=\"http://www.newpiper.com/aircraft/seminole/\">Piper Seminole (PA-44)</a></li> 
    </ul> 
  </li> 
  <li><a href=\"services.html\">Other Services</a></li> 
  <li><a href=\"team.html\">Our Team</a></li>
  <li><a href=\"oqu.html\">Quonset Airport</a></li> 
  <li><a href=\"rentals.html\">Aircraft Rentals</a></li>
  <li><a href=\"degree.html\">Degree Program</a></li> 
  <li><a href=\"pilots.php\">Online Pilot Center</a></li> 
  <li><a href=\"shop.html\">Pilot Shop</a></li> 
  <li><a href=\"giftcert.html\">Gift Certificates</a></li> 
  <li><a href=\"http://s08.myfbo.com/link.asp?fbo=cina\">Online Scheduling</a></li> 
  <li><a href=\"contact.html\">Contact Us</a></li> 
</ul> 
</div>



<div id=\"address\">
<center><font size=\"1\">
210 Airport Street<br>
N. Kingstown, RI 02852<br>
<b>(401) 667-7580<br>
   (401) 644-6610</b>
</font>
</center>
</div>


<div id=\"table_main_subpage\">

<h1>Online Student Application</h1>

<h2 class=\"discover\">Part II - Document Submission</h2> 		

<div id=\"text\">

Please upload each of the following documents in .DOC, .TXT, .PDF, or .JPG format.  If you are unable to scan/submit the required documents, please call to notify us and mail them to the following address:  <i>210 Airport Street, North Kingstown, RI 02852</i>

<table class=\"table_text\">
	<tr>
		<td>A cover letter explaining why you want to become a pilot:</td>
		<td>
			<a href=\"javascript:popUp('upload.html')\">Upload</a><br>
		</td>
	</tr>
	<tr>
		<td>Scans of your educational transcripts:</td>
		<td>
			<a href=\"javascript:popUp('upload.html')\">Upload</a><br>
		</td>
	</tr>
	<tr>
		<td>Color photo of yourself:</td>
		<td>
			<a href=\"javascript:popUp('upload.html')\">Upload</a><br>
		</td>
	</tr>
	<tr>
		<td>Relevant pages of your passport:</td>
		<td>
			<a href=\"javascript:popUp('upload.html')\">Upload</a><br>
		</td>
	</tr>
	<tr>
		<td>Evidence of your financial support:</td>
		<td>
			<a href=\"javascript:popUp('upload.html')\">Upload</a><br>
		</td>
	</tr>
	<tr>
		<td>Supplementary material (optional):</td>
		<td>
			<a href=\"javascript:popUp('upload.html')\">Upload</a><br>
		</td>
	</tr>
</table>
</div>

<div id=\"text\">Once you have finished uploading all files, you may exit this page.  We will begin reviewing your application immediately and we will be in contact with you soon!</div>

<div id=\"copyright1\">
<center>
<b>&#169 2008 - Cindtronix Aviation</b><br>
210 Airport Street  &#124; N. Kingstown, RI 02852 &#124; (401) 667-7580
</center>
</div>


</div>




<script src=\"http://www.google-analytics.com/urchin.js\" type=\"text/javascript\">
</script>
<script type=\"text/javascript\">
_uacct = \"UA-3281044-1\";
urchinTracker();
</script>





</div></body>
</html>

");
}else{
echo "There was a problem sending the form. Please go back to check that you filled it in completely and correctly.";
}

    }; 
?>

 

File Upload Script

 

<?php 
// if something was posted, start the process... 
if(isset($_POST['upload'])) 
{ 

// define the posted file into variables 
$name = $_FILES['picture']['name']; 
$tmp_name = $_FILES['picture']['tmp_name']; 
$type = $_FILES['picture']['type']; 
$size = $_FILES['picture']['size']; 

// get the width & height of the file (we don't need the other stuff) 
list($width, $height, $typeb, $attr) = getimagesize($tmp_name); 
    
// if the mime type is anything other than what we specify below, kill it     
if(!( 
$type=='application/pdf' || 
$type=='text/plain' ||
$type=='application/msword' || 
$type=='image/jpeg' || 
$type=='image/png' || 
$type=='image/gif' 
)) { 
echo $type .  " is not an acceptable format."; 
echo ?> <a href="form.html">Click here</a> to try again. <? ; 
die(); 
} 

// if the file size is larger than 350 KB, kill it 
if($size>'350000') { 
echo $name . " is over 350KB. Please make it smaller."; 
echo ?> <a href="form.html">Click here</a> to try again. <? ; 
die(); 
}

// if your server has magic quotes turned off, add slashes manually 
if(!get_magic_quotes_gpc()){ 
$name = addslashes($name); 
} 

// open up the file and extract the data/content from it 
$extract = fopen($tmp_name, 'r'); 
$content = fread($extract, $size); 
$content = addslashes($content); 
fclose($extract);  

// connect to the database 
include "connect.php"; 

// the query that will add this to the database 
$addfile = "INSERT INTO files (name, size, type, content ) ". 
           "VALUES ('$name', '$size', '$type', '$content')"; 

mysql_query($addfile) or die(mysql_error()); 

// get the last inserted ID if we're going to display this image next 
$inserted_fid = mysql_insert_id(); 

mysql_close();  

echo "Successfully uploaded your file!"; 
  
// we still have to close the original IF statement. If there was nothing posted, kill the page. 
}else{die("No uploaded file present"); 
} 
?>  

 

Picture Retrieval PHP

<? 
if(isset($_GET['fid'])) 
{ 
// connect to the database 
include "connect.php"; 

// query the server for the picture 
$fid = $_GET['fid']; 
$query = "SELECT * FROM files WHERE fid = '$fid'"; 
$result  = mysql_query($query) or die(mysql_error()); 

// define results into variables 
$name=mysql_result($result,0,"name"); 
$size=mysql_result($result,0,"size"); 
$type=mysql_result($result,0,"type"); 
$content=mysql_result($result,0,"content"); 

// give our picture the proper headers...otherwise our page will be confused 
header("Content-Disposition: attachment; filename=$name"); 
header("Content-length: $size"); 
header("Content-type: $type"); 
echo $content; 

mysql_close(); 
}else{ 
die("No file ID given..."); 
} 

?>

 

 

If it sounds like I'm going about this in the wrong way, please let me know.  It's simply my intent to create a type of "application" form that allows for submission of scanned documents, and notifies the company of a new submission and allows for a way to access the data.

 

Thank you! 

- mcatalf0221

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.