https://github.com/zyron-tech/dummy-backend
A PHP backend with email OTP authentication using PHPMailer and PostgreSQL. It provides APIs for user registration, login, and OTP verification, designed for seamless integration with frontend applications.
https://github.com/zyron-tech/dummy-backend
backend-api email-otp email-otp-validation email-sender otp-verification php user-authentication
Last synced: 3 months ago
JSON representation
A PHP backend with email OTP authentication using PHPMailer and PostgreSQL. It provides APIs for user registration, login, and OTP verification, designed for seamless integration with frontend applications.
- Host: GitHub
- URL: https://github.com/zyron-tech/dummy-backend
- Owner: Zyron-Tech
- License: mit
- Created: 2024-09-04T22:35:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-11T14:54:39.000Z (over 1 year ago)
- Last Synced: 2025-03-18T15:54:51.555Z (about 1 year ago)
- Topics: backend-api, email-otp, email-otp-validation, email-sender, otp-verification, php, user-authentication
- Language: PHP
- Homepage: https://dummy-backend-gyc3.onrender.com/
- Size: 894 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Backend with Email OTP Authentication
This backend system is built with PHP, using PHPMailer for sending OTPs via email during user registration and login processes. The backend connects to a PostgreSQL database to manage users and authentication.
## How to Integrate with Frontend
### Overview
The backend provides RESTful API endpoints for sign-up, login, and OTP verification. To connect the frontend (e.g., a React, Vue, or plain HTML/JavaScript application) to the backend, you will use HTTP requests (e.g., `fetch` or `axios`) to interact with these endpoints.
### API Endpoints
1. **Sign Up Endpoint**: Registers a new user and sends an OTP to their email.
- **URL**: `/public/signup.php`
- **Method**: `POST`
- **Parameters**: `username`, `password`, `email`
2. **Login Endpoint**: Logs in the user with email and password.
- **URL**: `/public/login.php`
- **Method**: `POST`
- **Parameters**: `email`, `password`
3. **Verify OTP Endpoint**: Verifies the OTP sent to the user’s email during sign-up.
- **URL**: `/public/verify-otp.php`
- **Method**: `POST`
- **Parameters**: `email`, `otp`
4. **Delete Account Endpoint**: Users can easily delete their account if it is no longer needed
- **URL**: `/public/delete_account.php`
- **Method**: `POST`
- **Parameters**: `email`,`password`
### Example Frontend Integration
Here's a basic HTML/JavaScript example showing how to interact with the backend API endpoints using the `fetch` API:
#### Sample Sign-Up Form
```html
User Sign-Up
Sign Up
document.getElementById('signupForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
try {
const response = await fetch('https://dummy-backend-gyc3.onrender.com/public/signup.php', {
method: 'POST',
body: formData
});
const result = await response.json();
alert(result.message);
} catch (error) {
console.error('Error during sign-up:', error);
alert('An error occurred. Please try again.');
}
});
```
#### Sample Verify Otp Code
```html
Verify OTP
Verify OTP
document.getElementById('verifyOtpForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
try {
const response = await fetch('https://dummy-backend-gyc3.onrender.com/public/verify-otp.php', {
method: 'POST',
body: formData
});
const result = await response.json();
alert(result.message);
} catch (error) {
console.error('Error during OTP verification:', error);
alert('An error occurred. Please try again.');
}
});
```