Hey guys,

Had a problem with Wordpress. When I click submit on a form for a plugin I made it says "insufficient permissions" So I can see that being a problem. I decided it might be best to use PHP_SELF.

Just a question really.

At the moment it is 3 forms. With different actions.

<form method="post" action="deleteuser_ac.php">
<form method="post" action="adduser_ac.php">
<form method="post" action="updateuser_ac.php">

How do I make it so when I click submit it does it all on that page and executes that code rather than going to an external page?

Thanks :)

4 Years
Discussion Span
Last Post by bradly.spicer

Use three different names for submit buttons. Then in the processing part of the code check which submit button has been pressed:

if(isset($_POST['submit_delete'])) {
    //code for deleting 
} elseif(isset($_POST['submit_add']) {
    // code for adding
} elseif(isset($_POST['submit_update']) {
    // code for updating

Yes, if it returns the scriptname (I think it depends on globals on setting). You can also use $_SERVER['PHP_SELF'].


Here's a little hiccup.


if(isset($_POST['submit_delete'])) {

            $sql= (mysqli_query($con, "Delete FROM details WHERE ID = '$id'"));
           echo "Data Deleted";
        } else {
           echo "Data Not Deleted";
} elseif(isset($_POST['submit_add']) {

// Get values from form 
    $value_Employer = $_POST["Employer"];
    $value_LearningProvider = $_POST["LearningProvider"];
    $value_ContractedProvider = $_POST["ContractedProvider"];
    $value_LearningDeliverySite = $_POST["LearningDeliverySite"];
    $value_VacancyDescription = $_POST["VacancyDescription"];
    $value_VacancyTitle = $_POST["VacancyTitle"];
    $value_EmployerDescription = $_POST["EmployerDescription"];
    $value_VacancyLocation = $_POST["VacancyLocation"];
    $value_WorkingWeek = $_POST["WorkingWeek"];
    $value_WeeklyWage = $_POST["WeeklyWage"];
    $value_NoVacancies = $_POST["NoVacancies"];
    $value_VacancyRefNumber = $_POST["VacancyRefNumber"];
    $value_ClosingDateForApplications = $_POST["ClosingDateForApplications"];
    $value_InterviewBeginFrom = $_POST["InterviewBeginFrom"];
    $value_PossibleStartDate = $_POST["PossibleStartDate"];
    $value_TrainingToBeProvided = $_POST["TrainingToBeProvided"];
    $value_LearningProviderDescription = $_POST["LearningProviderDescription"];
    $value_ContactDetails = $_POST["ContactDetails"];
    $value_VacancyType = $_POST["VacancyType"];
    $value_ApprenticeshipFramework = $_POST["ApprenticeshipFramework"];
    $value_SkillsRequired = $_POST["SkillsRequired"];  
    $value_PersonalQualities = $_POST["PersonalQualities"];  
     $value_ImportantOtherInformation = $_POST["ImportantOtherInformation"];  
     $value_Website = $_POST["Website"];

// Insert data into mysql 
$sql="INSERT INTO $tbl_name(Employer, LearningProvider, ContractedProvider, LearningDeliverySite, VacancyDescription, VacancyTitle, EmployerDescription, VacancyLocation, WorkingWeek, WeeklyWage, NoVacancies, VacancyRefNumber, ClosingDateForApplications, InterviewBeginFrom, PossibleStartDate, TrainingToBeProvided, LearningProviderDescription, ContactDetails, VacancyType, ApprenticeshipFramework, SkillsRequired, PersonalQualities, ImportantOtherInformation, Website)VALUES('$value_Employer', '$value_LearningProvider', '$value_ContractedProvider', '$value_LearningDeliverySite', '$value_VacancyDescription', '$value_VacancyTitle', '$value_EmployerDescription', '$value_VacancyLocation', '$value_WorkingWeek', '$value_WeeklyWage', '$value_NoVacancies', '$value_VacancyRefNumber', '$value_ClosingDateForApplications', '$value_InterviewBeginFrom', '$value_PossibleStartDate', '$value_TrainingToBeProvided', '$value_LearningProviderDescription', '$value_ContactDetails', '$value_VacancyType', '$value_ApprenticeshipFramework', '$value_SkillsRequired', '$value_PersonalQualities', '$value_ImportantOtherInformation', '$value_Website')";

// if successfully insert data into database, displays message "Successful". 
echo "Successful";
echo "<BR>";

else {
echo "ERROR";
echo $sql;

} elseif(isset($_POST['submit_update']) {
    // code for updating


Parse error: syntax error, unexpected '{' in /home/profiled/public_html/wp-content/plugins/job-board/Admin.php on line 51

in the snippet above it's line 13.


You are actually missing one parenthesis in line 13. This is the correct code:

} elseif(isset($_POST['submit_add'])) {

(sorry, my mistake in the code example).

Edited by broj1


Thanks mate, not your fault. I shouldn't have overlooked something that simple haha. Slap bang right infront of my face!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.