MrJames Posted July 7, 2011 Share Posted July 7, 2011 Hi, I am trying to create a Recruitment based website that allows the user to post jobs for three different lengths, i.e. 14 days, 1 month etc. Now I have it all working up to the point where paypal tries to send/carry out the IPN script. It does not send the values back to the database nor does it send the user to the Success page. When I look at the IPN history it says error response 404, but have looked at all the file paths and permissions and they all seem fine. Here is my PostJobs.php page where the user enters the job information: <?php require ('../jobAdmin/config.inc.php'); include ('../includes/header.php'); require (MySQL); $reg_errors = array(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // ===================================== GET PACKAGE ID =========================================== if ((isset($_GET['packageID'])) && (is_numeric($_GET['package_ID']))) { $packageID = (int) $_GET['packageID']; } elseif ((isset($_POST['packageID'])) && (is_numeric($_POST['packageID']))) { $packageID = (int) $_POST['packageID']; } else { echo '<section class="wrapper"> <section class="page_wrap"> <article class="mainContent">'; echo '<div id="jobResults">'; echo '<h1 class="normal padding">No Package Found...</h1>'; echo '<p class="normal black textHeight padding"> Sorry you did not manage to select a package for your Job Advertisement, you cannot progress you Job Advertisement without choosing a package. </p><br />'; echo '<p class="normal black textHeight padding">Please go back and select again.</p></div> </article>'; echo '<aside class="sideBar padding"> <h5 class="normal padding blue capitals bottom">Job Post Features</h5> <ul id="jobPost"> <li> <img src="../images/email.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE EMAIL LISTINGS</h6> <p class="padding textHeight graw">Whatever Job Type you purchased your vacancy will be put into Emails that are sent out on a daily basis as long as your vacancy is still valid.</p> </li> <li> <img src="../images/feed.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE SOCIAL HUB LISTINGS</h6> <p class="padding textHeight graw">With every Job that is posted it is automatically added to our Social Networks which include <a href="http://www.flockjobs.com/feeds/jobFeed.rss" class="keyword">RSS</a>, <a href="http://www.twitter.com/flockJobs" class="keyword">Twitter</a> and <a href="http://www.facebook.com/flockJobs" class="keyword">Facebook</a> as long as your vacancy is still valid.</p> </li> <li> <img src="../images/lockblue.png" align="left" alt="" title="" /> <h6 class="normal blue">SAFE AND SECURE PAYMENT</h6> <p class="padding textHeight graw">All transactions are processed by PayPal who accept most major credit cards.</p> </li> <li> <img src="../images/clock.png" align="left" alt="" title="" /> <h6 class="normal blue">EASY AND EFFICIENT</h6> <p class="padding textHeight graw">All Job posts are posted live and instantly there is no registration and no contracts saving you time.</p> </li> </ul> </aside> </section> </section>'; include ('../includes/footer.php'); exit(); } // ====================================== END PACKAGE ID ========================================== // if (preg_match ('/^[A-Z \'.-]{2,100}$/i', $_POST['companyname'])) { $companyName = mysqli_real_escape_string ($dbc, strip_tags($_POST['companyname'])); } else { $reg_errors['companyname'] = 'Enter Your Company Name'; } $companyWebsite = mysqli_real_escape_string ($dbc, strip_tags($_POST['companywebsite'])); if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $_POST['companyemail'])) { $companyEmail = mysqli_real_escape_string ($dbc, strip_tags($_POST['companyemail'])); } else { $reg_errors['companyemail'] = 'Enter A Valid Company Email Address'; } if (filter_var($_POST['CountryCode'], FILTER_SANITIZE_STRING)) { $companyLocation = mysqli_real_escape_string ($dbc, $_POST['CountryCode']); } else { $reg_errors['CountryCode'] = 'Select Your Companies Location'; } if (isset($_FILES['new_image']['name'])) { if (($_FILES['new_image']['type'] == "image/jpg") || ($_FILES['new_image']['type'] == "image/jpeg") && ($_FILES['new_image']['size'] < MAX_FILE_SIZE)) { $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $target = "../pictures/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "../pictures/new_pictures/" . $imagepath; $file = "../pictures/" . $imagepath; list($width, $height) = getimagesize($file); $modwidth = 500; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight); $image = imagecreatefromjpeg($file); imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); imagejpeg($tn, $save, 100); $save = "../pictures/new_pictures/sml_" . $imagepath; $file = "../pictures/" . $imagepath; list($width, $height) = getimagesize($file); $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight); $image = imagecreatefromjpeg($file); imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); imagejpeg($tn, $save, 100); $newLogo = "/pictures/new_pictures/" . $_FILES['new_image']['name']; $smallLogo = "/pictures/new_pictures/sml_" . $_FILES['new_image']['name']; } $newLogo = '/pictures/new_pictures/no_image.jpg'; } if (preg_match ('/^[A-Z \'.-]{2,100}$/i', $_POST['jobtitle'])) { $jobTitle = mysqli_real_escape_string ($dbc, strip_tags($_POST['jobtitle'])); } else { $reg_errors['jobtitle']='Enter A Job Title'; } if (filter_var($_POST['SectorID'], FILTER_VALIDATE_INT, array('min_range' => 1))) { $jobSector = mysqli_real_escape_string ($dbc, strip_tags($_POST['SectorID'])); } else { $reg_errors['SectorID'] = 'Select Your Job Sector'; } if (filter_var($_POST['jobtype'], FILTER_SANITIZE_STRING)) { $jobType = mysqli_real_escape_string ($dbc, strip_tags($_POST['jobtype'])); } else { $reg_errors['jobtype'] = 'Select A Job Type'; } if (preg_match ('/^[A-Z \',.-]{2,100}$/i', $_POST['joblocation'])) { $jobLocation = mysqli_real_escape_string ($dbc, strip_tags($_POST['joblocation'])); } else { $reg_errors['joblocation']='Enter Location Of The Job'; } if (!empty($_POST['JobContent'])) { $allowed = '<div><p><span><br><a><img><h1><h2><h3><h4><ul><ol><li><blockquote><strong><em><del><ins>'; $jobDesc = mysqli_real_escape_string($dbc, strip_tags($_POST['JobContent'], $allowed)); } else { $reg_errors['JobContent'] = 'Please Enter A Job Description'; } if (!empty($_POST['JobApplyContent'])) { $allowed = '<div><p><span><br><a><img><h1><h2><h3><h4><ul><ol><li><blockquote><strong><em><del><ins>'; $jobApply = mysqli_real_escape_string($dbc, strip_tags($_POST['JobApplyContent'], $allowed)); } else { $reg_errors['JobApplyContent'] = 'Enter How To Apply For The Job'; } // ====================================== END OF JOBS INFORMATION ========================================== // if (empty($reg_errors)) { // if everythings okay $q = "SELECT JobServiceID,JobServiceDesc,JobLength,Price FROM JobProducts WHERE JobServiceID = '$packageID'"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) == 1) { $row = mysqli_fetch_array ($r, MYSQLI_NUM); $productID = $row[0]; $productDescription = $row[1]; $productLength = $row[2]; $productPrice = $row[3]; $CompanyIP = $_SERVER['REMOTE_ADDR']; $q = "INSERT INTO Company(CompanyName,CompanyWebsite,CompanyEmail,CountryCode,CompanyIP)VALUES('$companyName','$companyWebsite','$companyEmail','$companyLocation','$CompanyIP')"; $r = mysqli_query($dbc, $q); if(mysqli_affected_rows($dbc) == 1) { $companyID = mysqli_insert_id($dbc); $_SESSION['companyID'] = $companyID; $q = "INSERT INTO pictures(CompanyID,logoPath)VALUES({$_SESSION['companyID']},'$newLogo')"; $r = mysqli_query($dbc, $q); if(mysqli_affected_rows($dbc) == 1) { $a = md5(uniqid(rand(), true)); $q = "INSERT INTO JobAdvert(CompanyID,JobServiceID,JobCode,JobTitle,JobSector,JobType,JobLocation,JobDescription,JobApply,JobExpires)VALUES({$_SESSION['companyID']},'$productID','$a','$jobTitle','$jobSector','$jobType','$jobLocation','$jobDesc','$jobApply', SUBDATE(NOW(), INTERVAL 1 DAY) )"; $r = mysqli_query($dbc, $q); $JobAdvert = mysqli_insert_id($dbc); $_SESSION['JobAdvertID'] = $JobAdvert; if(mysqli_affected_rows($dbc) == 1) { $JobAdvertID = mysqli_insert_id($dbc); //$_SESSION['JobAdvertID'] = $JobAdvert; echo '<section class="wrapper"> <section class="page_wrap"> <article class="mainContent"> <h1 class="normal padding">Proceed With Payment...</h1> <span class="padding textHeight graw normal txt1">1. Complete Job Details </span><span class="padding textHeight bold blue capitals">2. Proceed With Payment </span><br /><br />'; echo '<p class="padding textHeight"> Congratulations on completing step 1, To complete the process please proceed by clicking the button below so that you may pay for your Job Post via PayPal.'; echo '</p><br />'; //echo "{$_SESSION['JobPrice']}"; echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="customersupport@flockjobs.com"/> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="email" value="' . $companyEmail . '"/> <input type="hidden" name="custom" value="' . $JobAdvertID . '"/> <input type="hidden" name="hosted_button_id" value="PF4VPS4ZM2384"> <input type="hidden" name="item_name" value="' . $productDescription . '"/> <input type="hidden" name="amount" value="' . $productPrice . '"/> <input type="hidden" name="tax" value="20.0"> <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online." class="padding"> <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form>'; echo ' </article> <aside class="sideBar padding"> <h5 class="normal padding blue capitals bottom">Job Post Features</h5> <ul id="jobPost"> <li> <img src="../images/email.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE EMAIL LISTINGS</h6> <p class="padding textHeight graw">Whatever Job Type you purchased your vacancy will be put into Emails that are sent out on a daily basis as long as your vacancy is still valid.</p> </li> <li> <img src="../images/feed.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE SOCIAL HUB LISTINGS</h6> <p class="padding textHeight graw">With every Job that is posted it is automatically added to our Social Networks which include <a href="http://www.flockjobs.com/feeds/jobFeed.rss" class="keyword">RSS</a>, <a href="http://www.twitter.com/flockJobs" class="keyword">Twitter</a> and <a href="http://www.facebook.com/flockJobs" class="keyword">Facebook</a> as long as your vacancy is still valid.</p> </li> <li> <img src="../images/lockblue.png" align="left" alt="" title="" /> <h6 class="normal blue">SAFE AND SECURE PAYMENT</h6> <p class="padding textHeight graw">All transactions are processed by PayPal who accept most major credit cards.</p> </li> <li> <img src="../images/clock.png" align="left" alt="" title="" /> <h6 class="normal blue">EASY AND EFFICIENT</h6> <p class="padding textHeight graw">All Job posts are posted live and instantly there is no registration and no contracts saving you time.</p> </li> </ul> </aside> </section> </section>'; // SEND AN EMAIL LETTING THEM KNOW // $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:long="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Flockjobs.com, Step 1, Post A Job</title> <style type="text/css"> body,td,th {font-family: arial,sans-serif;font-size: 12px;} body {background-color: #F0f0f0;margin-left: 0px;margin-top: 0px;} p {color:#444;padding:0 0 0 8px;line-height:1.5em;} h4 {font-size:25;font-weight:400;color:#000000;} a{text-decoration:none;} a:hover{text-decoration:underline;} </style> </head> <body><center><br />'; $message .="<table width=\"600\" border=\"0\" bgcolor=\"#FFFFFF\" cellpadding=\"25\"> <tr> <td align=\"left\" bgcolor=\"#FFFFFF\"> <br /><br /> <p><h4>Flockjobs.com Notification</h4></p><br /> <p> Congratulations on deciding to advertise your Job vacancy with <a href=\"http://www.flockjobs.com\">flockjobs.com</a> whether you are a Recruitment company or an employer we hope you find your ideal Candidate. </p> <br /> <p> This is a notification email to tell you that your Job Advertisement has nearly been completed all that is required for you to do is to continue with your online payment via PayPal. Once this has been completed you will then be able to Edit / Delete your Job Vacancy whenever you feel like it as long as your Job Advertisement is still Valid. </p> <br /> <p> We use free advertising methods in which other recruitment boards would charge for and help get your Job advertisement noticed by tapping into the social networking areas such as <a href=\"http://www.facebook.com/flockjobs\">Facebook</a>, <a href=\"http://www.twitter.com/flockjobs\">Twitter</a> and our own RSS feed <a href=\"http://www.flockjobs.com/jobFeeds/jobFeed.php\">flockjobs.com</a>. </p> <br /><br /> <p> Yours Sincerely<br /><br />flockjobs.com </p> </tr> </table> <br /></center></body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .='From: Flockjobs.com <customersupport@flockjobs.com>' . "\r\n" . 'Reply-To: Admin@webzoost.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($_POST['companyemail'],'Flockjobs, Step 1, Post A Job',$message,$headers); //mail ($_POST['companyemail'], 'Step 1, Complete Job Details', $body, 'From: CustomerSupport@flockjobs.com'); include('../includes/footer.php'); exit(); } else { echo 'Problem with job info with image'; } } else { $a = md5(uniqid(rand(), true)); $q = "INSERT INTO JobAdvert(CompanyID,JobServiceID,JobCode,JobTitle,JobSector,JobType,JobLocation,JobDescription,JobApply,JobExpires)VALUES({$_SESSION['companyID']},'$productID','$a','$jobTitle','$jobSector','$jobType','$jobLocation','$jobDesc','$jobApply', SUBDATE(NOW(), INTERVAL 1 DAY) )"; $r = mysqli_query($dbc, $q); if(mysqli_affected_rows($dbc) == 1) { $JobAdvertID = mysqli_insert_id($dbc); $_SESSION['JobAdvertID'] = $JobAdvert; echo '<section class="wrapper"> <section class="page_wrap"> <article class="mainContent"> <h1 class="normal padding">Proceed With Payment...</h1> <span class="padding textHeight graw normal txt1">1. Complete Job Details </span><span class="padding textHeight bold blue capitals">2. Proceed With Payment </span><br />'; echo '<p class="padding textHeight"> Congratulations on completing step 1, To complete the process please proceed by clicking the button below so that you may pay for your Job Post via PayPal.'; echo '</p> </article> <aside class="sideBar padding"> <h5 class="normal padding blue capitals bottom">Job Post Features</h5> <ul id="jobPost"> <li> <img src="../images/email.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE EMAIL LISTINGS</h6> <p class="padding textHeight graw">Whatever Job Type you purchased your vacancy will be put into Emails that are sent out on a daily basis as long as your vacancy is still valid.</p> </li> <li> <img src="../images/feed.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE SOCIAL HUB LISTINGS</h6> <p class="padding textHeight graw">With every Job that is posted it is automatically added to our Social Networks which include <a href="http://www.flockjobs.com/feeds/jobFeed.rss" class="keyword">RSS</a>, <a href="http://www.twitter.com/flockJobs" class="keyword">Twitter</a> and <a href="http://www.facebook.com/flockJobs" class="keyword">Facebook</a> as long as your vacancy is still valid.</p> </li> <li> <img src="../images/lockblue.png" align="left" alt="" title="" /> <h6 class="normal blue">SAFE AND SECURE PAYMENT</h6> <p class="padding textHeight graw">All transactions are processed by PayPal who accept most major credit cards.</p> </li> <li> <img src="../images/clock.png" align="left" alt="" title="" /> <h6 class="normal blue">EASY AND EFFICIENT</h6> <p class="padding textHeight graw">All Job posts are posted live and instantly there is no registration and no contracts saving you time.</p> </li> </ul> </aside> </section> </section>'; //echo "{$_SESSION['JobPrice']}"; // Process Payments echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="customersupport@flockjobs.com"/> <input type="hidden" name="currency_code" value="GBP"> <input type="hidden" name="email" value="' . $companyEmail . '"/> <input type="hidden" name="custom" value="' . $JobAdvertID . '"/> <input type="hidden" name="hosted_button_id" value="PF4VPS4ZM2384"> <input type="hidden" name="item_name" value="' . $productDescription . '"/> <input type="hidden" name="amount" value="' . $productPrice . '"/> <input type="hidden" name="tax" value="20.0"> <input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online." class="padding"> <img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"> </form>'; //END Payments // SEND AN EMAIL ====================================================================// $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:long="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Flockjobs.com, Step 1, Post A Job</title> <style type="text/css"> body,td,th {font-family: arial,sans-serif;font-size: 12px;} body {background-color: #F0f0f0;margin-left: 0px;margin-top: 0px;} p {color:#444;padding:0 0 0 8px;line-height:1.5em;} h4 {font-size:25;font-weight:400;color:#000000;} a{text-decoration:none;} a:hover{text-decoration:underline;} </style> </head> <body><center><br />'; $message .="<table width=\"600\" border=\"0\" bgcolor=\"#FFFFFF\" cellpadding=\"25\"> <tr> <td align=\"left\" bgcolor=\"#FFFFFF\"> <br /><br /> <p><h4>Flockjobs.com Notification</h4></p><br /> <p> Congratulations on deciding to advertise your Job vacancy with <a href=\"http://www.flockjobs.com\">flockjobs.com</a> whether you are a Recruitment company or an employer we hope you find your ideal Candidate. </p> <br /> <p> This is a notification email to tell you that your Job Advertisement has nearly been completed all that is required for you to do is to continue with your online payment via PayPal. Once this has been completed you will then be able to Edit / Delete your Job Vacancy whenever you feel like it as long as your Job Advertisement is still Valid. </p> <br /> <p> We use free advertising methods in which other recruitment boards would charge for and help get your Job advertisement noticed by tapping into the social networking areas such as <a href=\"http://www.facebook.com/flockjobs\">Facebook</a>, <a href=\"http://www.twitter.com/flockjobs\">Twitter</a> and our own RSS feed <a href=\"http://www.flockjobs.com/jobFeeds/jobFeed.php\">flockjobs.com</a>. </p> <br /><br /> <p> Yours Sincerely<br /><br />flockjobs.com </p> </tr> </table> <br /></center></body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .='From: Flockjobs.com <customersupport@flockjobs.com>' . "\r\n" . 'Reply-To: Admin@webzoost.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($_POST['companyemail'],'Flockjobs, Step 1, Post A Job',$message,$headers); //mail ($_POST['companyemail'], 'Step 1, Complete Job Details', $body, 'From: CustomerSupport@flockjobs.com'); //End Email Send include('../includes/footer.php'); exit(); } else { trigger_error('Problem with job info without image'); } } } else { trigger_error('problem with company insert'); } } else { trigger_error('error'); } } // End Errors Condition } // End Main Conditional Operator ?> <section class="splash_wrap bottom"> <section class="page_wrap"> <article class="jobSlogan"> <h1 class="normal padding">Post a Job</h1> <p class="padding textHeight"> <span class="keyword">flockJobs.com</span> is an easy to use, automated <span class="keyword">Jobs Board</span> that allows <span class="keyword">Employers</span> and <span class="keyword">Recruitment Companies</span> to promote their Job vacancies with one of the fastest growing <span class="keyword">Job Boards</span> in the UK. We try to make the whole process of Job posting as easy and efficient as possible, NO registration, NO need to login and NO contracts. We give <span class="keyword">Employers</span> and <span class="keyword">Recruitment Companies</span> unrivalled response at a fraction of the cost, while providing extra features listed below at no extra cost. </p> </article> <div class="clear"></div> </section> </section><!-- END JOB SPLASH MESSAGE --> <section class="wrapper"> <section class="page_wrap"> <article class="mainContent"> <h1 class="normal padding">Post a Job...</h1> <span class="padding textHeight blue capitals bold">1. Complete Job Details </span><span class="padding textHeight txt1 graw">2. Proceed With Payment </span> <?php require ('../jobAdmin/functions.php'); ?> <form class="padding" id="jobPost" method="post" enctype="multipart/form-data" action="http://www.flockjobs.com/postJobs/jobPost.php" accept-charset="utf-8"> <fieldset> <legend><span>1. Select Job Package</span></legend> <ol> <li> <?php $q = "SELECT * FROM JobProducts"; $r = mysqli_query($dbc, $q); if($r) { echo '<table width="660px" border="0" cellpadding="2" cellspacing="2">'; while($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<tr> <td width="90px" align="right"><h4 class="normal blue">£' . $row['Price'] . '</h4><span class="graw normal txt1 capitals">' . $row['JobLength'] . '</span></td> <td width="15px"> </td> <td width="200px" align="left" valign="top"><p class="normal black textHeight padding txt3">' . $row['JobServiceDesc'] . '</p></td> <td width="5px"> </td> <td width="60px"><input id="name" name="packageID" type="radio" value="' . $row['JobServiceID'] . '" /></td> </tr> <tr><td colspan="5"> </td></tr>'; } echo '</table><br />'; //mysqli_free_result($r); } else { echo 'No Job Packages Available At This Moment In Time'; } //mysqli_close($dbc); ?> <tr><td colspan="5"><span class="txt1 padding graw">All prices are exclusive of V.A.T</span></td></tr> </table> </li> </ol> </fieldset> <fieldset> <legend><span>2. Company Details</span></legend> <ol> <li> <label for="name">Company Name:</label> <?php formElements('companyname', 'text', $reg_errors); ?> </li> <li> <label for="email">Company Website:</label> <?php formElements('companywebsite', 'text', $reg_errors); ?> <span class="small">(Website Optional)</span> </li> <li> <label for="email">Company Email:</label> <?php formElements('companyemail', 'text', $reg_errors); ?> </li> <li> <label for="email">Company Country:</label> <select name="CountryCode"<?php if (array_key_exists('CountryCode', $reg_errors)) echo ' class="error"'; ?>> <option>Select Country</option> <?php $q = "SELECT CountryCode, CountryName FROM Countries ORDER BY CountryName ASC"; $r = mysqli_query($dbc, $q); while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; if (isset($_POST['CountryCode']) && ($_POST['CountryCode'] == $row[0])) echo ' selected="selected"'; echo ">$row[1]</option>\n"; } ?> </select> <?php if (array_key_exists('CountryCode', $reg_errors)) echo ' <span class="errorMSG">' . $reg_errors['CountryCode'] . '</span>'; ?> </li> <li> <label for="email">Company Logo:</label> <input id="new_image" name="new_image" class="text" type="file" /> <input name="MAX_FILE_SIZE" type="hidden" value="2000000" /> <span class="small">(Logo Optional, JPG's Only)</span> </li> </ol> </fieldset> <fieldset> <legend><span>3. Job Advertisement</span></legend> <ol> <li> <label for="name">Job Title:</label> <?php formElements('jobtitle', 'text', $reg_errors); ?> <span class="small">..."Administrator", "Marketing Manager", "Web Developer"</span> </li> <li> <label for="email">Job Sector:</label> <select name="SectorID" <?php if (array_key_exists('SectorID', $reg_errors)) echo ' class="error"'; ?>> <option>Select Sector</option> <?php $q = "SELECT SectorID, SectorName FROM Sectors ORDER BY SectorName ASC"; $r = mysqli_query($dbc, $q); while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; if (isset($_POST['SectorID']) && ($_POST['SectorID'] == $row[0])) echo ' selected="selected"'; echo ">$row[1]</option>\n"; } ?> </select> <?php if (array_key_exists('SectorID', $reg_errors)) echo ' <span class="errorMSG">' . $reg_errors['SectorID'] . '</span>'; ?> </li> <li> <label for="email">Job Type:</label> <select name="jobtype" class="subject"> <option value="Please Select">Please Select</option><option value="Full Time">Full Time</option><option value="Part Time">Part Time</option><option value="Temporary">Temporary</option><option value="Contract">Contract</option> </select> </li> <li> <label for="email">Job Location:</label> <?php formElements('joblocation', 'text', $reg_errors); ?> <span class="small">..."Paris, France", "London, United Kingdom"</span> </li> <li> <label for="email">Job Description:</label> <?php formElements('JobContent', 'textarea', $reg_errors); ?> <span class="small smalllabel">..."Responsibilities, Duties, Qualifications, Benefits, No Tags"</span> </li> <li> <label for="email">How To Apply:</label> <?php formElements('JobApplyContent', 'textarea', $reg_errors); ?> <span class="small smalllabel">..."Email Address, Telephone, Address"</span> </li> </ol> </fieldset> <fieldset class="submit"> <input class="button" type="submit" value="POST JOB" /> </fieldset> </form> </article> <aside class="sideBar padding"> <h5 class="normal padding blue capitals bottom">Job Post Features</h5> <ul id="jobPost"> <li> <img src="../images/email.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE EMAIL LISTINGS</h6> <p class="padding textHeight graw">Whatever Job Type you purchased your vacancy will be put into Emails that are sent out on a daily basis as long as your vacancy is still valid.</p> </li> <li> <img src="../images/feed.png" align="left" alt="" title="" /> <h6 class="normal blue">FREE SOCIAL HUB LISTINGS</h6> <p class="padding textHeight graw">With every Job that is posted it is automatically added to our Social Networks which include <a href="http://www.flockjobs.com/feeds/jobFeed.rss" class="keyword">RSS</a>, <a href="http://www.twitter.com/flockJobs" class="keyword">Twitter</a> and <a href="http://www.facebook.com/flockJobs" class="keyword">Facebook</a> as long as your vacancy is still valid.</p> </li> <li> <img src="../images/lockblue.png" align="left" alt="" title="" /> <h6 class="normal blue">SAFE AND SECURE PAYMENT</h6> <p class="padding textHeight graw">All transactions are processed by PayPal who accept most major credit cards.</p> </li> <li> <img src="../images/clock.png" align="left" alt="" title="" /> <h6 class="normal blue">EASY AND EFFICIENT</h6> <p class="padding textHeight graw">All Job posts are posted live and instantly there is no registration and no contracts saving you time.</p> </li> </ul> </aside> </section> </section> <?php include ('../includes/footer.php'); ?> Then I have my IPN Script as below: <?php require ('http://www.flockjobs.com/jobAdmin/config.inc.php'); $file = fopen('http://www.flockjobs.com/postJobs/ipn.txt', 'a'); fwrite ($file, "Received:\n"); fwrite ($file, print_r($_POST, true)); fwrite ($file, "\n"); $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } //$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { trigger_error{'Could Not Connect For The IPN'); } else { $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; fputs ($fp, $header . $req); // Write the paypal request to the text file: fwrite ($file, "Sent:\n"); fwrite ($file, "$header\n"); fwrite ($file, "$req\n"); //Read In The Response: while (!feof($fp)) { $res = fgets ($fp, 1024); // Write the paypal response to the text file: fwrite ($file, "Received:\n"); fwrite ($file, "$res\n"); if (strcmp ($res, "VERIFIED") == 0) { //if(strcmp ($res, "VERIFIED") == 0 || 1 == 1) //Check For The Right Values if (isset($_POST['payment_status']) && ($_POST['payment_status'] == 'Completed') && ($_POST['receiver_email'] == 'customersupport@flockjobs.com') && ($_POST['mc_currency'] == 'GBP') && (!empty($_POST['mc_gross'])) && (!empty($_POST['txn_id'])) ) { require (MySQL); $txn_id = mysqli_real_escape_string($dbc, $_POST['txn_id']); $q = "SELECT OrderID FROM Orders WHERE Transaction_id='$tx_id'"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) == 0) { $companyEmail = mysqli_real_escape_string ($dbc, $_POST['email']); $jobAdvertID = (isset($_POST['custom'])) ? (int) $_POST['custom'] : 0; $status = mysqli_real_escape_string ($dbc, $_POST['payment_status']); $amount = (float) $_POST['mc_gross']; $q = "SELECT JobProducts.JobServiceID,JobAdvert.JobCode,Company.CompanyEmail FROM JobProducts,JobAdvert WHERE JobProducts.JobServiceID=JobAdvert.JobServiceID AND JobAdvert.JobAdvertID = '$JobAdvertID' AND Company.CompanyID=JobAdvert.JobAdvertID"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) == 1) { $row = mysqli_fetch_array ($r, MYSQLI_NUM); $productID = $row[0]; $jCode = $row[1]; $cEmail = $row[2]; if ($productID == 1) { $q = "INSERT INTO Orders(JobAdvertID,TransactionID,Payment_Status,Payment_Amount,Payment_Date_Time)VALUES($JobAdvertID,'$txn_id','$status','$amount',NOW())"; $r = mysqli_query($dbc, $q); if (mysqli_affected_rows($dbc) == 1) { $q = "UPDATE JobAdvert SET JobExpires = IF(JobExpires > NOW(), ADDDATE(JobExpires, INTERVAL 1 MONTH), ADDDATE(NOW(), INTERVAL 1 MONTH)) WHERE JobAdvert.JobAdvertID='$JobAdvertID'"; $r = mysqli_real_escape_string($dbc, $q); //===================================================================== $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:long="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Flockjobs.com, Step 1, Post A Job</title> <style type="text/css"> body,td,th {font-family: arial,sans-serif;font-size: 12px;} body {background-color: #F0f0f0;margin-left: 0px;margin-top: 0px;} p {color:#444;padding:0 0 0 8px;line-height:1.5em;} h4 {font-size:25;font-weight:400;color:#000000;} a{text-decoration:none;} a:hover{text-decoration:underline;} </style> </head> <body><center><br />'; $message .="<table width=\"600\" border=\"0\" bgcolor=\"#FFFFFF\" cellpadding=\"25\"> <tr> <td align=\"left\" bgcolor=\"#FFFFFF\"><br /><br /> <p> <h4>Flockjobs.com Job Advertisement</h4> </p><br /> <p> Your Job Advertisement has been completed, below you will find your links to Edit or Delete your Job post (as long as it is still valid). </p><br /> <p> <h4>Edit Your Job Advertisement</h4> </p><br /> <p> <a href=\"" . BASE_URL .'jobAccount/editJob.php?x=' . urlencode($jCode) . "&y=$cEmail\" />Edit Your Job Advertisement</a><br /><br /> If the above Edit Link does not work please copy and paste the code below into your browser address bar to activate your account:<br /><br />"; $message .= BASE_URL.'jobAccount/editJob.php?x='.urlencode($jCode)."&y=$cEmail </p><br /> <p> <h4>Delete Your Job Advertisement</h4> </p><br /> <p> <a href=\"" . BASE_URL .'jobAccount/deleteJob.php?x=' . urlencode($jCode) . "&y=$cEmail\" />Edit Your Job Advertisement</a><br /><br /> If the above Delete Link does not work please copy and paste the code below into your browser address bar to activate your account:<br /><br />"; $message .= BASE_URL.'jobAccount/deleteJob.php?x='.urlencode($jCode)."&y=$cEmail </p><br /> <p> DO NOT DELET THIS EMAIL OTHERWISE YOU WILL NOT BE ABLE TO GAIN ACCESS TO YOUR JOB ADVERTISEMENT! TO EDIT OR DELETE IT. </p><br /> <p> PLEASE NOTE: Once your Job Advertisement has been deleted it cannot be returned, if you want to re-post then you will have to re-advertise the same vacancy and then purchase another package. </p><br /> <p> Yours Sincerely<br /><br />flockjobs.com </p> </tr> </table><br /></center></body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .='From: Flockjobs.com <customersupport@flockjobs.com>' . "\r\n" . 'Reply-To: Admin@webzoost.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($companyEmail,'Flockjobs, Step 1, Post A Job',$message,$headers); //===================================================================== if (mysqli_affected_rows($dbc, $q) != 1) { trigger_error('The User\'s expiration date could not be updated'); } } else { trigger_error('Problem Inserting Order'); } } elseif ($productID == 2) { $q = "INSERT INTO Orders(JobAdvertID,TransactionID,Payment_Status,Payment_Amount,Payment_Date_Time)VALUES($JobAdvertID,'$txn_id','$status','$amount',NOW())"; $r = mysqli_query($dbc, $q); if (mysqli_affected_rows($dbc) == 1) { $q = "UPDATE JobAdvert SET JobExpires = IF(JobExpires > NOW(), ADDDATE(JobExpires, INTERVAL 14 DAY), ADDDATE(NOW(), INTERVAL 14 DAY)) WHERE JobAdvert.JobAdvertID='$JobAdvertID'"; $r = mysqli_real_escape_string($dbc, $q); //===================================================================== $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:long="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Flockjobs.com, Step 1, Post A Job</title> <style type="text/css"> body,td,th {font-family: arial,sans-serif;font-size: 12px;} body {background-color: #F0f0f0;margin-left: 0px;margin-top: 0px;} p {color:#444;padding:0 0 0 8px;line-height:1.5em;} h4 {font-size:25;font-weight:400;color:#000000;} a{text-decoration:none;} a:hover{text-decoration:underline;} </style> </head> <body><center><br />'; $message .="<table width=\"600\" border=\"0\" bgcolor=\"#FFFFFF\" cellpadding=\"25\"> <tr> <td align=\"left\" bgcolor=\"#FFFFFF\"><br /><br /> <p> <h4>Flockjobs.com Job Advertisement</h4> </p><br /> <p> Your Job Advertisement has been completed, below you will find your links to Edit or Delete your Job post (as long as it is still valid). </p><br /> <p> <h4>Edit Your Job Advertisement</h4> </p><br /> <p> <a href=\"" . BASE_URL .'jobAccount/editJob.php?x=' . urlencode($jCode) . "&y=$cEmail\" />Edit Your Job Advertisement</a><br /><br /> If the above Edit Link does not work please copy and paste the code below into your browser address bar to activate your account:<br /><br />"; $message .= BASE_URL.'jobAccount/editJob.php?x='.urlencode($jCode)."&y=$cEmail </p><br /> <p> <h4>Delete Your Job Advertisement</h4> </p><br /> <p> <a href=\"" . BASE_URL .'jobAccount/deleteJob.php?x=' . urlencode($jCode) . "&y=$cEmail\" />Edit Your Job Advertisement</a><br /><br /> If the above Delete Link does not work please copy and paste the code below into your browser address bar to activate your account:<br /><br />"; $message .= BASE_URL.'jobAccount/deleteJob.php?x='.urlencode($jCode)."&y=$cEmail </p><br /> <p> DO NOT DELET THIS EMAIL OTHERWISE YOU WILL NOT BE ABLE TO GAIN ACCESS TO YOUR JOB ADVERTISEMENT! TO EDIT OR DELETE IT. </p><br /> <p> PLEASE NOTE: Once your Job Advertisement has been deleted it cannot be returned, if you want to re-post then you will have to re-advertise the same vacancy and then purchase another package. </p><br /> <p> Yours Sincerely<br /><br />flockjobs.com </p> </tr> </table><br /></center></body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .='From: Flockjobs.com <customersupport@flockjobs.com>' . "\r\n" . 'Reply-To: Admin@webzoost.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($companyEmail,'Flockjobs, Step 1, Post A Job',$message,$headers); //===================================================================== if (mysqli_affected_rows($dbc, $q) != 1) { trigger_error('The User\'s expiration date could not be updated'); } } else { trigger_error('Problem Inserting Order'); } } else { $q = "INSERT INTO Orders(JobAdvertID,TransactionID,Payment_Status,Payment_Amount,Payment_Date_Time)VALUES($JobAdvertID,'$txn_id','$status','$amount',NOW())"; $r = mysqli_query($dbc, $q); if (mysqli_affected_rows($dbc) == 1) { $q = "UPDATE JobAdvert SET JobExpires = IF(JobExpires > NOW(), ADDDATE(JobExpires, INTERVAL 7 DAY), ADDDATE(NOW(), INTERVAL 7 DAY)) WHERE JobAdvert.JobAdvertID='$JobAdvertID'"; $r = mysqli_real_escape_string($dbc, $q); //===================================================================== $message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:long="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Flockjobs.com, Step 1, Post A Job</title> <style type="text/css"> body,td,th {font-family: arial,sans-serif;font-size: 12px;} body {background-color: #F0f0f0;margin-left: 0px;margin-top: 0px;} p {color:#444;padding:0 0 0 8px;line-height:1.5em;} h4 {font-size:25;font-weight:400;color:#000000;} a{text-decoration:none;} a:hover{text-decoration:underline;} </style> </head> <body><center><br />'; $message .="<table width=\"600\" border=\"0\" bgcolor=\"#FFFFFF\" cellpadding=\"25\"> <tr> <td align=\"left\" bgcolor=\"#FFFFFF\"><br /><br /> <p> <h4>Flockjobs.com Job Advertisement</h4> </p><br /> <p> Your Job Advertisement has been completed, below you will find your links to Edit or Delete your Job post (as long as it is still valid). </p><br /> <p> <h4>Edit Your Job Advertisement</h4> </p><br /> <p> <a href=\"" . BASE_URL .'jobAccount/editJob.php?x=' . urlencode($jCode) . "&y=$cEmail\" />Edit Your Job Advertisement</a><br /><br /> If the above Edit Link does not work please copy and paste the code below into your browser address bar to activate your account:<br /><br />"; $message .= BASE_URL.'jobAccount/editJob.php?x='.urlencode($jCode)."&y=$cEmail </p><br /> <p> <h4>Delete Your Job Advertisement</h4> </p><br /> <p> <a href=\"" . BASE_URL .'jobAccount/deleteJob.php?x=' . urlencode($jCode) . "&y=$cEmail\" />Edit Your Job Advertisement</a><br /><br /> If the above Delete Link does not work please copy and paste the code below into your browser address bar to activate your account:<br /><br />"; $message .= BASE_URL.'jobAccount/deleteJob.php?x='.urlencode($jCode)."&y=$cEmail </p><br /> <p> DO NOT DELET THIS EMAIL OTHERWISE YOU WILL NOT BE ABLE TO GAIN ACCESS TO YOUR JOB ADVERTISEMENT! TO EDIT OR DELETE IT. </p><br /> <p> PLEASE NOTE: Once your Job Advertisement has been deleted it cannot be returned, if you want to re-post then you will have to re-advertise the same vacancy and then purchase another package. </p><br /> <p> Yours Sincerely<br /><br />flockjobs.com </p> </tr> </table><br /></center></body> </html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .='From: Flockjobs.com <customersupport@flockjobs.com>' . "\r\n" . 'Reply-To: Admin@webzoost.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($companyEmail,'Flockjobs, Step 1, Post A Job',$message,$headers); //===================================================================== if (mysqli_affected_rows($dbc, $q) != 1) { trigger_error('The User\'s expiration date could not be updated'); } } else { trigger_error('Problem Inserting Order'); } } } } // Order Has Already Been Stored } // Right Values Don't Exist } elseif (strcmp ($res, "INVALID") == 0) { //Log For Manual Investigation } } // End of While Loop //Close The Connection fclose ($fp); } // End fp Connection fwrite ($file, "-------------------------------------------------\n"); fclose ($file); ?> And here is the paypal description of the problem: Message ID0FB64761XU9543332 Date/time created07/07/2011 11:04 BST Original/ResentOriginal Latest delivery attempt date/time07/07/2011 11:25 BST Notification HTTP response code 404 Delivery statusRetrying No. of retries8 Transaction ID1PN79280FG9078117 IPN typeTransaction made Hope it helps, I am just wondering if the SQL queries in the IPN script are working properly, any help would be much appreciated Link to comment Share on other sites More sharing options...
abigail Posted July 7, 2011 Share Posted July 7, 2011 I think either at PayPal you defined the wrong url for your script or the ipn.php file is not sitting in the right place. What happens when you type in the sitename.com/ipn.php to your browser. It should show a blank page and you can also put in debugging such as send yourself email. Link to comment Share on other sites More sharing options...
MrJames Posted July 7, 2011 Author Share Posted July 7, 2011 Hi, When I type in the URL on its own I get Internal Server Error / HTTP 500, so I am just wondering if it is something to do with the queries in the actual IPN script. The database didn't update nor did it insert the required information. I have my IPN script in a subfolder below the main domain, so would that make any difference ? Kind Regards I think either at PayPal you defined the wrong url for your script or the ipn.php file is not sitting in the right place. What happens when you type in the sitename.com/ipn.php to your browser. It should show a blank page and you can also put in debugging such as send yourself email. Link to comment Share on other sites More sharing options...
abigail Posted July 7, 2011 Share Posted July 7, 2011 I don't think you are even getting to your script. That is your problem. I think that 500 error might be because your directory is password protected, or a similar error to that. Link to comment Share on other sites More sharing options...
MrJames Posted July 8, 2011 Author Share Posted July 8, 2011 I don't think you are even getting to your script. That is your problem. I think that 500 error might be because your directory is password protected, or a similar error to that. Hi, My Directories are not password protected though, could it be my SQL queries or the fact that the IPN script is in a sub-folder, and also what about http | https issues since in my config script i have the base url set as http first ? Would a session also work from a user entering job details then going through the paypal gateway and then being made available on the ipn script ? Look forward to your advice and help Kind Regards Link to comment Share on other sites More sharing options...
Larry Posted July 8, 2011 Share Posted July 8, 2011 I think you're overcomplicating this. As Abigail said, you need to be able to access www.example.com/ipn.php (or whatever the correct path and filename are) directly in your browser. This is the same as if it were any other PHP script. Understand what the proper URL is first, make sure that loads without error, then make sure PayPal has that proper URL. Link to comment Share on other sites More sharing options...
MrJames Posted July 8, 2011 Author Share Posted July 8, 2011 I think you're overcomplicating this. As Abigail said, you need to be able to access www.example.com/ipn.php (or whatever the correct path and filename are) directly in your browser. This is the same as if it were any other PHP script. Understand what the proper URL is first, make sure that loads without error, then make sure PayPal has that proper URL. Okay Larry, I hear what you are saying, but from past experiences the only time I have really had HTTP 500 internal server errors is when a query has not been done properly or theirs a problem with the php code(NOT the URLS) ? The only only thing I can think of is the HTTP | HTTPS problems. Link to comment Share on other sites More sharing options...
abigail Posted July 8, 2011 Share Posted July 8, 2011 Larry is right Mr James. Do as he says first. Recently I had a 500 error and the only reason was my directory was password protected. When I updated the user/password it worked. Maybe there are other reasons to get a 500 error. After you can access your script and verify your url with PayPal then worry about what else might be wrong. Link to comment Share on other sites More sharing options...
Larry Posted July 9, 2011 Share Posted July 9, 2011 Hello James. I'm not saying you're wrong, because you've seen what you think you've seen, but based upon what I know, it makes no sense at all that query errors in a PHP script would case a 500 error. In 12 years of PHP development, I've never seen a problem with a PHP script's queries causing a 500 error. Link to comment Share on other sites More sharing options...
MrJames Posted July 9, 2011 Author Share Posted July 9, 2011 Hello James. I'm not saying you're wrong, because you've seen what you think you've seen, but based upon what I know, it makes no sense at all that query errors in a PHP script would case a 500 error. In 12 years of PHP development, I've never seen a problem with a PHP script's queries causing a 500 error. Hi, As always I appreciate your input/views and opinions. I got in touch with my webhosting provider and they tell me its a shared hosting package and their is a certain URL you have to use. Now if I change my IPN script URL in paypal will that always try the old URL instead of the new one my hosting package gave me ? So I'll have to try and carry out another transaction with the new URL ? As always thanks for your help... Link to comment Share on other sites More sharing options...
Recommended Posts