feat(site): email launch-list capture with a PHP/MySQL endpoint
A signup form in the closing section posts to subscribe.php (ships in the build): PDO/MySQL, honeypot, idempotent insert, optional mail() notify. DB creds live in a gitignored config kept above the web root; schema and setup in server/. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
6 files changed
+264
No files matched your search
@@ -0,0 +1,24 @@
|
||||
# Launch-list backend (cPanel)
|
||||
|
||||
The email capture on the site posts to `subscribe.php`, which ships in the build
|
||||
(`public/subscribe.php` → `dist/subscribe.php`). To wire it up on cPanel:
|
||||
|
||||
1. **Create the DB** in cPanel → MySQL Databases. Note db name, user, password.
|
||||
2. **Create the table**: run `schema.sql` in phpMyAdmin against that DB.
|
||||
3. **Add credentials**: copy `subscribe.config.example.php` to `subscribe.config.php`,
|
||||
fill in the DB values, and upload it **one level above** the subdomain's docroot
|
||||
(so it is never web-servable). `subscribe.php` looks there first.
|
||||
4. **Deploy** the built `dist/` into the subdomain docroot. `subscribe.php` is already inside it.
|
||||
5. **Smoke test**:
|
||||
```
|
||||
curl -i -X POST -H 'X-Requested-With: fetch' \
|
||||
--data 'email=test@example.com' \
|
||||
https://green-tea.expressive-tea.io/subscribe.php
|
||||
```
|
||||
Expect `{"ok":true,...}` and a row in `subscribers`.
|
||||
|
||||
Notes:
|
||||
- Duplicate signups are a silent success (unique index on `email`).
|
||||
- A hidden honeypot field blocks basic bots.
|
||||
- No-JS visitors are redirected to `/?subscribed=1`; with JS they get inline feedback.
|
||||
- No rate limiting yet — add one at the cPanel/CDN layer if signups get abused.
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Launch-list table for subscribe.php. Run once against the green-tea DB.
|
||||
CREATE TABLE IF NOT EXISTS subscribers (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
email VARCHAR(254) NOT NULL UNIQUE,
|
||||
created_at DATETIME NOT NULL,
|
||||
ip VARCHAR(45) DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Copy this to `subscribe.config.php` and fill in real values.
|
||||
*
|
||||
* Place the real file ONE LEVEL ABOVE the web root if you can (so it is never
|
||||
* web-servable), e.g. /home/USER/subscribe.config.php when the docroot is
|
||||
* /home/USER/green-tea.expressive-tea.io/. subscribe.php looks there first,
|
||||
* then falls back to sitting next to it.
|
||||
*
|
||||
* Never commit the real subscribe.config.php — it holds the DB password.
|
||||
*/
|
||||
|
||||
return [
|
||||
'dsn' => 'mysql:host=localhost;dbname=YOUR_DB;charset=utf8mb4',
|
||||
'user' => 'YOUR_DB_USER',
|
||||
'pass' => 'YOUR_DB_PASSWORD',
|
||||
'notify' => 'support@expressive-tea.io', // set to '' to skip notification emails
|
||||
];
|
||||
Reference in new issue
Block a user