Jump to content

PHP/SQL Integration: Posting Variables


SokrMan

Recommended Posts

Hello,

 

So I have a website where users can enter jobs they need done. Then workers can go there to find jobs. Im fairly new at PHP. At http://prahan.com/jobs/jobs.php, you can view all the entered jobs. My goal, is to add a button on the right of the text which users can click. Once clicked a form (http://prahan.com/jobs/sendemail/) will pop up. The users can enter their information. They will receive a confirmation email. Now, what im stuck on is, the author of the job needs to all get an email with the information entered into the form. I need a way so that when the user clicks the button on the search results the author of the selected job, author's email, and the name of the job get embed into the form somehow. They should be called jname, jemail, and jtext.

 

Here's how my databases are laid out.

Table: Jobs

Columns: jobtext, id, authorid

 

Table:Author

Columns:id, name, email

 

jobs.authorid matches with author.id .

 

Here is the code from some of my pages.

Search Results Code:

if (isset($_GET['action']) and $_GET['action'] == 'search')
{
include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php';

// The basic SELECT statement
$select = 'SELECT id, jobtext';
$from   = ' FROM job';
$where  = ' WHERE TRUE';

$authorid =  mysqli_real_escape_string($link, $_GET['author']);
if ($authorid != '') // An author is selected
{
	$where .= " AND authorid='$authorid'";
}

$categoryid =  mysqli_real_escape_string($link,
		$_GET['category']);
if ($categoryid != '') // A category is selected
{
	$from  .= ' INNER JOIN jobcategory ON id = jobid';
	$where .= " AND categoryid='$categoryid'";
}

$text = mysqli_real_escape_string($link, $_GET['text']);
if ($text != '') // Some search text was specified
{
	$where .= " AND jobtext LIKE '%$text%'";
}

$result = mysqli_query($link, $select . $from . $where);
if (!$result)
{
	$error = 'Error fetching jobs.';
	include 'error.html.php';
	exit();
}

while ($row = mysqli_fetch_array($result))
{
	$jobs[] = array('id' => $row['id'], 'text' => $row['jobtext']);
}

include 'jobs.html.php';

 

Contact Info Form:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<!-- #BeginTemplate "../resource_locator.dwt" -->

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
<!-- #BeginEditable "doctitle" -->
<title>Register</title>
<style type="text/css">
.style8 {
text-align: left;
}
.style12 {
color: #366092;
}
.style13 {
font-family: Verdana;
color: #366092;
letter-spacing: normal;
font-size: small;
}
.style14 {
color: #366092;
font-family: Verdana;
font-size: small;
}
.style15 {
font-family: Verdana;
font-size: small;
}
.style17 {
font-family: Verdana;
font-size: x-large;
color: #366092;
}
</style>
<!-- #EndEditable -->
<style type="text/css">
.style6 {
font-size: xx-large;
text-align: left;
}
.style7 {
text-align: center;
}
</style>
<script type="text/javascript">
<!--
function FP_swapImg() {//v1.0
var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
return null;
}
// -->
</script>
</head>

<body onload="FP_preloadImgs(/*url*/'../../images/button46.jpg',/*url*/'../../images/button47.jpg',/*url*/'../../images/button49.jpg',/*url*/'../../images/button4A.jpg',/*url*/'../../images/button4C.jpg',/*url*/'../../images/button4D.jpg')">

	<p style="margin:0in;font-family:Calibri;color:#366092" class="style6">
	<span style="font-weight:bold">Resource Locator</span></p>
	<p style="margin:0in;font-family:Calibri;color:#366092">
	 </p>
	<div><a href="../index.php">
		<img id="img1" alt="Home" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img1',/*url*/'../../images/button47.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img1',/*url*/'../../images/button45.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img1',/*url*/'../../images/button46.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img1',/*url*/'../../images/button46.jpg')" src="../../images/button45.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Brick Row 7" fp-title="Home" --></a>
		<a href="/jobs/jobs.php">
		<img id="img3" alt="Available Jobs" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img3',/*url*/'../../images/button4D.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img3',/*url*/'../../images/button4B.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img3',/*url*/'../../images/button4C.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img3',/*url*/'../../images/button4C.jpg')" src="../../images/button4B.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Brick Row 7" fp-title="Available Jobs" --></a>
		<img id="img2" alt="Login" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img2',/*url*/'../../images/button4A.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img2',/*url*/'../../images/button48.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img2',/*url*/'../../images/button49.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img2',/*url*/'../../images/button49.jpg')" src="../../images/button48.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Brick Row 7" fp-title="Login" --> </div>
	<!-- #BeginEditable "body" -->
<div class="style8">
<p class="style17"><strong>Apply For Job</strong></p>
<p class="style13">Please fill in all fields. The job poster will contact 
you shortly.</p>	
<form action="verify.php" method="post" name="register">
    	<span class="style14">Full Name: <br />
	</span> 
	<input type="text" name="name" class="style14" />
    	<br class="style15" />
    <br class="style14" />
    	<span class="style14">Location: <br />
	</span> 
	<input type="text" name="location" class="style14" />
    <br class="style14" />
    	<span class="style12"><br class="style15" />
	<span class="style15">Email:<br />
	</span></span> 
	<input type="text" name="email" class="style14" /><br />
	<br />
    	<span class="style12">
	<span class="style15">Additional Information About Yourself:<br />
	</span></span> 
	<input type="text" name="info" class="style14" style="width: 417px; height: 94px" /><br />
	<br class="style15" />
	<br class="style14" />
<input type="hidden" name="form_submitted" value="1" class="style14"/> 
  <input type="submit" value="Apply" class="style14" /><span class="style14">
	</span>
  </form>
</div>
<!-- #EndEditable -->

	<p class="style7">
	<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
	<span class="Apple-style-span" style="font-family: Verdana; font-size: 11px; text-align: center; ">
	Website Designed and Created by<span class="Apple-converted-space"> </span><a href="http://mysite.prahan.com/" style="color: rgb(139, 0, 0); text-decoration: underline; " target="_blank">Pratik 
	Vaidya</a><br />
	<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">
	<span class="Apple-style-span" style="font-family: Arial, Times, serif; text-align: justify; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">
	©</span></span><span class="Apple-converted-space"> Prahan.com</span> 
	2010</span></span></p>

</body>

<!-- #EndTemplate -->

</html>

 

Sending Email Script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<!-- #BeginTemplate "../resource_locator.dwt" -->

<head>
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" />
<!-- #BeginEditable "doctitle" -->
<title>Resource Locator</title>
<style type="text/css">
.style8 {
color: #366092;
}
</style>
<!-- #EndEditable -->
<style type="text/css">
.style6 {
font-size: xx-large;
text-align: left;
}
.style7 {
text-align: center;
}
</style>
<script type="text/javascript">
<!--
function FP_swapImg() {//v1.0
var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
return null;
}
// -->
</script>
</head>

<body onload="FP_preloadImgs(/*url*/'../../images/button46.jpg',/*url*/'../../images/button47.jpg',/*url*/'../../images/button49.jpg',/*url*/'../../images/button4A.jpg',/*url*/'../../images/button4C.jpg',/*url*/'../../images/button4D.jpg')">

	<p style="margin:0in;font-family:Calibri;color:#366092" class="style6">
	<span style="font-weight:bold">Resource Locator</span></p>
	<p style="margin:0in;font-family:Calibri;color:#366092">
	 </p>
	<div><a href="../index.php">
		<img id="img1" alt="Home" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img1',/*url*/'../../images/button47.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img1',/*url*/'../../images/button45.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img1',/*url*/'../../images/button46.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img1',/*url*/'../../images/button46.jpg')" src="../../images/button45.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Brick Row 7" fp-title="Home" --></a>
		<a href="/jobs/jobs.php">
		<img id="img3" alt="Available Jobs" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img3',/*url*/'../../images/button4D.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img3',/*url*/'../../images/button4B.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img3',/*url*/'../../images/button4C.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img3',/*url*/'../../images/button4C.jpg')" src="../../images/button4B.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Brick Row 7" fp-title="Available Jobs" --></a>
		<img id="img2" alt="Login" height="20" onmousedown="FP_swapImg(1,0,/*id*/'img2',/*url*/'../../images/button4A.jpg')" onmouseout="FP_swapImg(0,0,/*id*/'img2',/*url*/'../../images/button48.jpg')" onmouseover="FP_swapImg(1,0,/*id*/'img2',/*url*/'../../images/button49.jpg')" onmouseup="FP_swapImg(0,0,/*id*/'img2',/*url*/'../../images/button49.jpg')" src="../../images/button48.jpg" style="border: 0" width="100" /><!-- MSComment="ibutton" fp-style="fp-btn: Brick Row 7" fp-title="Login" --> </div>
	<!-- #BeginEditable "body" -->
	<p class="style8"><?php
if ($_POST['form_submitted'] == '1') {
##User is registering, insert data until we can activate it

$name = ($_POST[username]);
$info = ($_POST[info]);
$location = ($_POST[location]); 
$email = ($_POST[email]);

echo "An email has been sent to the Job Poster with your contact information. You will recieve a confirmation email at $_POST[email]. Remeber to check your junk mail as well.";

##Send activation Email

$to      = $_POST[email];

$subject = " Job Applicaton Confirmation";

$message = "Hello $_POST[name] , \r\rYou, or someone using your email address, has applied for a job using the Resource Locator at Prahan.com. Keep this as future reference. \r\r Full Name: $_POST[name] \r Location: $_POST[location] \r Email: $_POST[email] \r Additional Information: $_POST[info] \r\r Expect a response shortly. \r\r Regards, Prahan.com Team";

$headers = 'From: noreply@prahan.com' . "\r\n" .

    'Reply-To: noreply@prahan.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

$to1      = $_POST[jemail];

$subject1 = " Job Applicaton for $_POST[jtext]";

$message1 = "Hello $_POST[jname] , \r\r$_POST[name] has applied for a job you posted on The Resource Locator at Prahan.com. Here is the information they have provided you with. \r\r Full Name: $_POST[name] \r Location: $_POST[location] \r Email: $_POST[email] \r Additional Information: $_POST[info] \r Please get back to them shortly. \r\r Expect a response shortly. \r\r Regards, Prahan.com Team";

$headers1 = 'From: noreply@prahan.com' . "\r\n" .

    'Reply-To: noreply@prahan.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

mail($to1, $subject1, $message1, $headers1);
} 
?></p>
<!-- #EndEditable -->

	<p class="style7">
	<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
	<span class="Apple-style-span" style="font-family: Verdana; font-size: 11px; text-align: center; ">
	Website Designed and Created by<span class="Apple-converted-space"> </span><a href="http://mysite.prahan.com/" style="color: rgb(139, 0, 0); text-decoration: underline; " target="_blank">Pratik 
	Vaidya</a><br />
	<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">
	<span class="Apple-style-span" style="font-family: Arial, Times, serif; text-align: justify; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">
	©</span></span><span class="Apple-converted-space"> Prahan.com</span> 
	2010</span></span></p>

</body>

<!-- #EndTemplate -->

</html>

 

Thanks in Advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.