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

  • Home
  • SEARCH
  • 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 8182365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:50:28+00:00 2026-06-07T00:50:28+00:00

I´m building a small application with Jquery and PHP. Jquery (index.html) adds Form Fields

  • 0

I´m building a small application with Jquery and PHP. Jquery (index.html) adds Form Fields for the User and sends those to a PHP Script (pdo.php). The PHP Script fetches Values from the Database and does some calculations with the User given Values and the Values from the DB. The sum is returned to the Form Page.

index.html <-> pdo.php

Thus I am trying to understand the PHP MVC pattern my question is if

a.) this would make sense in this case.

b.) if so, which part would be what. index.html –> view; pdo.php –> model; controller –> ?

thanks for your help,

tony

Cut-out

jquery … index.html

$(document).ready(function(){
    $("#buttonAjax").click(function(){
        var name = encodeURI($("#name").val());

            $.ajax({
                type: "POST",
                url: "pdo.php",
                data: "name="+name,
                success: function(data){
                    var json = $.parseJSON(data);
                    $("#output").html(json.summe);
                    talk(json.say);
                }
            });

    });

    function talk (say){
        jQuery.noticeAdd({text: say,stay: false});
    }

     });

pdo.php

/* DB Connection */
    $strDbLocation = 'mysql:dbname=test;host=localhost';
    $strDbUser = 'root';
    $strDbPassword = 'root';

    try{
        $objDb = new PDO($strDbLocation, $strDbUser, $strDbPassword);
    }
    catch (PDOException $e){
        echo 'Failure: ' . $e->getMessage();
    }


/* Fetch POST Data */
    $id = $_POST['name'];


/* Build query */
    $dbSelect =  $objDb->prepare("SELECT Age,Name FROM Benutzer WHERE id = :id");
    $dbSelect -> setFetchMode(PDO::FETCH_ASSOC);  
    $dbSelect -> bindParam('id', $id);
    $dbSelect -> execute();


/* Output + Calculate */    
    while($row = $dbSelect->fetch()) {  
        $total =  $row['Age'] / 100 . "<br />";
    }  


/* Return to User */
    if(!empty($total)){ 
        $ret = Array("summe" => "Summe: " . $total, "say" => "all right");
        echo json_encode($ret); }
    else{
        $ret = Array("summe" => "Nothing for you",  "say" => "nothing for you");
        echo json_encode($ret); 
    }
  • 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-07T00:50:31+00:00Added an answer on June 7, 2026 at 12:50 am

    In a standard MVC webapp, routes are matched to controller actions. These controller actions may interface with the Model [which in turn interfaced with the database] or performs some other Model-agnostic calculations, and renders a view. It is obvious that the index.html is the view. And I think you have the controller and the model bundled up in pdo.php.

    I really recommend PeeHaa’s link in the comments. That answer is well written.

    That been said, there are many architectural patterns to making a webapp. Yours may not be MVC. Some prominent frameworks that aren’t MVC are SproutCore (View-based controllers) and JSP pages (single controller).

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

Sidebar

Related Questions

I am about to begin building a small application for a user to manage
I am currently building a small web application for publishing stories using PHP and
I'm building a small HTML/JS application for primary use on local machine (i.e. everything
I'm building a very small web ERP application with PHP / mySQL / CodeIgniter
I 'am building a small windows form application. I have a View - a
I am building a small windows form application in C#. Within the form code
I am building a small web application, where the user is granted the ability
I am building a small application in RoR that has a form asking for
Currently I am building a small application that allows a user to sign in
I'm building a small application that highly depends on anonymous user voting on some

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.