Hii this is pradeep here . i am a newbie to PHP .can u help me out.
i hve a file called con.conf(config uration file) tht contains
name:pradeep
place:bangalore
i need to read this file and display the contents in form type in browser . and then gve a submit button so as to edit and update the file .
can u gve me a code for this process.
email:[ REMOVED ]
Jul 29 '07
59 4180
Hi pradeepjain,
I have tried this with the following file: -
name:micahel
-
location:Newcastle
-
name:Steven
-
location:Liverpool
-
name:Jamie
-
location:Liverpool
-
Using the following php
[php]
<?php
$filehandle = fopen("test.txt ","r");
$line=true;
echo '<form method=post action=action.p hp>';
while($filehand le && $line)
{
$line = fgets($filehand le);
if (!empty($line))
{
$str = explode(':', $line);
echo $str[0] . ': <input type="text" name="'.$str[0].'" value="'.$str[1].'"><br />';
}
}
echo '<input type=submit value= submit>';
echo '</form>'
?>
[/php]
This gives me a page with 6 text boxes and labels on.
The text file is currently in the same directory as the php file but that shouldn't make any difference.
Hopefully you will get this finished in time for Saturday and will have learnt a bit more about PHP.
Please take some time after this project to read some php tutorials. This will give you a better understanding of the basics and help you to get better at it very quickly.
Cheers
nathj
wht u ment to say is tht this code is working properly or not..ok 6 text boxes are coming but is the contents being displayed properly..
lke
name(label) micheal(with in a text box) in the page
nathj 938
Recognized Expert Contributor
Yes! It is working correctly. The item on the left of the : in the txt file is the label and the item on the right of the : in the ext file is the contents of the input box.
If you could have been bothered to run this yourself you would see that it is working in the way you described.
Please run this and see! This is after all you rproject and I feel that you are doing very little to help yourself. I keep helping you becasue I am kind and like to see everyone succeed but if you do not help yourself a bit more I'll disappear.
Cheers
nathj
Yes! It is working correctly. The item on the left of the : in the txt file is the label and the item on the right of the : in the ext file is the contents of the input box.
If you could have been bothered to run this yourself you would see that it is working in the way you described.
Please run this and see! This is after all you rproject and I feel that you are doing very little to help yourself. I keep helping you becasue I am kind and like to see everyone succeed but if you do not help yourself a bit more I'll disappear.
Cheers
nathj
ya ok i agree on wht u r saying..but i hve tried it ...but its not working for me here...see this is the code tht i am using.....
[HTML]<html>
<head>
</head>
<body>
<?php
$filehandle = fopen("welcome. txt","r");
$line=true;
echo '<form method=post action=action.p hp>';
while($filehand le && $line)
{
$line = fgets($filehand le);
if (!empty($line))
{
$str = explode(':', $line);
echo $str[0] . ': <input type="text" name="'.$str[0].'" value="'.$str[1].'"><br />';
}
}
echo '<input type=submit value= submit>';
echo '</form>';
?>
</body>
</html>
[/HTML]
u might be saying tht i am not doing any thing..but i am putting a lot of effort..i am reading tht php bible...
nathj 938
Recognized Expert Contributor
In what whay is this not working for you?
Do you have permission to read the text file on your system?
I do not know what you mean when you say it is not working for you. The code I gave in my previous post works just fine for me.
The code you supplied alos works for me. When I change the file name to the test file I have set up it works perfectly. I do not understand what the problem is now.
Cheers
nathj
In what whay is this not working for you?
Do you have permission to read the text file on your system?
I do not know what you mean when you say it is not working for you. The code I gave in my previous post works just fine for me.
The code you supplied alos works for me. When I change the file name to the test file I have set up it works perfectly. I do not understand what the problem is now.
Cheers
nathj
i am jst executing the code i passed u in browser by giving http://localhost/i.html is there any other php settings tht i hve to do..
nathj 938
Recognized Expert Contributor
i am jst executing the code i passed u in browser by giving http://localhost/i.html is there any other php settings tht i hve to do..
Do you have php installed?
what happens if you have page called test.php that has only the following code in it:
[php]
<?php phpInfo() ;?>
[/php]
Run this via //localhost/test.php and tell me what you get on screen.
Also, what web server and O/S are you running on? There are somethingns you need to set up in IIS to get php to work.
Cheers
nathj
Do you have php installed?
what happens if you have page called test.php that has only the following code in it:
[php]
<?php phpInfo() ;?>
[/php]
Run this via //localhost/test.php and tell me what you get on screen.
Also, what web server and O/S are you running on? There are somethingns you need to set up in IIS to get php to work.
Cheers
nathj
i did as u said it gave me a blank screen...
i am using linux os and apache server...
which php to install and how and wht r the conf details
nathj 938
Recognized Expert Contributor
i did as u said it gave me a blank screen...
i am using linux os and apache server...
which php to install and how and wht r the conf details
Hi,
How frustrating, after all this you don't have PHP installed!
You need to go to the main php site and figure this out there, unless someone else can help. I am running PHP on Windows and have never used Linux. The instal process for Windows uses an msi and is all self explanatory.
Perhaps you could post another question asking for help installing php on linux, I know the LAMP (Linux Apache, MySQL, PHP) combination is very popular (if not the most popular) so you will be able to get some help on that. Though ask the question without mentioing this thread.
Hopefully, once installed your code should work fine.
I hope you get this resolved in time - the code will work once the environment is in place.
Cheers
nathj
[HTML]<html>
<head>
</head>
<body>
<?php
$filehandle = fopen("welcome. txt","r");
if(filesize("we lcome.txt")=='0 ')
{
echo "file empty";
}
else
{
$line=true;
echo '<form method=post action=action.p hp>';
while($filehand le && $line)
{
$line = fgets($filehand le);
if (!empty($line))
{
$str = explode(':', $line);
echo $str[0] . ': <input type="text" name="'.$str[0].'" value="'.$str[1].'"><br />';
}
}
echo '<input type=submit value= submit>';
echo '</form>';
}
?>
</body>
</html>
[/HTML]
yahoo !!! the read part is working correctly....
but now writing back to file???
$POST wll do it but the name of the text box???
any ideas on this...
nathj 938
Recognized Expert Contributor
yahoo !!! the read part is working correctly....
but now writing back to file???
$POST wll do it but the name of the text box???
any ideas on this...
Glad we finally got there on that.
As for writing back to the file the $_POST variable is really an array, so you can loop through the array and then write to file when you hit a key() value of name or location. This should sort you out nicely.
Have a go and if you get stuck post the code you've got and I'll have a play around with it.
Cheers
nathj
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: JDJones |
last post by:
I'm trying to write a script that will read from a text list of songs
that I burned onto my CD (Albums011.txt), then write to the database
text the new text made ready for inserting into a database.
The entries from the Albums011.txt look like this:
Wayne Newton - Wild Cool & Swingin' - 03 - But Not For Me.mp3
Wayne Newton - Wild Cool & Swingin' - 04 - Wives And Lovers.mp3 etc.
and I want to manipulate it them to look in the...
|
by: Amy G |
last post by:
I am looking to make this code a little "nicer"... any suggestions???
I want to do a "read+" where I would be able to first read the contents of
the file... then either close the file out or write to the file without
appending. I want to overwrite the content.
vacation_message = "blah blah blah"
f_vm=open("/home/%s/.vacation.msg" %userid, 'r')
lines=f_vm.readlines()
f_vm.close()
|
by: Joan Bos |
last post by:
Hi,
Is there somewhere on the Internet a description of what a .NET
application config file should contain?
For our application, I have to write passwords encrypted in a config
file. The Enterprise Library does have an encryption method, but that
method doesn't just return a value - no - it wants to write the value
immediately to a config file. Except, it always gives an error, because
no config file contents are ever good enough for...
|
by: Jason Heyes |
last post by:
Does this function need to call eof after the while-loop to be correct?
bool read_file(std::string name, std::string &s)
{
std::ifstream in(name.c_str());
if (!in.is_open())
return false;
char c;
std::string str;
|
by: cnu |
last post by:
My program generates a log file for every event that happens in the program.
So, I open the file and keep it open till the end. This is how I open the
file for writing:
<CODE>
public CLogHandler()
{
this.m_fsLog = new FileStream(strTodaysLogFile, System.IO.FileMode.Append,
System.IO.FileAccess.Write, System.IO.FileShare.Read);
this.m_swLog = new StreamWriter(this.m_fsLog);
| |
by: ESPN Lover |
last post by:
Below is two snippets of code from MSDN showing how to read a file. Is one
way preferred over the other and why? Thanks.
using System;
using System.IO;
class Test
{
public static void Main()
|
by: Tibby |
last post by:
I need to read/write not only text files, but binary as well. It seems like on binary files, it doesn't right the last 10% of the file.
--
Thanks
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003
|
by: kepioo |
last post by:
I currently have an xml input file containing lots of data. My objectiv
is to write a script that reports in another xml file only the data I
am interested in. Doing this is really easy using SAX.
The input file is continuously updated. However, the other xml file
should be updated only on request.
Everytime we run the script, we track the new elements in the input
file and report them in the output file.
|
by: =?Utf-8?B?ZGF2aWQ=?= |
last post by:
I try to follow Steve's paper to build a database, and store a small text
file into SQL Server database and retrieve it later. Only difference between
my table and Steve's table is that I use NTEXT datatype for the file instead
of using IMAGE datatype. I can not use SqlDataReader to read the data. I need
your help, Thanks.
-David
(1) I have a table TestFile for testing:
ID int
FileName navrchar(255)
|
by: Kevin Ar18 |
last post by:
I posted this on the forum, but nobody seems to know the solution: http://python-forum.org/py/viewtopic.php?t=5230
I have a zip file that is several GB in size, and one of the files inside of it is several GB in size. When it comes time to read the 5+GB file from inside the zip file, it fails with the following error:
File "...\zipfile.py", line 491, in read bytes = self.fp.read(zinfo.compress_size)
OverflowError: long it too large to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |