TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-04-2009, 08:45 PM   #1 (permalink)
The Visitor
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Hustle is on a distinguished road
Help php/html form to echo text file contents

Hi, I have a text file which i would like to echo the contents into seperate fields on a php/html form, the contents i would like to echo into text boxes is what is not in capital letters

NAME name-here
ADDRESSLINE1 address-line1
ADDRESSLINE2 address-line2
ADDRESSLINE3 address-line3
PHONEHOME homephoneline

I don't know how to go about doing this, I want to be able to edit the text file, if it is at all possible, thank you
Hustle is offline  
Reply With Quote
Old 03-04-2009, 11:24 PM   #2 (permalink)
The Contributor
 
hello-world's Avatar
 
Join Date: Feb 2009
Posts: 73
Thanks: 30
hello-world is on a distinguished road
Default

Here is a file written by wildhoney.

http://www.talkphp.com/attachments/a...ment-quote.php

and if you want to write a something.

Quote:
<?php
if(isset($_GET['con'])){
$contents = "write.txt";
file_put_contents($contents,$_GET['con']);
}
echo "<form action='".$_SERVER['PHP_SELF']."'><input type=text name=con><input type=submit></form>";

?>
I hope it is helpful.





Edited: By the way I am not php Expert.So wait what others say.

Last edited by hello-world : 03-05-2009 at 12:05 AM.
hello-world is offline  
Reply With Quote
Old 03-10-2009, 07:14 AM   #3 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

Hi, just making sure I understand what you are asking.
The form is not submitted yet, right? It is first displayed and you want to load the information from the text file in the form's textboxes.

If that is the case
you would need to get the contents of the file line by line, then display the line content in the textbox.
I guess something like this:

PHP Code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
$fields
=file('input_file.txt');
foreach (
$fields as $field) {
    
$input=explode(" "$field);
    echo 
"\t<label for=\"$input[0]\">$input[0]:</label>"
    
echo " <input type=\"text\" name=\"$input[0]\" value=\"$input[1]\" /> <br />";
}
?>
<input type="submit" value="Submit" />
</form>
This is of course assuming the input is separated by a space and there is no spaces in the input values.

i don't know if that helped out.

Last edited by tony : 03-10-2009 at 07:17 AM. Reason: adding breaks between input fields and labels
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i display on a php file the content of a text document chikooo Absolute Beginners 13 01-29-2013 11:44 AM
Read Text File in Reverse buildakicker General 9 11-26-2008 06:43 PM
Writing to XML file buildakicker General 8 02-06-2008 08:17 PM
Echoing Text File Rows into Array Display... buildakicker General 11 02-04-2008 07:17 PM
Database export to text file... d4v1d Absolute Beginners 5 01-09-2008 04:30 PM


All times are GMT. The time now is 07:23 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design