Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8140341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:07:53+00:00 2026-06-06T12:07:53+00:00

I am new to OO php so this may seem basic.. Basically I have

  • 0

I am new to OO php so this may seem basic..

Basically I have a list of courses a user can book. I have got it so the user can remove the course from their list, but I want a message to be displayed to them after they delete. I have done something similar to what I want here:

<form name="removecourse" action="<?php bloginfo('url');?>/user/<?php echo $current_user->first_name ; ?>" method="post">
<input type="hidden" value="<?php the_id();?>" name="courseid" />
<input id="removebutton" type="submit" name="removecourse" value="Remove">
</form>

The form sends the required data to the same page, and at the top of that page is a check to see if the forms post name is present in $_POST[] like so:

    if(isset($_POST['removecourse']) && !empty($_POST['removecourse'])){        
    $courseManager->delete_post($_POST['courseid'], $_POST['cancel-reason']);
    echo $courseManager->delete_response;
}; 

This is where the Class and object part comes in…

    public $delete_response;

function delete_post($postid, $reason){

     //stuff to actually delete the post

    $this->delete_response = 'Thanks, your course has been removed.';

}

So here I am adding a value to the delete_response variable and calling it above at the top of the page. This works, but when I refresh the page the message is still there as I am resubmitting the POST. I am just wondering if what I am doing is along the right track, and how to implement a Post/Redirect/Get type functionallity to stop the messaage from appearing on page refresh?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T12:07:56+00:00Added an answer on June 6, 2026 at 12:07 pm

    You have to check, either your course has been already deleted, is it simple as that :).

    Yours displaying it again because:

    if(isset($_POST['removecourse']) && !empty($_POST['removecourse'])){
    //is always true when posted again. 
    }
    

    You have to check the existiance

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This may be a silly question, but as someone relatively new to PHP, I'm
New to PHP and MySQL, have heard amazing things about this website from Leo
I think this is mostly because I'm new to PHP OOP, but I have
This question may seem a bit stupid, but i'm new to Joomla! And i
I'm new to PHP and this may be a stupid question to ask, so
This may be a dumb question, but I can't seem to find an answer
This may seem like a basic question, but I am not getting how to
Currently, I have this line: $.post(submitmail.php, $(#contactform).serialize(), recvMailStatus); I'm new to jQuery so this
This may seem totally unreasonable to ask, but I have been designing a multi-panel,
Yes I have seen This question But it's for php. I'm still new to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.