SEC S20W3|| Introduction to PHP Part -1

Assalam O Alaikum

Hello dear friends! Welcome to my post. How are you all? I hope you will be doing well by the grace of Almighty Allah. I'm also fine and enjoying my day. Today I'm here to participate in this Steemit engagement challenge season 20 week 3 organized by @kouba01 and @starrchris. The topic of this challenge is about "Introduction to PHP Part -1". So let's start without any more delay of time.


Black Simple Corporate Job Vacancy LinkedIn Single Image Ad_20240929_095805_0000.png

Created With Canva


What's the full meaning of PHP? And What type of language is PHP?

The full meaning of PHP is Hypertext Preprocessor which is a popular server side scripting language and mostly it is used for web development. Basically, the PHP is server side scripting language which can be used to create various kind of web pages and whole websites. It is more dynamic as compared to other languages as through it, we can run it on the server and the results of that program can be sent to the client's browser through which he can check it and on time changes can be done easily to build a website right according to client's requirements.

Furthermore, the PHP has a crucial role in processing the content of a website and through it, more dynamic web pages can be created. This is because, it can manage content of a website, database and different sessions on a website and on the basis of inputs which are provided by the clients. Also, the PHP is integrated with html which means that, we can add logics directly to the web pages. In this way different types of contents can be displayed based on our expectations.


php-coding-computer-css-data-digital-function-concept_53876-125415 (1).jpg

Freepik


Due to all these reasons, we can say that the PHP is highly flexible and very helpful in building websites of different types. As it supports different types of features like managing Cookies, interaction with APIs and uploading of various kinds of files. Also it can be combined with other technologies which are used in programming like the JavaScript. The PHP is versatile in nature Due to this, it can run over various programs like windows and linus etc.

The PHP can store store, manipulate and retrieve data by connecting with different types of database like MySQL and SQLite etc. So that level of connectivity, make it more useful for the programmers to build the applications which can store or manipulate the data. In results, we can say that the PHP has a crucial role in programming as it brings many advantages to them and help them to create a variety of websites and applications.

What do you understand by Conditional statements?

In programming, the conditional statements has a great role as they help the programmers to make decisions based on specific conditions. Also they help them execute different conditions whether they are true or false. In that way, we can easily control a program based on certain conditions. Now let's have a look at different types of conditions;

1. If statement: It executes a block of code when the specified condition evaluates to true.

2. If- else statement: It executes one block of code if the condition is true, the other block if the condition is false.

3. Else-If Statement: It Checks multiple conditions sequentially. If the first condition is false, it checks the next condition, and so on.

4. Switch Statement: A switch statement evaluates an expression and executes the corresponding case block. It is useful when we have to check many conditions.


For Example:


<?php
$score = 85; // Example score

if ($score >= 90) {
echo "Grade: A";
} elseif ($score >= 80) {
echo "Grade: B";
} elseif ($score >= 70) {
echo "Grade: C";
} elseif ($score >= 60) {
echo "Grade: D";
} else {
echo "Grade: F";
}
?>


Explanation;


  • If the $score is 90 or above, it's output will "Grade: A".

  • If the score is between 80 and 89, it will output "Grade: B".

  • If the score is between 70 and 79, it will output "Grade: C".

  • If the score is between 60 and 69, it will output "Grade: D".

  • If the score is less than 60, it will output "Grade: F".

What is the Importance of Functions in Web Development?

In the development of websites, the functions are very important as they play a vital role in promoting efficiency and scalability of websites. Also they help the programmers to build a large number of websites without facing problems related to the programming. So let's discuss more briefly about them importance of functions in web development:

1. Improve Performance:

  • The functions improve the performance by building the codes of a website in a logical way and reduces the redundancy. They structure the code in such a way that the redundancy reduces automatically. Also they optimize such functions which are coached by the server of a website.

2. Codes Reusability:

  • The functions provide an opportunity to the developers to use the same code many times in the structure of a website. In that way, it reduces the need of building the same many times. Also when the same codes are used in different parts of the website, the chances of errors reduces.

3. Simplifies Maintenance:

  • The functions make the maintenance easier, as when the codes are organized in the form of functions it becomes more easy to update, improve and remove errors from them. In that way, we can say that if you want to modify one function, you have to change it only one place and then the modifications will occur automatically on other location.

4. Reduces code Duplication:

  • When the codes are organized in the form of functions, the chances of their duplication reduces. So the development will stay away from the duplication of same logics throughout the whole set up of codes for a website. Also it reduces the chances of errors between the codes blocks of a website.

