Hi All,

Here you need to understand two points

1)A Book Store App (which is a web application) made on PHP and MySQL is running on local wamp server(in one computer locally) for store's proprietary use, which is running fine.

2)I stucked with implementing online(Internet) version of web app for online reservations of books and customers collect books which are reserved online from Store by paying money in store.

Now if you understood the scenerion, my question is what is the best way to update Local MySQL Database, when some one reserved a book in online version of web application.

Note that one answer for this is integrating local version of webapp into online version, but it shud not be done.
Except above answer experts please guide me with
how to design a secure updation of local MySQL Database from online MySQL database or
how to send data from a PHP script to two databases securely

Which implementation is best and please do provide some pros and cons. Thanks in advance.

Dani AI

Generated

Brief summary and recommended direction: you want online reservations to reliably appear in the store’s local MySQL without ripping the local app into the public cloud. That rules out brittle dual‑writes from a single request and makes a robust, auditable delivery pipeline the best fit. Building on ’s polling idea and noting that ’s “Ajax” comment applies only to browser‑client flows, the safest approach is an event‑delivery pattern (outbox → reliable delivery → local consumer).

A practical, implementation‑level plan (keeps online as source‑of‑truth)

  1. When a reservation is created, write the reservation record and an “outbox event” row in the same online DB transaction.
  2. A background worker reads outbox rows, then reliably delivers each event to the store (HTTPS POST to a local consumer or publish to a durable queue the store can pull). Include an idempotency key with each event.
  3. The local consumer validates/authenticates the request, writes the local DB, returns an acknowledgement. The worker marks the outbox row delivered and retries failures (dead‑letter for manual review).

Why this is usually better: it gives atomic creation of events, durable retries, idempotency to avoid duplicates, and minimal attack surface (only an HTTPS endpoint or queue, not an open MySQL port).

Other options and cautions: true MySQL replication (master‑master or master‑slave) can work but brings complexity (conflict resolution, WAN latency, firewall/VPN needs) and usually requires a secure tunnel or VPN rather than exposing DB ports. Simple cron/polling is viable if near‑real‑time isn’t required but needs the same delivery/idempotency care. Never expose your DB directly to the Internet; prefer TLS, client auth or HMAC tokens, least‑privilege DB users, logging/monitoring, and a reconciliation report to catch missed reservations.

Recommended Answers

All 4 Replies

Member Avatar for Member #949455

Help me in correctly designing my Web App and Local Web App !!!!!!

I think you need to read more about creating a Web Apps.

My answer is to used Ajax!

I understood everything about web app and I had created lot of web apps with successful designing, but requirement here is I have to update two databasesz(one online and one local) when a customer reserved book.

The Local app is designed in such a way that we need to do lot of modifications for keeping it online. So, best action here is to update two databases at same time.

I want to confirm whether it will be a right design(updation of two databases, one local and one online) of local and web app or some body who have similar scenerio has better solution.

recomendation 1: on your local server run a cron to read the online database every minute, and get the reservation info
recomendation 2: have the online version send you an email, then read the mailbox infor and insert a record on the local DB.
recomendation 3: make the local server and online server, so your web app can read/write the local db. You dont need to host your web app on the local server, just make it visible

Thanks for recomendations.

Recomendation 2 is not applicable here as it is manual process.

In Recomendation-1
Can we able to access shared online MySQL database from local PHP page for running cron, I am not sure but I think its restricted.

In Recomendation-3
Is the local server is secure enough to keep online.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.