Category Archives: Web Development

How to submit multiple checkbox values with php

Hello World, Welcome to ProjectsPlaza.com. Today we will learn how to submit and print multiple checkbox values with PHP. I have divided this tutorial into the following parts.
  • Create a form with multiple checkboxes
  • Submit the form with PHP and print the values

Create a form with multiple checkboxes

  • Create a form.php file and add the following in this.
  • <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Submit Checkbox Values with Php</title>
    </head>
    <body>
        <h3>Select Your Favorite Fruits</h3>
        <form action="" method="post">
            <ol>
                <li>
                    <input type="checkbox" name="fruit[]" value="apple" id="apple" />
                    <label for="apple">Apple</label>
                </li>
                <li>
                    <input type="checkbox" name="fruit[]" value="banana" id="banana" />
                    <label for="banana">Banana</label>
                </li>
                <li>
                    <input type="checkbox" name="fruit[]" value="grapes" id="grapes" />
                    <label for="grapes">Grapes</label>
                </li>
                <li>
                    <input type="checkbox" name="fruit[]" value="kivy" id="kivy" />
                    <label for="kivy">Kivy</label>
                </li>
            </ol>
            <input type="submit" name="submit" />
        </form>
    </body>
    </html>
  • You have noticed that we have added checkbox name as an array, It will store the value in array form. This is the important step. Once you added the values as array form, It will very easy to print the data.


Submit the form with PHP and print the values

Add the following code at the top of file form.php
<?php
if(isset($_POST['submit'])){
    $fruits=$_POST['fruit'];
    echo '<pre>';
    print_r($fruits);
    echo '</pre>';
}
?>

How to save error logs in file in Codeigniter 3

Hello World, Welcome to ProjectsPlaza.com. Today I am going to discuss how to save error logs in the file in Codeigniter 3. Sometimes we need to save the errors in our development process. We can do this with a very easy step.

  • Open application/config.php
/*
|--------------------------------------------------------------------------
| Error Logging Threshold
|--------------------------------------------------------------------------
|
| You can enable error logging by setting a threshold over zero. The
| threshold determines what gets logged. Threshold options are:
|
|   0 = Disables logging, Error logging TURNED OFF
|   1 = Error Messages (including PHP errors)
|   2 = Debug Messages
|   3 = Informational Messages
|   4 = All Messages
|
| You can also pass an array with threshold levels to show individual error types
|
|   array(2) = Debug Messages, without Error Messages
|
| For a live site, you'll usually only enable Errors (1) to be logged otherwise
| your log files will fill up very fast.
|
*/
$config['log_threshold'] = 1;

You can change the above threshold according to the requirements. They have defined all options.


It will save the error in the application/logs directory.

Make sure your logs directory has writable permission

create-comment-system-with-jquery-ajax-and-laravel-7

Create comment system with jquery ajax and laravel 7

Hello World, Welcome to ProjectsPlaza.com. Today we will learn how to create a comment system with jQuery Ajax and Laravel 7. In this tutorial, we will save comments and show instantly with the total comments count. This gonna be a very interesting tutorial for me as well as for you (I hope). I have divided this tutorial into the following parts:

  • Create a Post model
  • Create a Comment model
  • Define the hasMany relationship in Post Model
  • Add dummy data for post
  • Create a PostController and define a method for post list and post detail
  • Create templates for post and post detail with comments and show data
  • Setup route
  • Add a comment with jquery ajax and  show instantly

Continue reading

Count page views in laravel 7

Hello World, Today we will learn how to count page views in Laravel 7. In this tutorial, we simply count the page views whenever the user visits the page. Suppose we have a post detail page and we want to show how many times this post has been viewed by users. We will use shorthand Laravel query methods to solve this problem.


Post::find($post_id)->increment('views');

The above method will increase 1 every time. If you want to increase 2 or more then you can change the above code as follows.

Post::find($post_id)->increment('views',2);

 

fetch-data-with-model-relationship-in-laravel-7

Fetch data with model relationship in laravel 7

Hello World, Welcome to projectsplaza.com. Today we will discuss how we can fetch data with the model relationship in laravel 7. In this tutorial, we will create an example of hasMany and belongsTo model relationship.


hasMany Relationship

Suppose you have a blog website and you want to fetch comments of a specific post on the post detail page. In this scenario, you should have two models, Post and Comment respectively. We know that a single post has many comments so we will define the hasMany relationship in the post model.

Continue reading

How to save form data in database in django

Hello World, Welcome to projectsplaza.com. Today we will learn how to save form data in the database in django. We will use the SQL database. I am assuming that you have installed Django in your system, If not then please refer to this tutorial. We will create a simple contact form in which the user will fill his basic information like full name, email, and message.
I have divided this tutorial into the following parts.

  • Create a contact model
  • Create contact form template
  • Submit form and save data in the database

Continue reading

How to create website without coding knowledge

Hello World, Today I am going to create a website without coding knowledge. You just need basic knowledge of internet browsing. In this tutorial, we will create a beautiful blog website with WordPress without coding experience. I have divided this tutorial into three parts.

  • Introduction of WordPress
  • How to download and install WordPress.
  • Create and run the website

Continue reading

How to integrate stripe payment with laravel 7

Hello World, Welcome to projectsplaza.com. Today i am going to create a tutorial about stripe payment with laravel 7. This is a small and very easy tutorial. It is very easy to integrate stripe with laravel. I have divided this tutorial into the following parts.

  • Setup stripe account
  • Install stripe package in laravel
  • Integrate stripe with laravel
  • Make payment

Continue reading

how-to-send-email-in-laravel-with-mailtrap

How to send email with attachment in laravel 7 with Mailtrap

Hello World, Welcome to projectsplaza.com. Today I am going to show you how to send email with attachment in laravel with Mailtrap. This is a very easy and simple tutorial. In this tutorial, I will send a simple email with attachment from my controller function. I have divided this tutorial into the following parts.

  • Setup Mailtrap account
  • Connect Mailtrap with laravel
  • Email configuration in laravel
  • Send email with attachment from the controller

Continue reading