Hey guys,
Got this wordpress script which is bugging out for me :/
function JobBoard_admin_add() {
?>
<div class="wrap">
<?php
$con=mysqli_connect("localhost","profiled_job","","profiled_jobboard");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO details (Employer,
LearningProvider,
ContractedProvider,
LearningDeliverySite,
VacancyDescription,
VacancyTitle,
EmployerDescription,
VacancyLocation,
NoVacancies,
VacancyRefNumber,
ClosingDateForApplications,
InterviewBeginFrom,
PossibleStartDate,
TrainingToBeProvided,
LearningProviderDescription,
ContactDetails,
VacancyType,
ApprenticeshipFramework,
SkillsRequired,
PersonalQualities,
ImportantOtherInformation,
Website)
VALUES
('$_POST[jobboard_companyname]','$_POST[jobboard_learningprovider]','$_POST[jobboard_contractedprovider]','$_POST[jobboard_deliverysite]','$_POST[jobboard_vdesc]','$_POST[jobboard_title]','$_POST[jobboard_edesc]','$_POST[jobboard_vacloc]','$_POST[jobboard_novac]','$_POST[jobboard_refno]','$_POST[jobboard_closingdate]','$_POST[jobboard_interviewbegin]','$_POST[jobboard_startdate]','$_POST[jobboard_trainingprovided]','$_POST[jobboard_providerdesc]','$_POST[jobboard_contact]','$_POST[jobboard_vactype]','$_POST[jobboard_framework]','$_POST[jobboard_skillsreq]','$_POST[jobboard_personalqualities]','$_POST[jobboard_importantotherinfo]','$_POST[jobboard_website]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>
<?php
if($_POST['JobBoard_hidden'] == 'Y') {
if($_POST['jobboard_companyname'] != '') {
//Form data sent
echo "Sent Data";
?>
<div class="updated"><p><strong><?php _e('Options saved.' ); ?></strong></p></div>
<?php
}} else {
//Normal page display
echo "Didnt send data";
}
?>
<?php echo "<h2>" . __( 'JobBoard', 'JobBoard_trdom' ) . "</h2>"; ?>
<form name="jobboard_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
<input type="hidden" name="JobBoard_hidden" value="Y">
<p><?php _e("Company Name: " ); ?><input type="text" name="jobboard_companyname" value="" size="20"></p>
<p><?php _e("Learning Provider: " ); ?><input type="text" name="jobboard_learningprovider" value="" size="20"></p>
<p><?php _e("Contracted Provider: " ); ?><input type="text" name="jobboard_contractedprovider" value="" size="20"></p>
<p><?php _e("Learning Delivery Site: " ); ?><input type="text" name="jobboard_deliverysite" value="" size="20"></p>
<p><?php _e("vacancy Description: " ); ?><input type="text" name="jobboard_vdesc" value="" size="20"></p>
<p><?php _e("Vacancy Title: " ); ?><input type="text" name="jobboard_title" value="" size="20"></p>
<p><?php _e("Employer Description: " ); ?><input type="text" name="jobboard_edesc" value="" size="20"></p>
<p><?php _e("Vacancy Location: " ); ?><input type="text" name="jobboard_vacloc" value="" size="20"></p>
<p><?php _e("No Vacancies: " ); ?><input type="text" name="jobboard_novac" value="" size="20"></p>
<p><?php _e("Vacancy Ref Number: " ); ?><input type="text" name="jobboard_refno" value="" size="20"></p>
<p><?php _e("Closing Date for Applicants: " ); ?><input type="text" name="jobboard_closingdate" value="" size="20"></p>
<p><?php _e("Interview Begin From: " ); ?><input type="text" name="jobboard_interviewbegin" value="" size="20"></p>
<p><?php _e("Possible Start Date: " ); ?><input type="text" name="jobboard_startdate" value="" size="20"></p>
<p><?php _e("Training to be provided: " ); ?><input type="text" name="jobboard_trainingprovided" value="" size="20"></p>
<p><?php _e("Learning Provider Description: " ); ?><input type="text" name="jobboard_providerdesc" value="" size="20"></p>
<p><?php _e("Contact Details: " ); ?><input type="text" name="jobboard_contact" value="" size="20"></p>
<p><?php _e("Vacancy Type: " ); ?><input type="text" name="jobboard_vactype" value="" size="20"></p>
<p><?php _e("Apprenticeship Framework: " ); ?><input type="text" name="jobboard_framework" value="" size="20"></p>
<p><?php _e("Skills Required: " ); ?><input type="text" name="jobboard_skillsreq" value="" size="20"></p>
<p><?php _e("Personal Qualities: " ); ?><input type="text" name="jobboard_personalqualities" value="" size="20"></p>
<p><?php _e("Important Other Information: " ); ?><input type="text" name="jobboard_importantotherinfo" value="" size="20"></p>
<p><?php _e("Website: " ); ?><input type="text" name="jobboard_website" value="" size="20"></p>
<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Update Options', 'jobboard_trdom' ) ?>" />
</p>
</form>
</div>
<?php
}
The problem is, when I submit, it submits the correct info into the database but as it goes back onto the page it submits the empty form.
Same as when I click on the page.
I've added if $_POST != ''; but that still doesn't work.
any guidance in this matter would be much appreciated :)