Online news portal project in php free download
Here is a basic outline of an online news portal project in PHP, along with some free resources to help you get started:
Project Requirements:
- User registration and login system
- Article submission and editing system
- Article categorization and tagging system
- Commenting system
- Search functionality
- News feed and latest news section
- Admin dashboard for managing articles, users, and comments
Free Resources:
- PHP Framework: You can use a PHP framework like CodeIgniter, Laravel, or Symfony to build your project. Here are some free resources to get you started:
- CodeIgniter: CodeIgniter Official Website
- Laravel: Laravel Official Website
- Symfony: Symfony Official Website
- Database: You can use a free database like MySQL or PostgreSQL. Here are some free resources to get you started:
- MySQL: MySQL Official Website
- PostgreSQL: PostgreSQL Official Website
- Front-end Framework: You can use a front-end framework like Bootstrap or Foundation to build your project. Here are some free resources to get you started:
- Bootstrap: Bootstrap Official Website
- Foundation: Foundation Official Website
- Templates: You can use free templates like HTML5 UP or Start Bootstrap to get started with your project. Here are some free resources to get you started:
- HTML5 UP: HTML5 UP Official Website
- Start Bootstrap: Start Bootstrap Official Website
Project Structure:
Here is a basic project structure to get you started:
project/
app/
controllers/
articles.php
comments.php
users.php
...
models/
article.php
comment.php
user.php
...
views/
articles/
article.php
comments/
comment.php
...
...
public/
index.php
css/
style.css
...
js/
script.js
...
...
database/
database.sql
...
Code Snippets:
Here are some basic code snippets to get you started:
User Registration and Login:
// app/controllers/users.php
public function register() {
// validate user input
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
// create user in database
$query = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')";
$result = mysqli_query($conn, $query);
// redirect to login page
header('Location: login.php');
}
public function login() {
// validate user input
$username = $_POST['username'];
$password = $_POST['password'];
// check if user exists in database
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$result = mysqli_query($conn, $query);
// if user exists, log them in
if ($result->num_rows > 0) {
// set session variables
$_SESSION['username'] = $username;
$_SESSION['logged_in'] = true;
// redirect to dashboard
header('Location: dashboard.php');
} else {
// display error message
echo 'Invalid username or password';
}
}
Article Submission and Editing:
// app/controllers/articles.php
public function submit() {
// validate article input
$title = $_POST['title'];
$content = $_POST['content'];
// create article in database
$query = "INSERT INTO articles (title, content) VALUES ('$title', '$content')";
$result = mysqli_query($conn, $query);
// redirect to article list page
header('Location: articles.php');
}
public function edit() {
// validate article input
$id = $_GET['id'];
$title = $_POST['title'];
$content = $_POST['content'];
// update article in database
$query = "UPDATE articles SET title = '$title', content = '$content' WHERE id = '$id'";
$result = mysqli_query($conn, $query);
// redirect to article list page
header('Location: articles.php');
}
Commenting System:
// app/controllers/comments.php
public function submit() {
// validate comment input
$article_id = $_POST['article_id'];
$content = $_POST['content'];
// create comment in database
$query = "INSERT INTO comments (article_id, content) VALUES ('$article_id', '$content')";
$result = mysqli_query($conn, $query);
// redirect to article page
header('Location: article.php?id='. $article_id);
}
public function delete() {
// validate comment input
$id = $_GET['id'];
// delete comment from database
$query = "DELETE FROM comments WHERE id = '$id'";
$result = mysqli_query($conn, $query);
// redirect to article page
header('Location: article.php?id='. $_GET['article_id']);
}
This is just a basic outline of an online news portal project in PHP. You will need to add more functionality and features to make it a fully functional project.