PHP – CodingNepal https://www.codingnepalweb.com CodingNepal is a blog dedicated to providing valuable and informative content about web development technologies such as HTML, CSS, JavaScript, and PHP. Thu, 11 May 2023 07:44:07 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.2 PHP vs Node.js – Which is best for Backend Development? https://www.codingnepalweb.com/php-vs-nodejs-which-is-best-for-backend/ https://www.codingnepalweb.com/php-vs-nodejs-which-is-best-for-backend/#comments Tue, 27 Dec 2022 11:48:18 +0000 https://www.codingnepalweb.com/?p=3736 PHP vs Node.js Which is best for Backend Development

There are numerous programming languages available for backend development, but two of the most commonly used are PHP and Node.js. These languages are popular choices for building backend web applications and websites, but they each have their own unique set of strengths and weaknesses.

To help you decide which technology is the best fit for your backend development project, this blog will provide an overview of PHP and Node.js. We’ll cover what these languages are, what they are used for, and the critical differences between them.

By understanding the capabilities and features of each technology, you can make an informed decision about which one is the best fit for your specific project needs and requirements.

But before continuing this blog, there is also a lot of confusion among frontend developers when choosing the best framework for frontend development, if you’re one of them, this blog might be helpful to you: React vs Angular – Which is best for Frontend Development?

What is PHP, and what does it do?

What is PHP, and what does it do

PHP, which stands for “Hypertext Preprocessor,” is a server-side scripting language that is widely used for creating dynamic web applications and websites. It is executed on the server and generates HTML (HyperText Markup Language), which is then sent to the client’s web browser.

PHP was developed by Rasmus Lerdorf in 1994 and has since become a popular choice for building dynamic web pages. It is well-known for its ease of use, and it has a large ecosystem of frameworks such as Laravel, CodeIgniter, Symfony, etc., which offer a range of tools and features to help developers build robust and scalable web applications easily.

PHP has numerous advantages, some of which are listed below:

  • It is easy to learn and use even if you’re a newbie in backend development.
  • It has a large ecosystem of powerful libraries and frameworks available.
  • It is compatible with a wide range of platforms including Linux, and Windows.
  • It has built-in support for popular databases that make data easy to read and store.
  • It has many built-in security features such as input validation and sanitization.
  • It has a huge and active community of developers.

What is Node.js, and what does it do?

What is Node.js, and what does it do

Node.js is a JavaScript runtime environment that enables the execution of JavaScript code on the server side, outside of a web browser. It was developed by Ryan Dahl in 2009 and built using the V8 JavaScript engine, which is also used by the Chrome web browser.

Node.js is designed to be lightweight, efficient, and well-known for its fast performance and scalability. As a result, it is ideal for creating real-time web applications such as chat applications and online games. Node.js is also a cross-platform technology, which means it can be used on various operating systems, including Windows, macOS, and Linux.

Node.js has numerous advantages, some of which are listed below:

  • It is easy to learn and use, especially if you’re familiar with JavaScript.
  • It is efficient and well-suited for building real-time applications and APIs.
  • It uses an event-driven, non-blocking I/O model that makes it asynchronous.
  • It is a cross-platform technology that works on a variety of platforms.
  • It can be used for both the front-end and back-end of web development.

Differences between PHP and Node.js

There are several differences between PHP and Nod.js. But some key differences between them are pointed out below.

PHP Node.js
It is a server-side scripting language. It is a JavaScript runtime environment.
It uses a traditional synchronous programming model. It uses an event-driven, non-blocking I/O model.
It has a large ecosystem of libraries and frameworks. It has a more limited set of tools and libraries.
It is slower and less efficient than Node.js. It is faster and more efficient than PHP.
It is used for server-side rendering of web pages. It is used for building server-side applications and APIs.
It is used in collaboration with relational databases like MySQL. It works perfectly with NoSQL (not only SQL) databases like MongoDB.

Which should you use, PHP or Node.js?

As you are now aware, what are PHP and Node.js, their pros and cons, and the differences between them? The decision of which technology you should use will depend on your specific project requirements and the resources and skills that are available to you.

