<?php
session_start();
require_once('includes/functions.php');
$error=null;
# check for existance of prior started job ad
if (isset($_SESSION['job_ad_id_for_job_board'])) {
$id = $_SESSION['job_ad_id_for_job_board'];
} else {
$error .= 'A job ID is required - Check #1 ';
header('Location: post.php?invalid');
}
# validate id is still in need of previewing
if ($id) {
$select = "SELECT * FROM ".TB_JOBS." WHERE form_id='".clean($id)."' AND preview IS NULL AND completed IS NULL";
$result = mysql_query($select);
$count = mysql_num_rows($result);
# if the sql returned an unfinished job ad with the id given, pull that data
if($count == 1) {
$row = mysql_fetch_assoc($result);
} else {
$error .= 'That job ID does not exist - Check #2 ';
header('Location: post.php');
}
} else {
$error.= 'A job ID is required - Check #3 ';
header('Location: post.php');
}
# when someone pushes the button to approve their job ad
if (isset($_POST['submit'])) {
# update database to replace preview with timestamp, then redirect to purchase page
mysql_query("UPDATE ". TB_JOBS ." SET preview='".clean(date("D M j G:i:s T Y"))."'WHERE form_id='".$id."'");
header('Location: purchase.php');
exit;
}
?>
<?php get_template('header', 'Preview Your Ad'); ?>
<div id="main">
<h3><span>Step 2:</span> Preview Your Ad</h3>
<div id="jobpreview">
<h2><?php echo $row['title']; ?></h2>
<p class="jobmeta">Posted <?php echo date("M d, Y", convert_datetime($row['created'])); ?></p>
<p class="jobhead"><strong><?php echo $row['company']; ?></strong><br />
Location: <?php echo $row['location']; ?><br />
<?php if (! empty($row['url'])) {
echo '<a href="'.$row['url'].'" target="_blank" >'.$row['url'].'</a>';
} ?>
</p>
<div class="jobbody">
<?php echo nl2br($row['description']); ?>
</div>
<div class="jobapply">
<h4>How to Apply:</h4>
<?php echo nl2br($row['apply']); ?>
</div>
</div>
<form action="<?php echo get_filename(); ?>" method="post" enctype="multipart/form-data" >
<p class="submitline"><span><input type="submit" class="submit" name="submit" id="submit" value="Continue to Step 3 — Make your purchase" /></span></p>
</form>
</div>
<div id="sidebar">
<?php if($row['logo']) {?>
<div class="joblogo">
<a href="<?php echo $row['url']; ?>" target="_blank" ><img src="includes/timthumb.php?src=<?php echo $row['logo']; ?>&w=240&zc=1" alt="<?php echo $row['company']; ?>" /></a>
</div>
<?php } ?>
<div class="inner">
<h2>Hint</h2>
This is the way your job ad will look once it is posted.</p><p>Want to make changes to it? Go back and <a href="post.php">edit your ad</a>.
</div>
</div>
<?php get_template('footer'); ?>