technogyyan.tech

Hey 


In this tutorial I will  show you how to store html from data in a text file using a php code.

Sometimes new programmers try to store data without a database. Because database coding is hard for new programmers or sometimes we don’t need a database for a small program then we use a text file as a database to store data. So in this tutorial full information with html form css and php code to easily understand to how to create text file using php and develop website. And also you can copy code and try it.



Download Complete code below

Let’s start to Create text file using php


  • Create Html File “Index.html


<html>
<head>
<title>technogyyan.tech</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="main.css"/>
</head>
<body>
<div align="center">
<div class="Top_name">
<h2>Technogyyan.tech</h2>
</div>
<br/>
<br/>
<div class="card_panel" id=" panel_1">
<div class="card_panel_title">
<h3>Welcome To Technogyyan</h3>
</div>
<hr/>
<div class="card_panel_body">
<br/>
<form method="post" action="save.php">
<div class="card_panel_title">
<label>Creator name</label>
</div>
<input class="input_name right_side_color_lin" type="text" name="name" style="font-size: 20px;" value="" placeholder="Creater name" required/>
<br/><br/>
<input type="submit" name="submit" value="Submit" class="style_btn lin_color_left start_btn"/>
</form>
<br/>
</div>
</div>
<br/>
</div>
</body>
</html>

  • Now create a new Css file “Main.css” in same folder

what is cloud storage best cloud storage services

*
{
padding: 0;
margin: 0;
transition: 2s;
body
{
  background: -webkit-linear-gradient(top, 7579ff, b224ef);
  background: -o-linear-gradient(top, 7579ff, b224ef);
  background: -moz-linear-gradient(top, 7579ff, b224ef);
  background: linear-gradient(top, 7579ff, b224ef);
}
.right_side_color_lin
{
  background: -webkit-linear-gradient(right, 7579ff, b224ef);
  background: -o-linear-gradient(right, 7579ff, b224ef);
  background: -moz-linear-gradient(right, 7579ff, b224ef);
  background: linear-gradient(right, 7579ff, b224ef);
}
.lin_color_left
{
   background: -webkit-linear-gradient(left, 7579ff, b224ef);
  background: -o-linear-gradient(left, 7579ff, b224ef);
  background: -moz-linear-gradient(left, 7579ff, b224ef);
  background: linear-gradient(left, 7579ff, b224ef);
}
.style_btn
{
padding:5px;
border: 1px solid white;
border-radius: 20px;
color:white;
width:150px;
}
.Top_name
{
color:white;
margin-top:10px;
}
.card_panel
{
background-color:white;
border-radius: 20px;
width:80%;
margin-top:10%;
box-shadow: 8px 10px 25px black;
border:1px solid b224ef;
}
.input_name
{
padding: 5px;
width:80%;
border-radius: 10px 5px 10px 5px;
text-align: center;
color:white;
}
.card_panel_title
{
color:b224ef;
}
.input_name::placeholder
{
color: white;
text-align: center;
}
@media only screen and (min-device-width:770px)
{
.card_panel
{
width: 30%;
}
}
panel_1
{
display:block;
}
panel_2
{
display:block;
}
.token_style
{
border-radius: 20px;
}
.label_about
{
color:white;
text-decoration: none;
background-color:rgba(255,255,255,0.40);
border-radius: 10px 5px 10px 5px;
width: 100px;
padding: 5px;
text-align: center;
border: 1px solid white;
font-size: 20px;
}
.start_btn
{
padding:10px;
}

Download Code:

  • Now Time To store Data. create a new PHP file “save.php


<?php

if(isset($_POST["submit"]))  //check submit button is pressed
{

$name = $_POST["name"];  // get name from URL

echo($name);  //Print Name

$file = Fopen("db.txt","a+"); //create a file if not exists

fwrite($file,"\n".$name); // fwrite(file_object, data to store);

}
?>


Done.! Now you learned  to PHP File Create/Write store data in a text file using php.


If you want to add new line in data you can add “\n” to create a new line


get PHP free hosting with cpanel MySQL and email()


video tutorial  to store html from data in text file




tag: web development,how to become a web developer
what is business development
how to develop a web site

4 Comments

  1. Bro in your youtube video 2.47 your php file symbol is changed to google symbol. i cannot get that.it is shown as text file for me

    ReplyDelete
    Replies
    1. Bro. Just right click your file-Click open with-more app's- select chrome. Check "always open .php file" done.

      Delete

Post a Comment

Previous Post Next Post