PHP can be the best choice if you are a newbie and want to build a simple, traditional web application or website because it is easy to learn and has a large number of frameworks. But if you are familiar with JavaScript and want to build real-time, high-performance web applications or APIs, then Node.js might be a better choice for you.

Ultimately, each technology has its own advantages and disadvantages. So, before selecting any of these technologies for your backend development, it is important to consider your project requirements, objectives, and your personal interests and skills.

If you found this blog useful, please consider sharing it with others to help them benefit as well. Thank you for your support and keep visiting our site.

]]>
https://www.codingnepalweb.com/php-vs-nodejs-which-is-best-for-backend/feed/ 5
Login & Signup Form with Email Verification using PHP and MySQL https://www.codingnepalweb.com/login-signup-form-using-php-mysql/ https://www.codingnepalweb.com/login-signup-form-using-php-mysql/#comments Mon, 07 Sep 2020 18:16:00 +0000 https://codingnepalweb.com/2020/09/07/login-signup-form-with-email-verification-using-php-and-mysql/ Hello readers, Today in this blog you’ll learn how to create a Login & Signup Form with Email Verification using PHP and MySQL. Earlier I have shared a blog on How to configure XAMPP to send Mail from Localhost in PHP? If you haven’t still read this blog, then I want to suggest you first read that blog and continue this because in that blog I’ve taught you how to configure XAMPP before sending mail from the localhost.

As we all know, the login and & Signup Form is the set of different input fields – Name, Email, Username, Password, etc. which are used to authenticate users before giving access to the site. In our program [log in & Signup Form with Email Verification], there are eleven PHP files and one is a CSS file means there are a total of twelve files in our user name folder.Login & Signup Form with Email Verification using PHP and MySQLAt first, on the webpage, there is shown only a login form and inside the login form, there is a signup now link to redirect the user to the first signup before login. When the user tries to log in without even signup the form, there is displayed an error message labeled as “It looks like you’re not yet a member! Click on the bottom link to signup”.

In the signup form, while the user is signing up, if he enters the same email, which already exists in our database then there is displayed an error message labeled as “Email that you’ve entered is already exist!”. And when the user doesn’t match two password combinations, there is also displayed an error message labeled as “Your confirm password not matched”.

When the user filled up all the required inputs correctly, then a six-digit verification code number is sent to the user’s email and he will be redirected to the OTP Verification page. If the user entered the wrong code, there is displayed an error message labeled as “You’ve entered incorrect code!”. If the user exit the OTP verification code page without entered a valid or correct verification code and come to the login page to log in with the same email and password which he used to sign up, then he will be again redirected to the OTP page and there is displayed an info message labeled as “It looks like you’ve not verified your email”.

When the user entered the correct verification code, then he will be redirected to the Home Page. On the home page, there is a navbar with a logo on the top left corner and the logout button on the top right corner. At the center of the home page, there is a welcome message with the name of the user which he entered while signing up for the form. And when the user clicked on the logout button, he will be redirected to the login page and at this time he can log in with their correct email and password and will be directly redirected to the home page without redirecting to any other page.

If you’re feeling difficult to understand what I am saying. You can watch a full video tutorial on this program (Login & Signup Form with Email Verification).

Video Tutorial of Login & Signup Form with Email Verification

 
In the video, you have seen the demo of this project and I hope you love it. In this project, I have sent mail from Localhost using PHP and you must have to configure your XAMPP to Send Mail from Localhost in PHP. If you don’t configure your XAMPP then your mail which is used to send OTP code to the user won’t be sent and there is no meaning to download the source files of this project.

Login & Signup Form with Email Verification [Source Codes]

