Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,160,790 members, 7,844,562 topics. Date: Wednesday, 29 May 2024 at 11:41 PM |
Nairaland Forum / Maekhel's Profile / Maekhel's Posts
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (of 26 pages)
Webmasters / Re: Help Me Out With Register.php by maekhel(m): 7:26pm On Mar 12, 2015 |
Pasting ur html form code might be helpful |
Programming / Simple CRUD Application In PHP And Mysql – Part 3 by maekhel(m): 11:20am On Mar 11, 2015 |
Welcome guys to the third part of the Simple CRUD application In PHP and MySQL. In the previous part, we looked at setting up our working environment and directory structure. We have also created a database and table our application will be using. If your just joining, please refer to the previous parts so as to catch up. In this part, we will get to the meat of the application and start coding. We will be creating our database connection file (connect.php) and also create staff file (create.php). Since this tutorial is about database interactions, we must first establish our database connection with which we will use subsequently to connection our database and perform database operations. Open conncet.php file create from previous part, remember this file is in the db folder inside our main CRUD folder. This file should be empty when opened. Now copy and paste the code below into it. <?phpWhat this code does is to connect to our database. As you can see, am using the mysqli extension which support both procedural and OOP concept. But we will be using the OOP part of it. First I created some variables to hold my database details (these are just mine, remember to change them to your own details). Then a $db variable to hold the database connection which we can always refer to. The mysqli accepts 3 arguments (database server, database user and databse password) and an optional 4th argument (database name). I then went further to check if our database connection was successful using $db->connect_errno. What this does is return an error number if the database connection was not successful hence we echo an appropriate error message. Having our database connection ready, we can now start performing database operations on that database. Now open the create.php file, this should also be empty. First thing to do is include our database connection file in the file so as to be able to make use of the database connection created earlier. I used the require() to include the file. You can read more about PHP file inclusion. <?phpIts time to create the HTML form that will accept inputs that will be stored in our database. Copy and paste the code snippets below just after the closing PHP tag (?>. <!DOCTYPE html>This markup is quite straightforward, so I won’t be explaining each of since this is not an HTML tutorial. But there some few things to point out. If you noticed, there are two <span> tags with class error and success respectively. The <span> will display our error and success message respectively. We will update it later. Now to the fun part, the PHP mechanism that will process the form data and insert them into the database. From our form markup, we are using the POST method and the form is submitting to itself since the action attribute is empty. Copy and paste the code below in between the PHP tags (<?php and ?> but after the file inclusion. $error = ""; //variable to hold our form error messageFirst I declared some empty variable which will hold our error or success message. I then check to make sure the create button of the form is clicked. If the button has been clicked, I then collect the form data through the global PHP array ($_POST) and assign these values variables. I also used the trim() to remove white/blank spaces from both the left and right side of the form data. Then I further check to make sure all the form fields are filled else an error message. If the forms fields are fill, we can move to insert the details into the database. As you can see, am using prepared statement. Prepared Statements make our query more secured compared to just doing normal query. Maybe I will do a tutorial on prepared Statements later. Using the $db->prepare(), which accept normal SQL query but in a different way. I used placeholders instead of actual values for the name, position and bio respectively. For the joined field, I used the MySQL NOW() which will return the current date and time when the query is performed. Now that will have prepared the query, it time to bind params which will replace the placeholders. I assigned this prepare to a variable called $insert which we can later use as reference. We do that using the bind_param(). This method accepts 2 arguments, the first is the data type of the placeholder (in our case which are all string values), so that why I have ‘sss’. Each s stands for each string value. The second argument is a list of the actual values that will replace the placeholders. Since we have already assigned these values to variables, we just pass the variables as the list of value of the second argument. After the binding is to now execute the whole query using execute(). Now if the query was executed successfully we redirect to the index.php page (which we will create later) using the header(). Update your markup the reflect the error or success message as below: <span class="error"><?php if(isset($error)) echo $error;?></span>The complete code for the create.php file is shown below: <?phpThat’s the end of this part, see you in the next part. Don’t wanna miss the next tutorial, subscribe to our newsletter. If you have any questions or suggestions as regards this tutorial, kindly leave them in the comment form below. I will like to hear from you. Subscribe to our newsletter and join subscribers who are already receiving blog updates directly in their mail box. Source: http://tutorialslodge.com/simple-crud-application-in-php-and-mysql-part-3/ 1 Like |
Webmasters / Simple CRUD Application In PHP And Mysql – Part 3 by maekhel(m): 11:13am On Mar 11, 2015 |
Welcome guys to the third part of the Simple CRUD application In PHP and MySQL. In the previous part, we looked at setting up our working environment and directory structure. We have also created a database and table our application will be using. If your just joining, please refer to the previous parts so as to catch up. In this part, we will get to the meat of the application and start coding. We will be creating our database connection file (connect.php) and also create staff file (create.php). Since this tutorial is about database interactions, we must first establish our database connection with which we will use subsequently to connection our database and perform database operations. Open conncet.php file create from previous part, remember this file is in the db folder inside our main CRUD folder. This file should be empty when opened. Now copy and paste the code below into it. <?phpWhat this code does is to connect to our database. As you can see, am using the mysqli extension which support both procedural and OOP concept. But we will be using the OOP part of it. First I created some variables to hold my database details (these are just mine, remember to change them to your own details). Then a $db variable to hold the database connection which we can always refer to. The mysqli accepts 3 arguments (database server, database user and databse password) and an optional 4th argument (database name). I then went further to check if our database connection was successful using $db->connect_errno. What this does is return an error number if the database connection was not successful hence we echo an appropriate error message. Having our database connection ready, we can now start performing database operations on that database. Now open the create.php file, this should also be empty. First thing to do is include our database connection file in the file so as to be able to make use of the database connection created earlier. I used the require() to include the file. You can read more about PHP file inclusion. <?phpIts time to create the HTML form that will accept inputs that will be stored in our database. Copy and paste the code snippets below just after the closing PHP tag (?>. <!DOCTYPE html>This markup is quite straightforward, so I won’t be explaining each of since this is not an HTML tutorial. But there some few things to point out. If you noticed, there are two <span> tags with class error and success respectively. The <span> will display our error and success message respectively. We will update it later. Now to the fun part, the PHP mechanism that will process the form data and insert them into the database. From our form markup, we are using the POST method and the form is submitting to itself since the action attribute is empty. Copy and paste the code below in between the PHP tags (<?php and ?> but after the file inclusion. $error = ""; //variable to hold our form error messageFirst I declared some empty variable which will hold our error or success message. I then check to make sure the create button of the form is clicked. If the button has been clicked, I then collect the form data through the global PHP array ($_POST) and assign these values variables. I also used the trim() to remove white/blank spaces from both the left and right side of the form data. Then I further check to make sure all the form fields are filled else an error message. If the forms fields are fill, we can move to insert the details into the database. As you can see, am using prepared statement. Prepared Statements make our query more secured compared to just doing normal query. Maybe I will do a tutorial on prepared Statements later. Using the $db->prepare(), which accept normal SQL query but in a different way. I used placeholders instead of actual values for the name, position and bio respectively. For the joined field, I used the MySQL NOW() which will return the current date and time when the query is performed. Now that will have prepared the query, it time to bind params which will replace the placeholders. I assigned this prepare to a variable called $insert which we can later use as reference. We do that using the bind_param(). This method accepts 2 arguments, the first is the data type of the placeholder (in our case which are all string values), so that why I have ‘sss’. Each s stands for each string value. The second argument is a list of the actual values that will replace the placeholders. Since we have already assigned these values to variables, we just pass the variables as the list of value of the second argument. After the binding is to now execute the whole query using execute(). Now if the query was executed successfully we redirect to the index.php page (which we will create later) using the header(). Update your markup the reflect the error or success message as below: <span class="error"><?php if(isset($error)) echo $error;?></span>The complete code for the create.php file is shown below: <?phpThat’s the end of this part, see you in the next part. Don’t wanna miss the next tutorial, subscribe to our newsletter. If you have any questions or suggestions as regards this tutorial, kindly leave them in the comment form below. I will like to hear from you. Subscribe to our newsletter and join subscribers who are already receiving blog updates directly in their mail box. Source: http://tutorialslodge.com/simple-crud-application-in-php-and-mysql-part-3/ |
Webmasters / Re: I Need A Website Designer by maekhel(m): 11:21pm On Mar 10, 2015 |
Let's discus: WhatsApp: 07032047179 Email: meziemichael@gmail.com |
Webmasters / Re: Bloggers, Drop Your Blog Link For Review by maekhel(m): 12:02pm On Mar 10, 2015 |
Programming / Re: Simple CRUD Application In PHP And Mysql – Part 2 by maekhel(m): 5:46am On Mar 10, 2015 |
adenijiayo:thanks |
Programming / Simple CRUD Application In PHP And Mysql – Part 2 by maekhel(m): 10:03am On Mar 09, 2015 |
Welcome guys, this is the second part of the Simple CRUD Application In PHP and MySQL series. In the first part of the tutorial series, I did an overview of the application we will be developing. In this part, we will be setting up our working environment and also create our database. Lets begin. Setting Up Working Environment This tutorial assumes you already have a local server (LAMP, WAMP, MAMP etc) installed and configured on your computer. You will also need a text editor (like notepad++, sublime text etc) for writing your codes. In my case am using Sublime Text 3. Got all this in place, now we setup our working directory and folder structures. In your root folder (usually “www folder” or “htdocs folder”), create a new folder and name it CRUD. This folder will be the parent folder for our application. It will contain all other folders and files. Now create another folder inside the CRUD folder called db. The db folder will hold our file that connect to our database. Inside the db folder, create a PHP file and name it connect.php. Now navigate back to the parent folder (CRUD folder) and create the following files: index.php, create.php, edit.php, view.php, delete.php and styles.css. You should a directory structure similar to below: Having gotten the working environment and directory structure setup. Its time to create our database and table. Creating Our Database and Table Structures Our database name will be called crud and it will contain a single table called staff. The staff table will have 4 fields/columns. The columns will include an id, name, position, joined and bio. The id field will be an auto-increment INT field and will be the primary key. The name and position will be a VARCHAR field that will hold the name and position of staff respectively. The joined field is a DATETIME field that will hold the date and time the staff joined. And lastly the bio field will be a TEXT field that hold bio-data of the staff. Open your MySQL client (PHPMyAdmin in my case) and create a database called crud and create a table called staff with the fields above. You should have a structure as below: Here is the SQL code to create the table: CREATE TABLE staff (In the next part of this Simple CRUD Application In PHP And MySQL series, we will start the actual coding our CRUD application. Don’t wanna miss the next tutorial? then subscribe to our newsletter to get tutorial update directly in your mail box. See you in the next part. . Your views, comments, suggestions and questions counts, drop them in the comment form below Subscribe to our newsletter and join subscribers who are already receiving blog updates directly in their mail box. source: http://tutorialslodge.com/simple-crud-application-in-php-and-mysql-part-2/ |
Webmasters / Simple CRUD Application In PHP And Mysql – Part 2 by maekhel(m): 9:57am On Mar 09, 2015 |
Welcome guys, this is the second part of the Simple CRUD Application In PHP and MySQL series. In the first part of the tutorial series, I did an overview of the application we will be developing. In this part, we will be setting up our working environment and also create our database. Lets begin. Setting Up Working Environment This tutorial assumes you already have a local server (LAMP, WAMP, MAMP etc) installed and configured on your computer. You will also need a text editor (like notepad++, sublime text etc) for writing your codes. In my case am using Sublime Text 3. Got all this in place, now we setup our working directory and folder structures. In your root folder (usually “www folder” or “htdocs folder”), create a new folder and name it CRUD. This folder will be the parent folder for our application. It will contain all other folders and files. Now create another folder inside the CRUD folder called db. The db folder will hold our file that connect to our database. Inside the db folder, create a PHP file and name it connect.php. Now navigate back to the parent folder (CRUD folder) and create the following files: index.php, create.php, edit.php, view.php, delete.php and styles.css. You should a directory structure similar to below: Having gotten the working environment and directory structure setup. Its time to create our database and table. Creating Our Database and Table Structures Our database name will be called crud and it will contain a single table called staff. The staff table will have 4 fields/columns. The columns will include an id, name, position, joined and bio. The id field will be an auto-increment INT field and will be the primary key. The name and position will be a VARCHAR field that will hold the name and position of staff respectively. The joined field is a DATETIME field that will hold the date and time the staff joined. And lastly the bio field will be a TEXT field that hold bio-data of the staff. Open your MySQL client (PHPMyAdmin in my case) and create a database called crud and create a table called staff with the fields above. You should have a structure as below: Here is the SQL code to create the table: CREATE TABLE staff (In the next part of this Simple CRUD Application In PHP And MySQL series, we will start the actual coding our CRUD application. Don’t wanna miss the next tutorial? then subscribe to our newsletter to get tutorial update directly in your mail box. See you in the next part. . Your views, comments, suggestions and questions counts, drop them in the comment form below Subscribe to our newsletter and join subscribers who are already receiving blog updates directly in their mail box. source: http://tutorialslodge.com/simple-crud-application-in-php-and-mysql-part-2/ |
Programming / Simple CRUD Application In PHP And Mysql by maekhel(m): 7:02pm On Mar 08, 2015 |
I will be showing you how to create a simple CRUD application in PHP and MySQL. By the way, CRUD is an abbreviation for Create Read, Update and Delete. A CRUD application is a type of application that does database interactions (inserting, selecting, updating, deleting etc). When you are just learning the PHP programming language, as you advance in learning to database interactions, there will be a need to create a simple application that can carry out some major database operations like SELECT, INSET, UPDATE, DELETE etc. So this tutorial will be walking you through the process of creating a simple CRUD application in PHP and MySQL. Before we get our hands dirty, let take a look at what will be be developing, Our final application will look similar top the image below: Am going to break this tutorial to series, each part covering a particular database operation so as to make the tutorial easy to follow and understand. This first part is going to be an overview of the whole tutorial. This CRUD application will be built using a OOP concept (though minimal). If you are new to the OOP concept, reading this post Introduction To OO PHP will be helpful. This simple CRUD application will have the capability to create new staff with the the following details: name, position, joined date and bio data. Also the ability to read (view) staff details, update staff details and as well delete staff from the database. Pardon me for coming up with this idea, but since I want something simple, this was the idea that came to my head. I will try as much as possible to make this tutorial simple enough. As I said earlier, we won’t be doing anything in this part of the tutorial, just an overview of the whole tutorial. In the next part of the simple CRUD application in PHP and MySQL series, we will be setting up our working environment and as well creating our database and relevant table. Don’t wanna miss the next tutorial? then subscribe to our newsletter to get tutorial update directly in your mail box. See you in the next part. Subscribe to our newsletter and join subscribers who are already receiving blog updates directly in their mail box. source: http://tutorialslodge.com/simple-crud-application-in-php-and-mysql/ |
Webmasters / Simple CRUD Application In PHP And Mysql by maekhel(m): 6:47pm On Mar 08, 2015 |
I will be showing you how to create a simple CRUD application in PHP and MySQL. By the way, CRUD is an abbreviation for Create Read, Update and Delete. A CRUD application is a type of application that does database interactions (inserting, selecting, updating, deleting etc). When you are just learning the PHP programming language, as you advance in learning to database interactions, there will be a need to create a simple application that can carry out some major database operations like SELECT, INSET, UPDATE, DELETE etc. So this tutorial will be walking you through the process of creating a simple CRUD application in PHP and MySQL. Before we get our hands dirty, let take a look at what will be be developing, Our final application will look similar top the image below: Am going to break this tutorial to series, each part covering a particular database operation so as to make the tutorial easy to follow and understand. This first part is going to be an overview of the whole tutorial. This CRUD application will be built using a OOP concept (though minimal). If you are new to the OOP concept, reading this post Introduction To OO PHP will be helpful. This simple CRUD application will have the capability to create new staff with the the following details: name, position, joined date and bio data. Also the ability to read (view) staff details, update staff details and as well delete staff from the database. Pardon me for coming up with this idea, but since I want something simple, this was the idea that came to my head. I will try as much as possible to make this tutorial simple enough. As I said earlier, we won’t be doing anything in this part of the tutorial, just an overview of the whole tutorial. In the next part of the simple CRUD application in PHP and MySQL series, we will be setting up our working environment and as well creating our database and relevant table. Don’t wanna miss the next tutorial? then subscribe to our newsletter to get tutorial update directly in your mail box. See you in the next part. Subscribe to our newsletter and join subscribers who are already receiving blog updates directly in their mail box. source: http://tutorialslodge.com/simple-crud-application-in-php-and-mysql/ |
Programming / Re: How Do I Connect My System To A Wifi ? by maekhel(m): 2:05pm On Mar 07, 2015 |
successmart:most routers are passworded, so u av to meet d owner or network admin fr d password |
Programming / Re: Need Single Page Website Tutorial by maekhel(m): 1:59pm On Mar 07, 2015 |
sammybrainy:what exactly do u want, a tutor or a website? 07032047179 |
Software/Programmer Market / Re: 5 Free For First 5 Requests | Hug A Geek by maekhel(m): 1:44pm On Mar 07, 2015 |
I need this theme ICONIC ONE PRO: http://themonic.com/iconic-one-pro/ |
Software/Programmer Market / Re: Expert Joomla Website Developer Needed by maekhel(m): 1:34pm On Mar 07, 2015 |
Amokwe:meziemichael@gmail.com lets discuss |
Webmasters / Re: Help Transfer Files by maekhel(m): 1:22pm On Mar 07, 2015 |
Aspireahead:yea. u cn also drop ur challenges on d blog too |
Webmasters / Re: Help Transfer Files by maekhel(m): 12:08pm On Mar 07, 2015 |
Webmasters / Re: How Much Will You Charge For Creating A Professional Blog? by maekhel(m): 10:12am On Mar 04, 2015 |
Godditex: www.tutorialslodge.com Check nd lets discus on meziemichael at gmail dot com |
Education / Re: Funaab 2014/2015 Direct Entry Aspirant. Meet Here >>>cont.>>> by maekhel(m): 8:06am On Feb 23, 2015 |
mrng guys, I want to apply for this year's DE and want to choose Funaab as my second choice. pls wat is my chance of being admitted. |
Webmasters / Re: Drop A Link To Your Best Post Of The Week Here by maekhel(m): 7:07am On Feb 22, 2015 |
All You Need To Know About HTML Links http://tutorialslodge.com/all-you-need-to-know-about-html-links/ |
Webmasters / Re: How To Create Download Link In Html. by maekhel(m): 7:04am On Feb 22, 2015 |
you can just point the download link to the file you want downloaded |
Webmasters / Re: 2 Intern Positions For Male & Female Web Designers At WBRL, Ikeja by maekhel(m): 7:02am On Feb 22, 2015 |
tundewoods:how much are you willing to pay |
Webmasters / Re: Top Quality Web Designer And Developer Wanted by maekhel(m): 6:59am On Feb 22, 2015 |
greenmouse:bro comprehending is a great problem. |
Webmasters / Re: Make More Money Site Owners by maekhel(m): 6:26am On Feb 22, 2015 |
www.tutorialslodge.com support@tutorialslodge.com |
Webmasters / All You Need To Know About HTML Links by maekhel(m): 8:07pm On Feb 18, 2015 |
In this tutorial, I will try as much as possible to discuss all you need to know about HTML links. I will be covering various types of links and how to create them with relevant examples. What Is A link? Literally the word link means connection between places, persons, events or things. So also does it have similar meaning in web development but this time its a connection between documents, images, files etc. Link is abbreviation of hyperlink. According to Wikipedia, hyperlink is a reference to data that the reader can directly follow either by clicking or by hovering. A hyperlink points to a whole document or to a specific element within a document. Links are found in nearly all web pages, links allows users to click their way from page to page. A link is not necessarily have to be a text link, there are other types of links which include and is not limited to the following: image links, music links, video link, link to an email (mailto). There are difference types of links which I will cover shortly. How Do I Create Links Getting bored about the links theory above? same here to. So how do I create links. HTML links are created using the <a> tag. See the syntax below: <a href="location">Text</a>The <a> indicate the beginning of the link while the </a> denotes the end of the links. The text in between the opening and closing tags (<a></a> is what the user will see and be able to click on. The href, which means hypertext reference is used to point to the location where you want the users to go if they click on the link. Below is a more practical example of the link which takes the users to our homepage (www.tutorialslodge.com) when clicked. <a href="http://www.tutorialslodge.com">Tutorials Lodge</a>Noticed the “http://” in the URL above? will cover that in the next section. You might have as well noticed while browsing some websites, that when you click some links, its opens a new tab in your browser, some opens in the current tab you are in, others opens in an entirely new browser’s window. Let me quickly explain why there are such difference. There is something called link target and link targets are listed below with their explanation. _blank: This opens the page in a new tab on the browser’s window. _self: This opens the page in the current browser window. This is the default. parent: This opens the page in a parent frame. _top: This opens the page in the full body of the browser’s window. Let see our these targets are being used. <a href="http://www.google.com" target="_parent">Home</a>We have so far created text links, let see how to create an image link. The syntax is quite similar, just that the <img> makes it different. See below: <a href="#"><img src="image.jpg" alt="alternate text" /></a> As you can see from above, I only embed the <img> tag within the <a> tag. The “#” is just a placeholder which you should substitute with your actual location. Internal Links Internal links can be of two types: linking to a local page which is within the entire website and linking to a section within a particular page. Relative urls are used in the local links. Let see an example <a href="about-us.html">About Us</a>The link above will take the user to the about us page of the website. about-us.html is called a relative link. To make a link go to a particular section of a webpage, you will have to take note of the id name if that particular section. An example will make it more clearer. <a href="#main-content">Skip to main content</a>Once the link is clicked, the user will be taken to down to the #main-content div (section). External Links Like I say above, there are relative urls and also there are absolute urls. To link to an external website, say www.google.com. You will have to pass the absolute path to the href. <a href=http://www.google.com>Google</a>I said would explain what “http://” does earlier. It somehow indicates you are pointing to an external website. If you leave out the “http://” from the url, it will be processed as if it was an internal link. Say for example, your main website url is www.sitename.com and you left out the “http://” fro the external link, when you check where the link is pointing to, you will see something like “www.sitename.com/www.google.com”. So it is very important to include the “http://” in the url of an external link. Conclusion I hope you find this tutorial helpful. In my next post, I will be talking on styling your links with CSS. So do subscribe to this blog so as not to miss out. You can drop your comments and questions in the below. source: http://tutorialslodge.com/all-you-need-to-know-about-html-links/ 1 Like |
Software/Programmer Market / Re: Urgent Need Of A Very Good Programmer. There Is A Job by maekhel(m): 9:09pm On Feb 15, 2015 |
sunylatsega:wat type of project are we talking abt here |
Webmasters / Re: Hello Developers. I Want A Little Explanation Of How I Can Style My Html Documen by maekhel(m): 7:36pm On Feb 15, 2015 |
Webmasters / Re: Exchange Links Here-to Get More Traffic by maekhel(m): 6:25am On Feb 13, 2015 |
Programming / Re: PHP File Inclusion by maekhel(m): 8:16pm On Feb 08, 2015 |
tresz:u right there |
Webmasters / Re: Web Guru Needed... I Need A Website .. by maekhel(m): 6:29pm On Feb 08, 2015 |
ifyalways:meziemichael@gmail.com |
Webmasters / Re: Are There Any Unemployed App/Software/Web Designers & Programmers On Nairaland? by maekhel(m): 3:34pm On Feb 08, 2015 |
Jeffflo:meziemichael@gmail.com let discus it |
Webmasters / Re: Are There Any Unemployed App/Software/Web Designers & Programmers On Nairaland? by maekhel(m): 3:33pm On Feb 08, 2015 |
Username: maekhel How many hours you have per day for freelance/ remote work: 6 Skills: HTML5, CSS3, PHP, MySQL, JavaScript, JQuery |
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (of 26 pages)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 76 |