Jump to content

Need help in finishing a project


ROCKINDANO

Recommended Posts

Hello everyone,

 

I am working on a project for a client that requested for online employment. So far what i have is a login page (login.php), create an account (createaccnt.php) and view all jobs (alljobs.php).

 

I want them to create an account first before applying or adding a job to their basket. Once the create an account they can view all jobs (alljobs.php). The all jobs page lists all the jobs with a check box to the right. i am trying to pass the job_id to the Employment Main menu (empmainmenu.php) when they click submit btn. the employment main menu displays their names, and a table with all the jobs that they have added.

 

this is where i am having trouble. i can't get it to pass the job_id to the employment main menu page.  can someone help me with this. maybe i am doing it wrong or there might be an easier way.

 

below is my code for all my pages.

 

alljobs.php page

<body>
<?php
if(isset($_POST['submit'])) {
$job_id = $_POST['job_id'];
	header('Location: login.php');
}

?>
<form method="post" action="empmainmenu.php">
     <?php


			if(!($db = @ mysql_connect('host', 'name', 'password')))
			{
				echo 'Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time.';
				exit;
			}
			//select which database you want to edit
			mysql_select_db("job_site"); 

				$apply = $_POST["checkbox"];

				$query = "SELECT * FROM fulltime ORDER BY jobnum desc";
				$result = mysql_query($query);

				print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"table\">";
  					print "<tr align=\"center\" style=\"color:#FFFFFF\" bgcolor=\"#0066FF\">";
				print "<td width=\"20%\">Title</td>";
                	print "<td width='30%'>Department</td>";
//					print "<td width='21%'>Supervisor</td>";
                print "<td width='13%'>Pay</td>";
    	            print "<td width='13%'>Job#</td>";
				print "<td width='13%'>Closing Date</td><td> </td>";
//        	        print "<td width=\"22%\" align=\"center\"> View Job</td>";
  					print "</tr>";
					print "<tr>";
  					print "<td width=\"100%\" colspan=\"6\">";
    					print "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">";
						//goes through all records in database and retrieves the need ones.
				while($r=mysql_fetch_array($result))
				{	
				  //the format is $variable = $r["nameofmysqlcolumn"];
				  //modify these to match your mysql table columns
					$job_id=$r["job_id"];
					$department=$r["department"];
					$supervisor=$r["supervisor"];
					$title=$r["title"];

					//displays all info only first three
					print "<tr><td width='20%'><a href='fullemp.php?job_id=$job_id'>".$title."</a></td>";
					print "<td width=\"30%\" style=\"padding-left: 5px\">".$department."</td>";
//						print "<td width='21%'>".$supervisor."</td>";
					print "<td width=\"13%\" align=\"center\">".$pay=$r["pay"]."</td>";
					print "<td width=\"13%\" align=\"center\">".$jobnum=$r["jobnum"]."</td>";
					print "<td width=\"20%\" align=\"center\">".$closedate=$r["dataclose"]."</td>
					<td><input type='checkbox' name='checkbox' value='checked1' /></td></tr>";
			//		print "<td width=\"10%\" align=\"center\"><a href='fullemp.php?job_id=$job_id'>view</a></td></tr>";
				}//end while loop
					print "</table>";
					print "</td>";
   						print "</tr>";
					print "</table>";


?>
            <input type="submit" name="submit" value="submit" />          
</form>

</body>

 

empmainmenu.php page

<body>

<?php

	$error  = ""; //leave blank


	if(!isset($_SESSION["user_id"]) || !isset($_SESSION["ip_addr"]))
		 die("Invalid operation!!!<br />Please login first<br /><a href=\"login.php\">Login</a>");

			$user_id=$_SESSION["user_id"];
		$ip_addr=$_SESSION["ip_addr"];
		if($ip_addr != $_SERVER["REMOTE_ADDR"])
			 die("invalid operation!!!<br /> please login first");


	if(!($db = @ mysql_connect('localhost', 'dvera', 'letdanin23')))
	{
		print "Error: Could not connect to our database sorry for any inconvience.<br /> Please try at a later time.";
	}						
		 //select which database you want to edit
		mysql_select_db("employement"); 

				$query = "SELECT * FROM users WHERE user_id='{$user_id}'";
				$result = mysql_query($query);
				$num_result = mysql_num_rows($result);

				if($num_result == 0)
				die("Invalid operation <br /> Please login first");
				$row = @ mysql_fetch_array($result);
?>
    <?php
	echo '<h3>Employement Main Menu</h3>'; ?>
      
      <a href="alljobs.php">View all Jobs Available</a><br /><a href="changeinfo.php">View/change your Contact Information</a><br />
      
<?php
 	$job_id = $_POST['job_id'];

print $job_id;

      echo '<p>Welcome, ' .$_SESSION['Fname']. ' ' .$_SESSION['Lname']. '</p>';


?>
    	<table width="100%" border="1" cellspacing="1" cellpadding="0">
          <tr bgcolor="#000099">
            <th style="color:#FFF;" colspan="4">Your saved jobs.</th>
          </tr>
<?php
	if (!$db = mysql_connect('host','user','password'))
	{
		print "Error: could not connect to the database.<br>".mysql_error();
	}

	mysql_select_db('employement') or die(mysql_error());  

	$query = "SELECT * FROM jobs WHERE jobs.user_id = '{$user_id}'";
	$result = mysql_query($query);

	$num_result = mysql_num_rows($result);


	while ($r=mysql_fetch_array($result))
	{

		$jobID=$r['jobID'];
		$user_id=$r['user_id'];
		$jobTitle=$r['jobTitle'];
		$jobNumber=$r['jobNumber'];
		$department=$r['department'];
	}
	if($num_result >= 1) {
	echo '<tr>';
			echo '<td>' .$jobTitle. '</td>';
			echo '<td>' .$jobNumber. '</td>';
			echo '<td>' .$department. '</td>';
			echo '<td> <a href="">View Status</td>';
	echo '</tr>'; }

	else if($num_result == 0)
	{
		echo '<td><font style="color:#FF0000">You have no saved jobs</font>.</td>';
	}

?>
        </table>

  		<a href="logout.php">logout</a>
</body>

Link to comment
https://forums.phpfreaks.com/topic/200172-need-help-in-finishing-a-project/
Share on other sites

Your loop you are naming all the check boxes the same. make the check boxes an array ie

 

<?PHP
$job_id_values = array ("001","002","004");
$i=0;
while($i<3) {
	echo $job_id_values[$i] . '<input type="checkbox" name=box[] value="' . $job_id_values[$i] . '"><br>';
$i++;
}
?>

 

make sense?

 

in you alljobs page

replace this

<td><input type='checkbox' name='checkbox' value='checked1' /></td></

with this

<td><input type='checkbox' name=box[] value='<?PHP echo $job_id;?>' /></td></

then on your empmainmenu page loop thru the box[] values displaying the approriate data

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.