Click the given download button and you’ll be redirected to the timer page, just wait until the timer completed. Once the timer complete then the zip file will automatically download. Once you download the zip file, just extract it and you’ll get a folder with all required coding files with a userform.sql file. After these, create the database and the database name must be userform then import the userform.sql file by clicking on the import tab in the database. This file will create all required tables with columns. That’s it you don’t need to do anything more.

 

]]>
https://www.codingnepalweb.com/login-signup-form-using-php-mysql/feed/ 258
How to configure XAMPP to send Mail from Localhost in PHP ? https://www.codingnepalweb.com/configure-xampp-to-send-mail-from-localhost/ https://www.codingnepalweb.com/configure-xampp-to-send-mail-from-localhost/#comments Mon, 07 Sep 2020 16:41:00 +0000 https://codingnepalweb.com/2020/09/07/how-to-configure-xampp-to-send-mail-from-localhost-in-php/ How to Configure XAMPP to Send Mail from Localhost in PHP
Hello friends, today in this blog you’ll learn How to configure XAMPP to Send Mail from Localhost in PHP. If you don’t know, XAMPP is an abbreviation for cross-platform, Apache, MySQL, PHP, and Perl. Using XAMPP we can work on our local server and test our local copies or projects of websites using PHP code and MySQL databases.

As a part of the experiment, developers need to send emails and we all know that sending mail from localhost using PHP can be much more painful if we don’t know how to properly configure XAMPP for it.

Before starting this blog, if you want to send an email in node.js applications, then you can see this blog How to Send Email in Node.js using Nodemailer & Gmail.

To send mail from localhost using XAMPP, we’ve to configure XAMPP after installing it. To configure the XAMPP server to send mail from the local host, we have to make some changes in two files one is PHP and another one is Sendmail.

First, go to the XAMPP installation directory and open the XAMPP folder and follow the below steps same: I’ve installed XAMPP in the C directory.

1. Go to the (C:xampp\php) and open the PHP configuration setting file then find the [mail function] by scrolling down or simply press ctrl+f to search it directly then find the following lines and pass these values. Remember, there may be a semicolon ; at the start of each line, simply remove the semicolon from each line which is given below.

[mail function]
For Win32 only.
http://php.net/smtp
SMTP=smtp.gmail.com
http://php.net/smtp-port
smtp_port=587
sendmail_from = your_email_address_here
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

That’s all for this file, press ctrl+s to save this file and then close it.

2. Now, go the (C:\xampp\sendmail) and open the sendmail configuration setting file then find sendmail by scrolling down or press ctrl+f to search it directly then find the following lines and pass these values. Remember, there may be a semicolon ; at the start of each line, simply remove the semicolon from each line which is given below.

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=your_email_address_here
auth_password=your_password_here
force_sender=your_email_address_here (it's optional)

That’s all for this file, press ctrl+s to save this file and then close it. After all changes in the two files, don’t forget to restart your apache server.

Now, you’re done with the required changes in these files. To check the changes you’ve made are correct or not. First, create a PHP file with the .php extension and paste the following codes into your PHP file. After pasting the codes, put your details into the given variables – In the $receiver variable put the receiver email address, in the $subject variable put the email subject and do respectively.

<?php
$receiver = "receiver email address here";
$subject = "Email Test via PHP using Localhost";
$body = "Hi, there...This is a test email send from Localhost.";
$sender = "From:sender email address here";

if(mail($receiver, $subject, $body, $sender)){
    echo "Email sent successfully to $receiver";
}else{
    echo "Sorry, failed while sending mail!";
}
?>

After completing these steps, just open this PHP file on your browser. If your mail is sent successfully then there is appears a success message “Email sent successfully to …..” and in the case your mail not sent then there is appears “Sorry, failed while sending mail!”.

If mail is sent then check whether the receiver has got your email or not. If yes, then great you did all changes perfectly. If not, check all the changes that you have done earlier are correct or not.

Note: Google removed the “Less secure apps” feature on May 30, 2022. So you need to do some extra steps and make changes in the files to send mail from localhost using Gmail.

Instead of using your Google account password as auth_password in sendmail configuration file, you need to use an App password which is 16 characters long.

To create an app password, go to manage your google account > Click Security > Under “Signing in to Google,” select App passwords > Select App & Device, and then you’ll get a 16-character code and this is your password. For more details about creating App Passwords, read the Official Google Article.

]]>
https://www.codingnepalweb.com/configure-xampp-to-send-mail-from-localhost/feed/ 143