Page 1 of 1

Adding PHP script to a save button for a Job Posting site.

Posted: Tue Feb 07, 2012 3:21 pm
by netprojecter
I have a question or rather yet I need help with a code snippet for a job posting

website that I am working on. I need to add a scipt to a save button that will gather

the job post id ($post_id) and submit the applicant info to the job/($post_id) so that the applicant has apply for the position.

Now I'm not a php expert more like a beginner but, here is the code to the page a need the functionality add.

Code: Select all

<?php
/*
	Resume form: form_id = 2

	Here you can modify the resume form.
	This file is a file php mixed with PHP.
	The php code is located between  < ?php and ? > tags.
	Anything outside these tags is HTML code and can be modified as normal HTML

	The form has 3 modes possible: 'view', 'edit' and 'EDIT'
	
	view - for displaying data, the data that is stored in these fields is displayed, instead
	of the form field

	edit - the form is displayed for editing the data by the users

	EDIT - the form is displayed for editing the fileds by the Admin

	How to display data from the individual fields?

	- Each Field has a 'Template Tag' which is specified when editing the form.
	Use the JB_get_template_value($template_tag, $form_id) function to get the data from the field.
	For example, this will display the email of the resume:

	echo JB_get_template_value('EMAIL', 2); 

	The resume form has 3 sections by default.
	To display a section, a call to the JB_display_form() function is made. For example, to
	print a section 1 section like this:
	JB_display_form (2, $mode, $prams, 1, $admin);

	How to make all resumes anonymous

	Replace this checkbox

	<input type="checkbox" value="Y" name="anon" ?php if($prams['anon']=='Y') { echo ' checked ';} ? >

	With:

	<input type="hidden" value="Y" name="anon"  >
	
	*/
	
	// load the javascript for the SCW Date selector field (if one exists on the form)
	if (!defined('SCW_INCLUDE')) {
		?>
		<script type='text/JavaScript' src='<?php echo JB_BASE_HTTP_PATH."scw/scw_js.php?lang=".$_SESSION['LANG']; ?>'></script>
		<?php
		define ('SCW_INCLUDE', 'Y');
	}

	if ($mode != 'view') { // editing mode, output the start of the <form> and hidden fields

		?>		
		<form method="POST" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" name="form1" onsubmit=" form1.savebutton.disabled=true;" enctype="multipart/form-data">
		<input type="hidden" name="mode" size="" value="<?php echo $mode; ?>">
		<input type="hidden" name="resume_id" size="" value="<?php echo $prams['resume_id']; ?>">
		<input type="hidden" name="user_id" size="" value="<?php echo $prams['user_id']; ?>">
		<?php
	}

	// begin the Resume Form
	?>
	
<?php /* NASTHON */
		if ($mode == "view") {		
		$BTN_PRINTPRE = '<a class="iconbutton"  title="' . $label['nasthon1007_button_print'] . '" href="javascript:printpreview();">' . '<span style="display:inline;"><img src="'.JB_THEME_URL. 'images/icon/printer.gif" style="vertical-align:middle;" border="0">' . ' ' . $label['nasthon1007_button_print'] . '</span></a>';
		echo '<div class="printbtn" style="margin-top:10px;">' . $BTN_PRINTPRE . '</div>';
	}
?>

	<table border="0" cellSpacing="1" cellPadding="5" class="resume_data" >
	<tr><td colspan="2" >
	<?php 
	
	// checkbox for job seeker when editing the resume
	if (($mode!='view') && (JB_RESUME_REQUEST_SWITCH!='NO') ) {
		
		?>
		<input type="checkbox" value="Y" name="anon" <?php if($prams['anon']=='Y') { echo ' checked ';} ?> > <?php echo $label["resume_priv_notice"]; ?>
		<?php
	}

	
