Skip to main content

Posts

Showing posts from December, 2023

Our today post will focus on how to implement php class and method

A class is a container for objects, and object is items in class. Class is container that we can store all kinds of obejects, such as variable, function etc. Today we will implement class and objects , property, set, get and the rest. If you look at the php class below, this is exactly how to declare empty php class. Php class container with public objects, function set parameters and gets parameters. In php class below, we created two functions, one to set a value and one to get the value, pass the instance object and its value. Now you can copy the below code for your testing. name = $name; } function getname() { return $this->name; } } $username = new KcFuns(); $username->setname('Kenan Chiquado'); echo "Output:"; echo "Username is: ".$username->getname(); echo "----------------------------------"; ?> Php class several objects function and parameters In our second php class implementation, we will lo...

Our today post will focus on how to create php swith case

Php compare different color and return the match What is switch case in php? To make it simple: switch case is usually a method of comparing two objects to decide true or false, negative or positive action. In php script below we will set a variable container with value color and compare it with different color and see which could match the previous value. Copy the php script below your testing. Php switch case to compare digit number and return the match Another method of comparison is setting up a digit number and compare it with another digit number. While running the below code you can change different digit number to the activity of switch case comparison. Now, you can copy the code below or write it manually for your testing. $d = 5; switch ($d) { case 1: echo "Your favourite number is: 1"; break; case 2: echo "Your favourite number is: 2"; break; case 3: echo "Your favourite number is: 3"; break; case 4: e...

Today we will look into how to implement cUrl in php application

Passing json file via cUrl in php We will implement passing json file via cUrl and submit to next server. cUrl is all about special communication between two or more server. Such as server1.com sending data to server2.com. A lot of beginner had always ask endless question about what is cUrl and what cUrl actually does. A simple answer there is: cUrl is a special communication between two or more server. Now, if you look at json code below, it has been neatly written and indented and ready for testing. Launch your notepad copy the json data below and save it as data.json place it in a folder where you saved other php file. { "id": "1", "image": "image\/chiquado.jpg", "fullname": "Kenan Chiquado", "fulladdress": "Udah, Igbo-eze North LGA, Enugu state, Nigeria", "emailaddress": "2348130802790", "phonenumber": "presschiquado@gmail.com...

How to decode json data and print on user interface stream using php script

Printing data retrieved from json file In our previous tutorials we have shown you how to retrieve database information, encode and print it to json file. Now, we will learn how to decode the same json file and print it to user interface stream. If you look and json data format below this is exactly what we retrieve from our database. Put the json file in the same folder where the next php code will be placed. Below is example of our json file named data.json for this testing. { "id": "1", "image": "image\/chiquado.jpg", "fullname": "Kenan Chiquado", "fulladdress": "Udah, Igbo-eze North LGA, Enugu state, Nigeria", "emailaddress": "2348130802790", "phonenumber": "presschiquado@gmail.com", "username": "Chikwado", "password": "web@design&33", "project": "Local ...

Our today post will focus on how to retrieve information from our database and print it in json file

Opening database retrieve user profile and print in json file In our previous discussion we showed you how to store information in database and display it on html stream. Now, we will implement how to print users details to json file. The below code, you can copy and paste or write it manually for your testing. Copy the below code save it as jsontest.php and run it. if you see message "Success!" this means our profile details was successfully created and printed to json file. connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM webdesign"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $profile = array( 'id' => $row["id"], 'image' => $row['image'], 'fullname' => $row["fullname"], 'fulladdress' => $row["fulladdress"], 'emailaddress' ...

Today we will implement login with cookie using php script

Php login with cookie, provide username and password store it in cookie container This tutorials is assume you have been following up on other tutorials, such as php signup page. You have signup page already, if you don't have any, then I think you need to create one. if you look at the code below this is html form already-made you can copy and paste for our testing. Now, copy the code below or write it manually and save it as index.php and run it to see a nice decorated ligin form. " method="POST"> Enter login details Username "> Password "> Remember me Register Login the user and retrieve the protected page The php script below, copy and paste on top of your html tag, this script should come first before anything else in your application. In this script, this script will open our database, in the table select the appropriate user and compare it with the one typed in the input field, if the two data are equally the same...

How to store user details in cookie and retrieve it during signup

Today we will practice how to store user cookie in our signup application and retrieve then when the form was correctly filled. This will assure visitors that their details was successfully received and that they can login at that moment. For testing purpose, copy the code below or write it manually, save it as cookietest.php and run it. " enctype="multipart/form-data"> Register your profile today Select profile picture Full name Full address Your community, local government and state Email address Phone number Username Password Select project type Select project type Web technology developer Server-side technology developer Database management developer Local and public network developer Gender Male Female Our php script to submit users details and store copy in cookie container Again, copy the below php script and paste it on top of your html file combine it with html above and save it as cookietest.php and run the c...

How to make a signup page using php programming language

After developing your application, it's time to setup a signup page where user can fill a form and submit before they will have access to protected website. Test connection as a mysql user of database First, Let's assume you have access to mysql database. we will test connection to database, once we can connect to database, we are good to go. If you look at our code below it's almost already made you can just copy and paste and start testing. Save it as dbconnect.php and run it. connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Connection was successful!"; ?> Create a new database where we can run testing In below code, our code has been written in place you can copy and paste and start testing. The below code will help us create database with name 'webdesign' after running that code we will have good ready for use database. Save the code as dbcreate.php and run it. connect_error) { die(...

In today post we will focus on how to create php script that could upload picture to server

Before writing script to upload files to server, you have to check ensure that php file upload is set to 'On' in php.ini. Open C:\xampp\php\php.ini file locate the line that says upload_file = On and also change the php upload max setting, example: php_max_upload = 100m. Now save the file, restart the server and start writing php script to upload your file. Step 1: Below is the html code to implement our practice of file upload. You can write it manually or copy and paste. " enctype="multipart/form-data" method="POST"> Uploader Step 2: Php command to target the upload folder, php comman to get file name, php command to check upload status, and php command to validate file extension. Below is our sample code: Step 3: We will use php global object called $_POST to get the image object. And check if the file is image or not, if it's not image the upload status will be set to zero. Below is our sample code: if(isset(...

Our today post will focus on how to implement php hits counter

PHP counter step 1: Have you ever wonder how you can monitor, view or learn how many times your website is been processed by visitors. How many times your website is been browse by your visitors? If your answer is 'no', then it's time to learn all these. You can learn how many times browser processed your website by binding certain php script on top of your webpage. Now, if you look at our php script below, this script will help you count how many times your website was processed at any given moment. To apply our php script below, you can copy and paste this script on top of your webpage before html declaration. PHP counter step 2: Again, the below script, you can copy and put it in a separate file. All you need to do is check time to time and see the digits number your script return. That's exactly how many times your website was processed. Example of the counter: Hits counter While applying our tutorials, if our code spot error, don't hesit...

We will take a closer look on how to bind webpage in python programming language

Today we will take a closer look on how to run python in your webpage under windows operating system. Let's assume you have installed xampp in your windows operating system and have python program installed as well. If you have not done so, then go on to installed xampp in your computer together with python program. Remember to select software version compactible to your computer. When you are ready with these two software, then copy the code below: #!"C:\Users\Administrator\AppData\Local\Programs\Python\Python311-32\python.exe" print ("Content-Type: text/html\n") print (" ") print (" ") print (" ") print (" ") print (" Hello world! ") print (" Welcome to my first python webpage ") print (" ") print (" ") Save the above code as index.py in C:\xampp\htdocs the path should be: C:\xampp\htdocs\index.py On your browser address bar you can type http://localhost/index.py, ...