Web Application Help needed

SohaibArif

Proficient
Apr 10, 2008
666
0
21
Karach,i Pakistan
Salams,
I am making an inventory management web app as a personal project and I need help with deciding on the back end.

Firstly, I have no formal training in web development, I used the missing manual php book and Rob Percival's udemy course to make my FYP and am only using free online resources, mostly Youtube, to continue the learning parts of this.

I am currently using a kind of fake REST api as PUT and DELETE requests give a 405 "Request not allowed" error. So I did used POST and some flags( I don't know the proper term if there is one) like this instead:

PHP:
if($_SERVER['REQUEST_METHOD'] == 'POST')
    {
        require_once('../../../scripts/database_connection.php');
        if(isset($_POST["edit_id"]) && isset($_POST["name"]) && isset($_POST["description"]))
        {
            $id = trim(mysqli_real_escape_string($link, $_POST["edit_id"]));
            $name = trim(mysqli_real_escape_string($link, $_POST["name"]));
            $description = trim(mysqli_real_escape_string($link, $_POST["description"]));
            
            $data = edit_item($link, $id, $name, $description);
            deliver_response(200,"item edited", $data);            
        }
        else if(!isset($_POST["edit_id"]) && isset($_POST["name"]) && isset($_POST["description"]))
        {            
            $name = trim(mysqli_real_escape_string($link, $_POST["name"]));
            $description = trim(mysqli_real_escape_string($link, $_POST["description"]));
            
            $data = add_item($link, $name, $description);
            deliver_response(200,"item added", $data);
            
        }
        else if(isset($_POST['delete_id']))
        {
            $id = trim(mysqli_real_escape_string($link, $_POST["delete_id"]));
            $data = delete_item($link, $id);
            deliver_response(200,"item deleted", $data);
        }
        else
        {
            deliver_response(200,"NO DATA ENTERED",NULL);
        }
    }
It is working perfectly but he problem is, more complex data is to be retrieved and sent later and I am not sure I should continue with this messy kind of solution.

Error handling is also a mess for me in PHP/javascript as I don't know any if tools exist for it. I mistakenly used mysql_query instead of mysqli_query due to notepad++'s built in suggessions and spent almost an hour before figuring out why the edit_item function was not working. I really don't want to run into that kind of stupidity again.

Writing so much code to just get some simple data also seems like I am doing something wrong.

I could abandon the PHP version and start on ASP.net or Java or even learn Ruby but then the problem is with hosting the back end but then hosting may become a problem.

Can someone suggest how I continue this?
 

gullfounder

Phoenix Dawn
Supervisor
Aug 25, 2008
970
3
24
Khanpur
Salams,
I am making an inventory management web app as a personal project and I need help with deciding on the back end.

Firstly, I have no formal training in web development, I used the missing manual php book and Rob Percival's udemy course to make my FYP and am only using free online resources, mostly Youtube, to continue the learning parts of this.

I am currently using a kind of fake REST api as PUT and DELETE requests give a 405 "Request not allowed" error. So I did used POST and some flags( I don't know the proper term if there is one) like this instead:

PHP:
if($_SERVER['REQUEST_METHOD'] == 'POST')
    {
        require_once('../../../scripts/database_connection.php');
        if(isset($_POST["edit_id"]) && isset($_POST["name"]) && isset($_POST["description"]))
        {
            $id = trim(mysqli_real_escape_string($link, $_POST["edit_id"]));
            $name = trim(mysqli_real_escape_string($link, $_POST["name"]));
            $description = trim(mysqli_real_escape_string($link, $_POST["description"]));
            
            $data = edit_item($link, $id, $name, $description);
            deliver_response(200,"item edited", $data);            
        }
        else if(!isset($_POST["edit_id"]) && isset($_POST["name"]) && isset($_POST["description"]))
        {            
            $name = trim(mysqli_real_escape_string($link, $_POST["name"]));
            $description = trim(mysqli_real_escape_string($link, $_POST["description"]));
            
            $data = add_item($link, $name, $description);
            deliver_response(200,"item added", $data);
            
        }
        else if(isset($_POST['delete_id']))
        {
            $id = trim(mysqli_real_escape_string($link, $_POST["delete_id"]));
            $data = delete_item($link, $id);
            deliver_response(200,"item deleted", $data);
        }
        else
        {
            deliver_response(200,"NO DATA ENTERED",NULL);
        }
    }
It is working perfectly but he problem is, more complex data is to be retrieved and sent later and I am not sure I should continue with this messy kind of solution.

Error handling is also a mess for me in PHP/javascript as I don't know any if tools exist for it. I mistakenly used mysql_query instead of mysqli_query due to notepad++'s built in suggessions and spent almost an hour before figuring out why the edit_item function was not working. I really don't want to run into that kind of stupidity again.

Writing so much code to just get some simple data also seems like I am doing something wrong.

I could abandon the PHP version and start on ASP.net or Java or even learn Ruby but then the problem is with hosting the back end but then hosting may become a problem.

Can someone suggest how I continue this?
Well, I am not the the pro in PHP. but i can tell you this is that, you need to create objects. Like Functions in C that should do the repeated task. and Group then in a Class. So, you wont have to write the code again and again. This will help you alot in Long run. But in start yes that will take time. But Once the foundation are built. Its easy to create anything on it.

For Example.

You could create a function that will insert data into any given table. So, when ever u need to insert data just call that Function and Done.
 

SohaibArif

Proficient
Apr 10, 2008
666
0
21
Karach,i Pakistan
Php is not an object oriented language as far as I know, it can only be forced to kind of act like them.
And I already have functions for fetching, editing and deleting data in a different file as seen in the given snippet.
 

furball

Well-known member
Nov 18, 2008
2,074
0
41
34
Lahore
Php is not an object oriented language as far as I know, it can only be forced to kind of act like them.
And I already have functions for fetching, editing and deleting data in a different file as seen in the given snippet.
php is an object oriented language not advance like java c#. But mvc based frame work are very popular and complex products can be made using php oop.. And use net beans or any good ide for development. Put support is not that good in php .To avoid these long flags check u can put specified parameter based on request type. u can use jquery for that...
 

SohaibArif

Proficient
Apr 10, 2008
666
0
21
Karach,i Pakistan
php is an object oriented language not advance like java c#. But mvc based frame work are very popular and complex products can be made using php oop.. And use net beans or any good ide for development. Put support is not that good in php .To avoid these long flags check u can put specified parameter based on request type. u can use jquery for that...
Thanks.
As I had no formal training in web development, I did not know Netbeans could be used with anything other than Java and maybe C++ or that MVC is supported in PHP.

Will I have to use WAMP even with Netbeans? I am currently uploading my PHP code directly to the live server instead because I kind of find WAMP to be too much of a hassle if a project is non-critical.
 

furball

Well-known member
Nov 18, 2008
2,074
0
41
34
Lahore
yes net beans has good support of php. Download netbeans complete package. It even support's javascript. Yes u need to use WAMP with netbeans. WAMP sometimes create problems during installation on some pc's . SO u can use xamp.
 
General chit-chat
Help Users
We have disabled traderscore and are working on a fix. There was a bug with the plugin | Click for Discord
  • No one is chatting at the moment.
  • NaNoW NaNoW:
    skyrim
    Link
  • NaNoW NaNoW:
    is one game, 10 releases
    Link
  • NaNoW NaNoW:
    GTA 5
    Link
  • faraany3k faraany3k:
    Which Franchise has 5 releases but only two games. Last of Us
    Link
  • faraany3k faraany3k:
    Shadowdragoo said:
    no idea how that is a steal by wasting 3500 rupees per month and for games that are removed before you can finish them off.xbox gamepass is garbage with no local prices
    why you are paying american rates in Pakistan. Search cheaper region like Turkey. 13k for 13 months. Ms does not care
    Link
  • Link
  • S Shadowdragoo:
    no idea how that is a steal by wasting 3500 rupees per month and for games that are removed before you can finish them off.xbox gamepass is garbage with no local prices
    Link
  • faraany3k faraany3k:
    Just finished Diablo 4 season in hurry to play Fallout 4 but gamepass released another banger in the form of Star Wars on April 25th. Gamepass is a steal man.
    Link
  • Necrokiller Necrokiller:
    EternalBlizzard said:
    Is it just me or people lately seem to defend every bad game design decision made by the devs and try to give bullshit reasons for that? Or perhaps it's because I'm on reddit and discord :ROFLMAO:
    There are no such thing as "bad design" bro, its all "artistic vision" now :ROFLMAO:
    • Haha
    Reactions: EternalBlizzard
    Link
  • EternalBlizzard EternalBlizzard:
    Is it just me or people lately seem to defend every bad game design decision made by the devs and try to give bullshit reasons for that? Or perhaps it's because I'm on reddit and discord :ROFLMAO:
    • Haha
    Reactions: Necrokiller
    Link
  • B Baghi:
    vos
    Link
  • Link
  • G gorillageneral:
    It's me cattoboee
    Link
  • G gorillageneral:
    It's me tattooed
    Link
  • Link
  • C cattoboee:
    testing
    Link
  • NaNoW NaNoW:
    true
    Link
  • faraany3k faraany3k:
    Add 20 years into your age. Congrats you are in Playstation 8 era. Probably a VR streaming headset in a form of glasses.
    Link
  • S Shehryar89:
    Hi any repair shop for Nintendo Switch in Isb/ Rwp? The console is not charging. Anybody? Who can help in this regard.
    Link
  • iampasha iampasha:
    Ewww brother ewww, what's that brother? Whats that?
    Link
  • Necrokiller Necrokiller:
    Senua Saga 30fps both on Series S and X. Gotta feel bad for the Series X owners.
    Link
  • Necrokiller Necrokiller:
    Imagine buying a Pro console and still getting 30fps in GTA 6 😬
    Link
  • faraany3k faraany3k:
    So this console gen was like putting a SSD in an old laptop
    Link
  • LordIT LordIT:
    does anyone know a reliable vendor in lahore for laptop batteries?
    Link
  • XPremiuM XPremiuM:
    I remember when PG used to be such an active site. Now it's barely alive.
    Link
    NaNoW NaNoW: skyrim