Beruflich Dokumente
Kultur Dokumente
1 Introduction
The union between these two technologies called back and front
end, is that it is possible what is known as web pages
1.1 Requirement
For the development of a web application with php you must have
minimum knowledge in the following sections:
- Basic knowledge in programming
-Basic knowledge in html
-Xampp
-Basic Knowledge in mysql/sql(optional)
- a text editor of your choice
We will create a folder called proyects where we will host all our
projects
When you want to access the website from the browser you will have
to put localhost/ + the route that you have saved your project, as we
define that would be projects, the route that appears would be
For the creation of databases you can use phpmyadmin that comes
included in xampp, there you can create and store the databases with
which we will work, it is as easy as giving new database and put the
script or put the columns you want
Build a web application with php
We will add the main structure which is the form where we will receive
all the data entered into the website, with the different fields that are
needed.
the access.php declared in the form is where the data will go to be
entered into the database, this will be declared and created later
The index would be as follows, later css will be added to give it style
p
Modify pets
We will create a new page for the modify quotes view, where we will
copy the code that we had in the index page, modifying the title of the
page, the title of the header, the page where the data will be sent in the
modification and the link where we will be redirected in the back button
Build a web application with php
Show
In this view as in the other one we will define the head that contains the
link to the css file, the title and other important things
We will define a table where we will organize the data that will be
shown
Build a web application with php
3.2 CSS
we already have the basic html structure now we need to style it to look
nicer, we will create a .css file in the css directory, we'll use this file to
style all the views we have
in this case we will modify the body of the page, things like giving it a
background,a font, and assigning an image as background
Build a web application with php
We will modify the header to give it more space and make it look
better, we will give it an automatic margin so that it adapts to the
screen, we will make it have a transparent background so that the
background can be seen, a padding so that it gives more space, and a
margin-bottom so that it is separated from the main content
The result is as shown in the image the header has much more space
with respect to the main content
Build a web application with php
We will modify the main container that contains the main section in this
case the registration form, which occupies 85% of the total width of the
screen and its maximum size is 500px to be more responsive design
an its margin is 0 up and down and automatic on the sides
Build a web application with php
As you can see in the image the main form is centered and all inputs
are separated from each other, so we changed the background to
white
We will change the style of the buttons, so that it looks modern and
elegant
you can see in the image the button takes much more space and its
color is blueviolet also the color and size of the font are modifie
Build a web application with php
Build a web application with php
Here we will modify the second button, since the first one was of
submit type, but the second one we are using a <a> tag so that it
behaves like a button, we will do the same as with the previous button
modifying its dimensions, its background and its font color
The button will be the same color as the previous one, and the same
font color you can see
Build a web application with php
as we are using the same css file for all the views, the changes we
have made also affect the other views, for example in this case the
view that will show the appointments looks like this
What we will do is modify the table to give it style, we will give it things
like more space, a background so that it differs from the bottom of the
main page, we will also make the columns have their own space so
that it looks much cleaner
Build a web application with php
the result we will get is this, the space between rows and columns is
bigger and looks much more organized than before
3.3 SQl
We will need a sql database, where we will store the data of the
received quotations, as we have previously installed xampp we also
have local databases that allow us to store data, what we will do is
create a database with the following table
Build a web application with php
3.4 PHP
We will now move on to the functional part of the application where it
will process the data and communicate with the database. Unlike other
php programming languages the way to declare variables is with the $
symbol, for example we will declare a variable that will store an integer
number : $num = 10;.
Something to keep in mind is the inclusion of php code within html
pages, usually when working with php you must include this tag <?php
at the beginning of all documents that include php code, if a page only
include php code is not necessary to close this tag because it will not
cause conflicts, but when you want to include code as in the case of
some views that we have in the web page should be closed the php?>
tag so there is no conflict
The first thing we will do is the connection to the database, in the first
red box we have the connection data to the database, such as the
host, the user, the password and to which database we will connect. In
the second box we have the connection query to the database, where
we will have to pass the variables declared before and finally we have
a conditional that will check if the connection to the database has
existed or fails for any reason
Build a web application with php
Then we will have to make the file that will send the data to the
database.
In the first red box we have an include that imports the code to connect
to the database, then we'll need to declare variables that will store all
the data we'll receive from the form in the views, in the third box we'll
make the sql query that will enter the data into the database and finally
we will make the test successful or fail for some reason
also we will have to make the code that will be in charge to update the
data when we want to make some modification of an appointment, the
code that we will make will be exactly equal to the previous one the
only thing that we will change is the query in charge to make the
update to the data base.
Build a web application with php
Then we will make the file that will bring the data from the database to
show it in the view, this is easier than the previous one because we
only have to bring everything from the database with a simple query
Then what we'll do is to pass to each entry of the form the value of
each of the columns so that they can be modified, as you can see in
the image we're passing it with the tag, php code previously declared
and with
Finally we will make the php code in charge of bringing records from
the database and display them in the view, as seen in the image we
have a query and each column what we do is enter the data for that
column, as the example above this section of php code is within html
code
Build a web application with php
4. Conclusions
If you develop this tutorial step by step as indicated will come to have a
simple application for the assignment of appointments to pets, this is
equally modifiable this tutorial is only a guide as developing a website
but each person is free to customize, just let your imagination fly, and
remember if you can imagine it you can program it
The source code of the web page is housed in the following repository
https://github.com/xltiagoxl/Petsu. This code is a base from which to
guide you through multiple projects