Build a MVC Application

+1 Dennis Siaw · January 29, 2015
This might be somewhat basic, but can someone clarify it for me?
The tutorial only talked of $_GET data or variables.
How do you pass $_POST data?

I will be most grateful

Post a Reply


Oldest  Newest  Rating
+1 ludwig fourie · January 29, 2015
They use the $_GET data normally to get the URL to the correct page you are using. You can't let a user user the $_POST as post is hidden from the user, so how will he or she enter the address of you web site when it is hidden? That is why they use get...

You can use post for your form or data to your controller, this is very different from from using get from the url. 
0 Dennis Siaw · January 30, 2015
Thanks ludwig!
So i want to know how to pass post data from a form possibly through ajax to the controller class.


I seriously need help!!
0 ludwig fourie · February 1, 2015
Well Deniis, I must be honest with you, I am still learning MVC, so not to sure yet, but you can sent your request to the index.php and just get the right class and method from there, as you create a .htaccess file that sends your url detail to the route.php, you can simply get it right from there...

Let me know if this helps my friend
+1 Ron Butcher · February 1, 2015
The way that I have done it is to create a controller called process.  All of my forms are submitted to that class along with the method I want to call for that specific form.

<form action="/process/formName">
<input type="text" id="item1" name="item1" />
   <!--  Additional Form Code -->

In your class you can filter out your POST data

class Process extends Controller
public function formName()
$item1 = $_POST['item1'];
// Additional code

You can submit forms via Ajax the same way, by sending it to the same URL.
I am not sure that this is the most efficient way, but it has worked for me so far.
0 Dennis Siaw · February 6, 2015
@Ron Butcher. Your answer works perfect but i encountered a problem on the way, so i stopped using the whole approach
I had to go by my own since i need to finish this one urgently.

Maybe i would take a second look at it later

Thanks to you all
  • 1



Server-side, HTML embedded scripting language used to create dynamic Web pages.