forum

Home / DeveloperSection / Forums / How to submit form to controller or model in mvc?

How to submit form to controller or model in mvc?

Anonymous User247509-Nov-2014

I'm trying to apply a simple MVC pattern to my current website without any frameworks. Since i haven't really gotten into oop yet im still using procedural at the moment.

I have a simple login form (view)

<formaction="controller/login.php"method="Post"><inputtype="text"name="username"placeholder="Username"/><inputtype="text"name="password"placeholder="Password"/><inputtype="submit"value="Sign in"/></form>

this form will submit to the controller for login form. Controller will now check if both fields have inputs and "cleanse" more or less the input

if(isset($_POST['username'])){ $username = $_POST['username']; $password = $_POST['password']; $username_escape = mysqli_real_escape_string($connect, $username); $password_escape = mysqli_real_escape_string($connect, $password);} header("../model/login.php");

this is a really simple check right now however i was now wondering should i include controller into model and redirect to model from controller or form submit it at first place and have controller included.

Model

include_once("../controller/login.php"); $query = mysqli_query($connect,"INSERT into DB_table (username, password) VALUES($username_escape, $password_escape)");

Updated on 10-Nov-2014
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By