upload resumes to database

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
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

upload resumes to database

Post by monkeynme »

I need to create a page which allows job candidates to insert their info and upload a resume into a database from the web. Then it needs to notify HR by e-mail that a new resume has been added.

I created a dynamic form in Dreamweaver. But can't seem to figure out where to go from there. I've seen lots of different code on the web. But none of it seems to be exactly what I'm looking for since it doesn't look like Dreamweaver code. The more I search for code, the more confused I get about how to do this. So maybe someone could offer some suggestions on what code to use. I know a $_POST and INSERT INTO is needed somewhere. But with Dreamweaver assigning the variables on it's own, I'm not sure how much extra code is needed.

The PHP setup is:

Code: Select all

<?php require_once('Connections/EagleMain.php'); ?>
<?php
mysql_select_db($database_EagleMain, $EagleMain);
$query_submitResume = "SELECT * FROM candidates";
$submitResume = mysql_query($query_submitResume, $EagleMain) or die('<p>Error processing resumes from the database!<br> />'.
'Error: ' . mysql_error() . '</p>');
$row_submitResume = mysql_fetch_assoc($submitResume);
$totalRows_submitResume = mysql_num_rows($submitResume);
?>
And the form is like this:

Code: Select all

&lt;table&gt;
&lt;tr&gt;&lt;td&gt;&lt;form action="thankyou.htm" method="post" enctype="multipart/form-data" name="resumesubmit"&gt;
&lt;table&gt;
&lt;tr&gt;&lt;tdFirst Name:&lt;/td&gt;&lt;td&gt;&lt;input name="firstname" type="text" value="&lt;?php echo $row_submitResume&#1111;'candFirstName']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Last Name:&lt;/td&gt;&lt;td&gt;&lt;input name="lastname" type="text" value="&lt;?php echo $row_submitResume&#1111;'candLastName']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Address:&lt;/td&gt;&lt;td&gt;&lt;input name="address" type="text" value="&lt;?php echo $row_submitResume&#1111;'candAddress']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;City:&lt;/td&gt;&lt;td&gt;&lt;input name="city" type="text" value="&lt;?php echo $row_submitResume&#1111;'candCity']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;State:&lt;/td&gt;&lt;td&gt;&lt;input name="state" type="text" value="&lt;?php echo $row_submitResume&#1111;'candState']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Zip:&lt;/td&gt;&lt;td&gt;&lt;input name="zip" type="text" value="&lt;?php echo $row_submitResume&#1111;'candZip']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Phone:&lt;/td&gt;&lt;td&gt;&lt;input name="phone" type="text" value="&lt;?php echo $row_submitResume&#1111;'candPhone']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Fax:&lt;/td&gt;&lt;td&gt;&lt;input name="fax" type="text" value="&lt;?php echo $row_submitResume&#1111;'candFax']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;E-mail:&lt;/td&gt;&lt;td&gt;&lt;input name="email" type="text" value="&lt;?php echo $row_submitResume&#1111;'candEmail']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Paste cover letter here:&lt;/td&gt;&lt;td&gt;&lt;textarea name="coverletter" cols="25" rows="6"&gt;&lt;?php echo $row_submitResume&#1111;'coverLetter']; ?&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Upload resume (MS Word or ASCII format):&lt;/td&gt;&lt;td&gt;&lt;input name="file" type="file" value="&lt;?php echo $row_submitResume&#1111;'candResume']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Type of job you're looking for:&lt;/td&gt;&lt;td&gt;&lt;textarea name="jobtype"&gt;&lt;?php echo $row_submitResume&#1111;'jobType']; ?&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;Insert Job ID of job you're applying for:&lt;/td&gt;&lt;td&gt;&lt;input name="textfield" type="text" value="&lt;?php echo $row_submitResume&#1111;'jobID']; ?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" name="Submit" value="Submit Resume"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to break the project down into managable chunks and program it a bit at a time. Learning how to do it without Dreamweaver will also make your life easier in the long run as if it breaks you'll have the skill to fix it.

Tutorials:
http://www.php.net/tutorial
http://www.phpcomplete.com
http://www.devshed.com/Server_Side/PHP

Firstly you need the form that allows users to enter their details (ignore the resume uploading for now) once you're able to place that information into a database then you're a lot closer. Ensure that you have a field in the database (easiest is an auto-incrementing integer field) that is unique for each user so that you can easily work with the data for an inidividual.

Next learn how to manage a file upload, to do this start here:
http://www.php.net/manual/en/features.file-upload.php
Then you'll not want to store the whole file in the database but the name of this file - that way you can move all uploaded files to a single folder for ease of accessiblity. You could possibly name the file using the user's unique ID for ease of retrieval.

Finally you can add a short bit of code to the end to send the required e-mail(s).

Then you can go over the whole thing and add validation to the user's input and checks to ensure that duplicate information is not being added.

If you have problems with the code come back and ask about it.

HTH,
Mac
Post Reply