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 8824603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:40:29+00:00 2026-06-14T06:40:29+00:00

Each time I post some info from my web app to the server i

  • 0

Each time I post some info from my web app to the server i send it to a PHP file. this php file then calls a function that put the info into the database. This is the general idea right ? 🙂

The only problem is that I find myself creating a php file for each function call! I have one for creating a “task”, one for creating a “user” one for toggleing a variable, one for setting a variable …..etc.

I don’t know how else to do it. Even though I keep all my PHP database functions in one file, I find that I have to make a new file for each post call I do.

Example 1:

<?php
include 'databasefunctions.php';
inserttaskDB();
?>-

Example 2:

<?php
include 'databasefunctions.php';
inserthelpoffers($_POST[task_id],$_SESSION[id],$_POST[help_offer]);
?>

I find that I’m organizing my code badly. How can I better organize my code?

  • 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-14T06:40:31+00:00Added an answer on June 14, 2026 at 6:40 am

    I think I know what you are doing. When you send a post request to a php page via your app ypu call a function in that file to store the data into db. The problem seems to be you send this post request to multiple PHP files instead of one. So here is a quick fix for this.

    //I believe your databasefunctions.php has all the functions like
    function inserttaskDB($task){
       //SQL query to insert
    }
    
    function inserthelpoffers($taskId,$id,$helper){
       // SQL query to insert helper offer
    }
    

    Now what you can do is have only one file like getDataFromMobile.php
    so when you send data to getDataFromMobile send one more variable called func(for function)

    //Now in your getDataFromMobile you can use a switch statement
    
    $functionName = $_POST["func"];
    
    switch($functionName){
        case "inserttaskDB":
            //Gets all your post iformation here and call the respective function
        break;
        case "inserthelpoffers":
          inserthelpoffers($_POST[task_id],$_SESSION[id],$_POST[help_offer]);
        break;
    }
    

    This is a very quick fix. I personally would tend towards OOP in such cases.

    Hope this helps,
    Dins

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

Sidebar

Related Questions

I want to make the time of each post to change in realTime. This
Each time my user signs in, we pull his profile picture from Facebook. This
My app should post some message to Twitter at the end of each day
I want my program to get notification each time someone makes a post to
I'm trying to make a post, however each time I did it, I would
Each time I make changes to XML file and press run button, It generates
I have a Post, Comment and Vote model Each time an instance of Vote
So I am executing a $.post() to get some html code returned from a
When I POST some images to my server using: ASIFormDataRequest *request = [[ASIFormDataRequest alloc]
I have Post and Comment model. I want to achieve the following: Each time

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.