Search code examples
javascriptphpajaxinventory

PHP process http request from one page and display it on another


I come here with very little knowledge on web development trying to learn, so I ask for some patience in regards to my ignorance on the subject.

It would be great if you could show me logical steps that i need to perform to complete the task before me.

Working with PHP here. I need to figure out how to send a GET request from one page/web application and process as well as display it in another.

A simple example:

there are 2 php pages, one to send the request - send.php, another to process and display it display.php

send.php contains a simple form to get some user input string and using get method to send it over to display.php

<form action="display.php" method="get">
    <input type="text" name="userInput">
    <input type="submit">
</form>

display.php receives the string and uses it as a parameter for some function and echoes it.

What logical steps do I need to perform to be able to open send.php in one window, display.php in another, type something in into the form, press submit and see the results in the display.php window instead of usual redirect to display.php from send.php? As far as I know, AJAX allows us to communicate with the server but the result is still returned to the same page. Forgive my ignorance, I seek the logical steps to the solution, maybe certain technologies or methods that I am currently unaware of,something to look into and find a way to accomplish this task.

Actual task is work with inventory management system: we need to be able to scan barcodes/id's etc. with one device, while seeing information about the items on another screen (think: scanning barcodes with an android app, sending it to the web based inventory system, which is open on a tablet computer or something like that and seeing the information about the item on said tablet).

Notes: we were explicitly told not to use java/scala, because the sys-admin doesnt want a jvm running on the same server as the inventory system(appearantly only one server dedicated to that), i assume node.js also falls into the same boat, although im uncertain.

Thank you for your patience dealing with a complete web development noob :)


Solution

  • So after analyzing your OP(Original Post) more in depth, I believe what would work for you is the following:

    In send.php: use Ajax to store each scanned barcode to the database. The reasoning for this is so that you dont redirect elsewhere. AJAX will just look for the php file that does all the storing work(which you can call process.php).

    In display.php: retrieve all the barcodes from the database and render it. This can be done straight with embedded PHP or is you want to do this every so many times, use AJAX.

    With this structure, you can see all the barcodes saved regardless of what window or device you are in.