What you Need?
If your server supports PHP you don't need to do anything.
Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support.
However, if your server does not support PHP, you must install PHP.
Php SERVER -- (xampp) download here ---> xampp1.6.8
after installation make sure that MySQL and Apache pannel is running ->
if it is running just click the X button to hide the pannel.
Next you need an Editor to create and edit your PHP codes ( i prefer notepad ++) download here if you want ---> notepad++
then a layout to your site(HTML) if you want base from the scratch its ok, i preferably use template from internet to download (ex. click here to download a sample template --> sample HTML template )
more html template here---->>>> html template
if you done downloading the template you need to unzip or to extract the files
(right click the file and click extract here) and after extracting copy the folder ( CTRL + C)
and paste it to the directory of (XAMPP) in localdisk C and folder xampp----> . c:/xampp/htdocs (if the xampp install in C:/)
now after that open the folder and rename the index.html file to INDEX.PHP by using notepad++(editor)[right click and open with notepad++] now save as it to index.php , then open your browser ( ex. mozilla, explorer) and type --> localhost/slickblue/index.php , ( slickblue- is a folder u can rename it if u want like wise with the index).
so thats it you already have now a template you can use for creating simple website .
next we have to create a login form for a registration to our site to engage accessing to any part to our website.
first we need a login form for our user but first we to create a registration for in order to access to the login form of the user . ( put it anywhere in the lay out as long as its fit to your taste . meaning design it )
the user need to create an account so we need to create a registration form for the user using editor (NOTEPAD++)
--------------> SAVE IT AS A REGISTRATION.PHP (in editor (notepad++) <---------
FILENAME: registration.php
<html>
<body>
<div style="border:1px solid;"><center>
<table border="1"><tr><td>
<form action="register.php" method="post">
USERNAME <input type="text" name="name"><br>
PASSWORD <input type="password" name="password"><br>
FIRST NAME <input type="text" name="fname"><br>
LAST NAME <input type="text" name="lname"><br>
AGE <input type="text" name="age"><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form> </tr></td></table></center>
</div>
</body>
</html>
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
from the registration.php all the data inputted must be cached by a form to save from a database (MYSQL) so we need a form as a catcher from all the data inputted from registration.php
-----> SAVE the FILE as a register.php <------------------
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample") or die("Cannot connect to the database");
$username= ($_POST['username']);
$password = ($_POST['password']);
$fname = ($_POST['fname']);
$lname = ($_POST['lname']);
$age = ($_POST['age']);
mysql_query("insert akoregister set username='".$username."', password='".$password."'");
?>
---------------------------------------------------------------------------------------------------
so all data inputted in the registration form must be saved in dabase (MYSQL) so we need to create a database (mysql) in order to save those data inputted from the user
im preferably used CMD prompt, so click RUN in the START menu type CMD , and then locate the mysql directory using -->
( preferably dont use password)
cd c:\
cd xampp\mysql\bin
mysql -u root
then first you have to create database using the command --> create database sample;
*sample is the database name* if you already have database just type ---> show databases;
and then you have to use the database you create by typing ---> use sample;
* sample is the database name*
after creating database you need to create table by typing ----> create table akoregister(id int not null auto_increment primary key, username varchar(23), password varchar(24), fname varchar(23), lname varchar(24), age int(23));
so you already done creating your database and the table , in order to see the value from the table type usinng ---> describe akoregister;
*akoregister is a table name*
in order to see all information save from the form manually in the database(MYSQL)
----> select * from the akoregister;
* akoregister is a table name *
click here for all list of mysql server code --> mysql command code
--------------------------------------------------------------------------------------
so you already done adding information from form to database(MYSQL) but mostly we need to see all information itself from database to the website or to the browser likewise not only viewing files but mostly deleting ad updating all information from a certain files . so heres the step by step to do that.
first we need to view all the information from the database in order to see a certain user , let we use the information the we add earlier the registration.php
----> SAVE as FILE as VIEW.PHP,<-------------------
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample") or die("Cannot connect to the database");
$query = mysql_query("select * from akoregister order by id desc");
?>
<table border="1">
<tr>
<td>Username</td>
<td>First Name</td>
<td>Last Name</td>
<td>Age</td>
<td>Action</td>
</tr>
<?php
if(mysql_num_rows($query)>0){
while($row= mysql_fetch_array($query)){ ?>
<tr>
<td><?=$row['username']?></td>
<td><?=$row['fname']?></td>
<td><?=$row['lname']?></td>
<td><?=$row['age']?></td>
<td><a href="update.php?id=<?=$row['id']?>">[Edit]</a> <a href="delete.php?id=<?=$row['id']?>">[Delete]</a></td>
</tr>
<?php
}
}
else{
echo "no record";
}
?>
<tr><td colspan="3"><a href="index.php" >[Add new record]</a>
</td></tr>
</table>
-----------------------------------------------------------------------
---> DELETE.PHP <-------
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample") or die("Cannot connect to the database");
$id = $_GET['id'];
mysql_query("delete from akoregister where id='".$id."'");
echo "<script>alert('Record successfuly deleted.');window.location.href='view.php';</script>";
?>
-------------------------------------------------------------------
UPDATE.PHP
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample",$konek) or die("Cannot connect to the database");
$query = mysql_query("select * from akoregister where id='".$_GET['id']."'");
$row = mysql_fetch_array($query);
?>
<html>
<body>
<div style="border:1px solid;">
<form action="edit.php" method="post">
<input type='hidden' name="id" value="<?=($_GET['id'])?$_GET['id']:''?>">
username <input type="text" name="username" value="<?=$row['username']?>"><br>
First name <input type="text" name="fname" value="<?=$row['fname']?>"><br>
Lastname <input type="text" name="lname" value="<?=$row['lname']?>"><br>
Age <input type="text" name="age" value="<?=$row['age']?>"><br>
<input type="submit" value="Update">
<input type="reset" value="Reset">
</form>
<a href="view.php" >[Back to home]</a>
</div>
</body>
</html>
------------------------------------------------------------------
EDIT.php
<?php
$konek = mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample",$konek) or die("Cannot connect to the database");
$username= ($_POST['username'])?$_POST['username']:'';
$fname= ($_POST['fname'])?$_POST['fname']:'';
$lname= ($_POST['lname'])?$_POST['lname']:'';
$age= ($_POST['age'])?$_POST['age']:'';
$id = ($_POST['id'])?$_POST['id']:'';
if($name=="" || $age==""){
echo "<script>alert('Complete all field');history.back();</script>";
}else{
mysql_query("update akoregister set username='".$username."', age='".$age."', fname='".$fname."', lname='".$lname."' where id='".$id."'");
echo "<script>alert('Record successfuly updated.');window.location.href='view.php';</script>";
}
?>
--------------------------------------------------------------
If your server supports PHP you don't need to do anything.
Just create some .php files in your web directory, and the server will parse them for you. Because it is free, most web hosts offer PHP support.
However, if your server does not support PHP, you must install PHP.
Php SERVER -- (xampp) download here ---> xampp1.6.8
after installation make sure that MySQL and Apache pannel is running ->
if it is running just click the X button to hide the pannel.
Next you need an Editor to create and edit your PHP codes ( i prefer notepad ++) download here if you want ---> notepad++
then a layout to your site(HTML) if you want base from the scratch its ok, i preferably use template from internet to download (ex. click here to download a sample template --> sample HTML template )
more html template here---->>>> html template
if you done downloading the template you need to unzip or to extract the files
(right click the file and click extract here) and after extracting copy the folder ( CTRL + C)
and paste it to the directory of (XAMPP) in localdisk C and folder xampp----> . c:/xampp/htdocs (if the xampp install in C:/)
now after that open the folder and rename the index.html file to INDEX.PHP by using notepad++(editor)[right click and open with notepad++] now save as it to index.php , then open your browser ( ex. mozilla, explorer) and type --> localhost/slickblue/index.php , ( slickblue- is a folder u can rename it if u want like wise with the index).
so thats it you already have now a template you can use for creating simple website .
next we have to create a login form for a registration to our site to engage accessing to any part to our website.
first we need a login form for our user but first we to create a registration for in order to access to the login form of the user . ( put it anywhere in the lay out as long as its fit to your taste . meaning design it )
the user need to create an account so we need to create a registration form for the user using editor (NOTEPAD++)
--------------> SAVE IT AS A REGISTRATION.PHP (in editor (notepad++) <---------
FILENAME: registration.php
<html>
<body>
<div style="border:1px solid;"><center>
<table border="1"><tr><td>
<form action="register.php" method="post">
USERNAME <input type="text" name="name"><br>
PASSWORD <input type="password" name="password"><br>
FIRST NAME <input type="text" name="fname"><br>
LAST NAME <input type="text" name="lname"><br>
AGE <input type="text" name="age"><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form> </tr></td></table></center>
</div>
</body>
</html>
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------
from the registration.php all the data inputted must be cached by a form to save from a database (MYSQL) so we need a form as a catcher from all the data inputted from registration.php
-----> SAVE the FILE as a register.php <------------------
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample") or die("Cannot connect to the database");
$username= ($_POST['username']);
$password = ($_POST['password']);
$fname = ($_POST['fname']);
$lname = ($_POST['lname']);
$age = ($_POST['age']);
mysql_query("insert akoregister set username='".$username."', password='".$password."'");
?>
---------------------------------------------------------------------------------------------------
so all data inputted in the registration form must be saved in dabase (MYSQL) so we need to create a database (mysql) in order to save those data inputted from the user
im preferably used CMD prompt, so click RUN in the START menu type CMD , and then locate the mysql directory using -->
( preferably dont use password)
cd c:\
cd xampp\mysql\bin
mysql -u root
then first you have to create database using the command --> create database sample;
*sample is the database name* if you already have database just type ---> show databases;
and then you have to use the database you create by typing ---> use sample;
* sample is the database name*
after creating database you need to create table by typing ----> create table akoregister(id int not null auto_increment primary key, username varchar(23), password varchar(24), fname varchar(23), lname varchar(24), age int(23));
so you already done creating your database and the table , in order to see the value from the table type usinng ---> describe akoregister;
*akoregister is a table name*
in order to see all information save from the form manually in the database(MYSQL)
----> select * from the akoregister;
* akoregister is a table name *
click here for all list of mysql server code --> mysql command code
--------------------------------------------------------------------------------------
so you already done adding information from form to database(MYSQL) but mostly we need to see all information itself from database to the website or to the browser likewise not only viewing files but mostly deleting ad updating all information from a certain files . so heres the step by step to do that.
first we need to view all the information from the database in order to see a certain user , let we use the information the we add earlier the registration.php
----> SAVE as FILE as VIEW.PHP,<-------------------
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample") or die("Cannot connect to the database");
$query = mysql_query("select * from akoregister order by id desc");
?>
<table border="1">
<tr>
<td>Username</td>
<td>First Name</td>
<td>Last Name</td>
<td>Age</td>
<td>Action</td>
</tr>
<?php
if(mysql_num_rows($query)>0){
while($row= mysql_fetch_array($query)){ ?>
<tr>
<td><?=$row['username']?></td>
<td><?=$row['fname']?></td>
<td><?=$row['lname']?></td>
<td><?=$row['age']?></td>
<td><a href="update.php?id=<?=$row['id']?>">[Edit]</a> <a href="delete.php?id=<?=$row['id']?>">[Delete]</a></td>
</tr>
<?php
}
}
else{
echo "no record";
}
?>
<tr><td colspan="3"><a href="index.php" >[Add new record]</a>
</td></tr>
</table>
-----------------------------------------------------------------------
---> DELETE.PHP <-------
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample") or die("Cannot connect to the database");
$id = $_GET['id'];
mysql_query("delete from akoregister where id='".$id."'");
echo "<script>alert('Record successfuly deleted.');window.location.href='view.php';</script>";
?>
-------------------------------------------------------------------
UPDATE.PHP
<?php
mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample",$konek) or die("Cannot connect to the database");
$query = mysql_query("select * from akoregister where id='".$_GET['id']."'");
$row = mysql_fetch_array($query);
?>
<html>
<body>
<div style="border:1px solid;">
<form action="edit.php" method="post">
<input type='hidden' name="id" value="<?=($_GET['id'])?$_GET['id']:''?>">
username <input type="text" name="username" value="<?=$row['username']?>"><br>
First name <input type="text" name="fname" value="<?=$row['fname']?>"><br>
Lastname <input type="text" name="lname" value="<?=$row['lname']?>"><br>
Age <input type="text" name="age" value="<?=$row['age']?>"><br>
<input type="submit" value="Update">
<input type="reset" value="Reset">
</form>
<a href="view.php" >[Back to home]</a>
</div>
</body>
</html>
------------------------------------------------------------------
EDIT.php
<?php
$konek = mysql_connect("localhost","root","") or die("Cannot connect to server");
mysql_select_db("sample",$konek) or die("Cannot connect to the database");
$username= ($_POST['username'])?$_POST['username']:'';
$fname= ($_POST['fname'])?$_POST['fname']:'';
$lname= ($_POST['lname'])?$_POST['lname']:'';
$age= ($_POST['age'])?$_POST['age']:'';
$id = ($_POST['id'])?$_POST['id']:'';
if($name=="" || $age==""){
echo "<script>alert('Complete all field');history.back();</script>";
}else{
mysql_query("update akoregister set username='".$username."', age='".$age."', fname='".$fname."', lname='".$lname."' where id='".$id."'");
echo "<script>alert('Record successfuly updated.');window.location.href='view.php';</script>";
}
?>
--------------------------------------------------------------
No comments :
Post a Comment