?>
	</td></tr>
	<?php  
	// check for error, and display an error message is there is an error when saving
	if (($error != '' ) && ($mode!='EDIT')) { ?>
	<tr>
		<td colspan="2"><?php  echo "<span class='error_msg_label'>".$label["resume_save_error"]."</span><br> ".$error."";  ?></td>
	</tr>
	<?php } ?>
  <tr>
    <td  valign="top" >
	<?php 
		 if ($mode == "EDIT") { 
					echo "[Section 1]";
		}
		// JB_display_form function will display the form from the database
		JB_display_form (2, $mode, $prams, 1, $admin);
	?>

    </td>

	<?php
	// check if there are any fields in section 2
	$sql = "SELECT * FROM form_fields WHERE form_id=2 AND section=2 ";
	$result = JB_mysql_query ($sql);
	if (mysql_num_rows($result)>0) {
		// display section 2
	
	?>
    <td valign="top"  rowspan="2">
    <?php 
		if ($mode == "EDIT") {
			echo "[Section 2]";
		}
		JB_display_form (2, $mode, $prams, 2, $admin);
	?></td>

	<?php } ?>
  </tr>

  <tr>
    <td>
		<?php 
		if ($mode == "EDIT") {
			echo "[Section 3]";
		}
		// display section 3
		JB_display_form (2, $mode,  $prams, 3, $admin);
		?></td>
  </tr>
  <?php 
  // save button (if in edit mode)
	if ($mode=='edit') { ?>
 		<tr><td colspan="2" bgcolor="#ffffff">
		<input type="hidden" name="save" id="save101" value="">
		<input class="form_submit_button" TYPE="SUBMIT"  name="savebutton" value="<?php echo $label['resume_save_button']; ?>" onClick="save101.value='1';">
		</td></tr>
		<?php } ?>		
	</table>
	<?php if ($mode != 'view') { ?>
	</form>
	<?php } ?>
	
	<?php /* NASTHON */		
		if ($mode == "view") {echo '<div class="printbtn">' . $BTN_PRINTPRE . '</div>'; }
	?>
would appreciate whatever help someone is will to give.

Re: Adding PHP script to a save button for a Job Posting sit

Posted: Wed Feb 08, 2012 3:29 am
by artofwork
I'm not 100% sure what your trying to do, If your trying to read the data when you submit the form?

I wrote a class which deals with arrays, its nothing special its for testing purposes and will allow you to see the elements and their values when you click the submit button.

Code: Select all

<?php
/*
    This class will check not only the elements of 
    an array but also if those elements contain key values.
  
	
	Create a new object
	$objPost = new POST($_POST); 
	or  
	$objPost = new POST();
	$objPost->checkPost($_POST);
	
	Just comment the echo statements to supress the output
	Change the $omit value to whatever value you want to exclude

*/
class POST 
{
	var $result = array();
	var $key;
	var $value = array();
	var $post = array();
	var $omit = 'Submit';
	
	function __construct($post=false)
	{
		if($post)
		{
			$this->post = $post;
			$this->checkPost($this->post);
		}
	}
	function checkPost($post)
	{
		foreach($post as $this->key => $this->value)
		{
			$this->result[$this->key] = $this->value;
				if(!empty($this->result[$this->key]) && ($this->result[$this->key] != $this->omit))
				{
					echo "Element: [".$this->key."] Key: [".$this->result[$this->key]."] <br />";
				}
				else				
					echo "Element: [".$this->key."] Empty Key: [".$this->result[$this->key]."] <br />";
				
		}
		return $this->result[$this->key];
	}
}
?>

Re: Adding PHP script to a save button for a Job Posting sit

Posted: Wed Feb 08, 2012 2:53 pm
by netprojecter
Upon clicking the submit button I would like the user/applicant to be able to apply for the job that they have viewed. To go into a little more detail this is part of an email

campaign. A 'potential user'(isn't a user yet) receives a email from the job site expressing to the 'pu' that this job would be a good match. The 'pu' clicks on the job link

from the email and reviews the job from the website. Likes the job and decides to click the apply online button. Now here is where it get interesting. The 'pu' then is given

a couple of options login as an existing user or register. They register and create usrid and pwd then click the submit. The website logs the user in with their now created

usrid and pwd, so the code has to be passing the $user_id at least. Once the website logs the user in it asks for additional info, fill it out then click the (save button).

Now from this button I would like to say:

Take this user($user_id), ($resume_id) that just signed up and apply them to this position ($post_id).