5. Provides Flexibility:

  • The functions provides flexibility and allow the parameters to pass to perform different tasks within a website. Also, they make the inputs and outputs more flexible as the same function can be Used with different inputs to produce different outputs.
Give 5 difference between GET and POST method.

GETPOST
1. It adds the data to URL and make it visible in address bar. In that way, sensitive information like passwords can be seen in GET.2. In POST, the data isn't visible in in the URL because it sends data in the form of https request. So it is more suitable to share sensitive data.
2. On GET, we can send a limited amount of data which is determined by the browser or server. This is because, th data is a part of URL.2. The POST allow us to send a large amount of data because the data is transmitted in the request body.
3. In GET, the requests can be cached by the browsers or intermediaries present in them like proxies. It improves performance but sometimes, it create significant challenges.3. In POST, the requests aren't cached because it often change the state of a server.
4. In GET, the requests can be bookmarked which is useful for the queries to search them to use for different purposes.4. In POST, the data can't be shared or bookmark as the requests aren't a part of URL.
5. The GET is used to retrieve data from server without modifying data. It deals with the links, queries and filters.5. The POST is used to submit data to the server.

Using a conditional statement, print even numbers from 0 to 30 if a user inputs an even number, otherwise print odd numbers if the user inputs an odd number.

IMG-20240929.jpg


For Even numbers:


IMG-20240929jpg


For Odd numbers:


IMG-20240929-jpg


I have used PHP and html along with the CSS to style that content. And both these page has a users input in which the first form will check the numbers if they are even and the second one will check if the numbers are odd. So the following will be be results of that inputs which are provided by the users:

  • If the number is even, the script outputs even numbers from 0 to 30.

  • If the number is odd, the script outputs odd numbers from 1 to 29.

Create a form that accepts sign-up data, and send the username and email to a new page named user.php. Create a form that posts the password and age to a new page named secure.php.

IMG-20240929

IMG-20240929jpg


Here's is the form which I have created through the HTML which has two Fields among them, the one is allowing the users to input their data as username and the second one is requiring input and asking the users to put their password. Also below is the signup button which will send the data in the form of email and password to the next screen.

Now, I'm moving towards the second part of that question in which we have to send the username and email to a new page named user.php.


IMG-20240929-WA0004.jpg

IMG-20240929.jpg


IMG-20240929.jpg

IMG-20240929jpg


Create a function that says "hello" to the user when they register their account.

IMG-20240929jpg

IMG-20240929jpg


IMG-20240929jpg

IMG-20240929jpg


Finally, above you can see, I have done that task and their results have been appeared on my the screen of my laptop.

Create a beautiful sign-up and login page, which will be used in the next class.

IMG-20240929jpg

IMG-20240929jpg


Above is the beautiful page which I have created with the help of CSS, HTML and JavaScript to make it more beautiful and visible. In that page, the users can give an input by creating their profile through their email and passwords and then they can see its results in the form of output on the screens of their computers and laptops. Below their codes have been given and you can see them.


IMG-20240929jpg

JavaScript code

IMG-20240929jpg

CSS code

IMG-20240929jpg

CSS code


C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iP9VDv5a4EtHBpkJfW8Nn7PSXUPJapWuHbag84TFcG78C8dcNHndZWQcoQ8aFmkLxe2x47zw3mg.png

So friends, that was my entry about that challenge and I hope you will enjoy reading it. Now it is a time to say goodbye to everyone and I want to invite my friends @josepha, @simonnwigwe, @hudamalik20, @arinaz08 and @jyoti-thelight to take a part in this amazing challenge.

C3TZR1g81UNaPs7vzNXHueW5ZM76DSHWEY7onmfLxcK2iP9VDv5a4EtHBpkJfW8Nn7PSXUPJapWuHbag84TFcG78C8dcNHndZWQcoQ8aFmkLxe2x47zw3mg.png


Written by @abdullahw2


ij42VfeLLLL7WCxzYedv2KU7aUqHk3RNyfwHxuumhaYnHDokdbjRLxXkrL7DSe5jzS8jzGDd29gtGG4pvuDJSmxLPGt9GXUQJ72g1AB1fe5qt8DvgzMKW6QWvU4qnL7RCP9XNvs8xoiQDu52RHULmxg9jntMKRVMobRLqEiV5oKKho3MoMJgpUxyzHMbJSmzDNuPnJgSwTrwpTq5YBkjyML1T.gif


Sort:  

Upvoted. Thank You for sending some of your rewards to @null. It will make Steem stronger.

Loading...

Coin Marketplace

STEEM 0.16
TRX 0.17
JST 0.029
BTC 69585.15
ETH 2499.56
USDT 1.00
SBD 2.56