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,053
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,053
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:
    by closing down good studios
    Link
  • NaNoW NaNoW:
    well he is breaking barriers
    Link
  • iampasha iampasha:
    SolitarySoldier said:
    Phil keeps talking about breaking barriers to gaming, making it accessible on all platforms yada yada, while killing competition and creativity at the same time. the fact that i actually believed him for a second lol
    guys the biggest yapper in the Industry right now. All he do is yap
    Link
  • Necrokiller Necrokiller:
    Phil should be held responsible for this shitfest too, just like Sarah, but it's highly likely that these decisions are coming from Satya. And this isn't even the end of it. More closures are coming.
    Link
  • SolitarySoldier SolitarySoldier:
    if we are moving towards more and more popular trash across platforms that make billions for companies, I'm happy with all the barriers and exclusivity because at least that brings some pressure to create good stuff.
    Link
  • SolitarySoldier SolitarySoldier:
    Phil keeps talking about breaking barriers to gaming, making it accessible on all platforms yada yada, while killing competition and creativity at the same time. the fact that i actually believed him for a second lol
    Link
  • SolitarySoldier SolitarySoldier:
    "These changes are not a reflection of the creativity and skill of the talented individuals at these teams or the risks they took to try new things" ... seems to me that's exactly what it is
    Link
  • SolitarySoldier SolitarySoldier:
    why make good games when u can just buy everyone and shut them down lol
    Link
  • XPremiuM XPremiuM:
    I'm gonna say one last time, F*** Microsoft to infinity!
    Link
  • XPremiuM XPremiuM:
    Microsoft deserves all the hate they can get. Seriously i can't explain how much i want to curse them out.
    Link
  • XPremiuM XPremiuM:
    They could've sold the studios instead of closing them, but the nazi bastards just didn't want competition down the road.
    Link
  • Link
  • XPremiuM XPremiuM:
    F*** Microsoft, and F*** their fanboys.
    Link
  • XPremiuM XPremiuM:
    What's the f*** is wrong with them? I mean really? Have they completely lost it? F***ing retards.
    Link
  • XPremiuM XPremiuM:
    So i just found out that f***ing s***bag Microsoft shut down Arkane Studio (makers of the brilliant Dishonored series) and Tango Gameworks (makers of the iconic The Evil Within series), among some other studios. I just want to say a giant F*** Y**! to Microsoft. THEY'VE F***ED UP BIG TIME this time.
    Link
  • Necrokiller Necrokiller:
    MS: Hold my trillion dollars
    Link
  • Necrokiller Necrokiller:
    Sony: We can f**k up a totally good situation.
    Link
  • Link
  • XPremiuM XPremiuM:
    Started Dead Island 2, and i find it pretty lame. The story is shit. The characters are either cringe or bland (all 6 of them), The gameplay isn't fun. Even the goddamn zombies don't behave like proper zombies. They're all fast & intelligent unlike how zombies are supposed to be like. Any fan of "zombie" genre cannot possibly like this shitfest of a game. Dying Light 2 was million times better than this shit.
    Link
  • NaNoW NaNoW:
    so Baldurs Gate 3 is pretty great!"
    Link
  • faraany3k faraany3k:
    So who here is waiting for Senua Hellblade 2. Prequel was a true mind fuck experience.
    Link
  • GloriousChicken GloriousChicken:
    Sad indeed
    Link
  • NaNoW NaNoW:
    what a sad day
    Link
  • faraany3k faraany3k:
    Necrokiller said:
    MS one upping Sony in catching the biggest L in gaming
    tbh gaming industry as a whole is failing much like tech industry. They have buckled down too much to Corporate suites then relying on passionate and innovative people. A corporate only believes in financial growth and shareholders.
    Link
  • Necrokiller Necrokiller:
    MS one upping Sony in catching the biggest L in gaming
    Link
    NaNoW NaNoW: by closing down good studios