Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 04-01-2007, 08:06 PM   #16 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
salch.. take some initiative and follow through with what you're doing one topic at a time. when you get a firm handle on it, move on.

i can't help when every follow up question is as general as 'how'
__________________
Mike
sde is offline   Reply With Quote
Old 04-02-2007, 12:22 AM   #17 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
DJMaze,

I'm not to worried about security at this stage, as the server is only being run on a private machine, especially to run the web-page application I'm creating/developing.

I'll probably look more into security as times goes on, when the application will eventually be run on a properly designed, standalone server.

Currently, I just want to see if I can get certain aspects of my application working, before I finally lock it up.

How do I store information from a form on a page into a .txt file?

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 04-02-2007, 12:26 AM   #18 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
SDE,

OK, can you give be a starting point on how to load information from a text file & drop down menu, into a .txt file?

Just to give me a starting point, as I have a basic outline on how to create the file, but not to save information into it from a form.

Many Thanks, much appreciated!!!
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 04-02-2007, 01:29 AM   #19 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 745
DJMaze is on a distinguished road
PHP Code:
if ($fp fopen('c:/file.txt''w+'))
{
    
fwrite($fp'some data');
    
fclose($fp);

__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 04-02-2007, 01:36 AM   #20 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
PHP:Save MySQL Database

DJMaze,

How do I store the information entered in the following form to a .txt file, then on a separate page, load the information back from the .txt file into the form elements (Text Box & Drop Menu)

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>

<body>
<form action="" method="post" name="New" id="New">
  <input name="Name" type="text" id="Name">
  <select name="Sex" id="Sex">
    <option>Male</option>
    <option>Female</option>
  </select>
  <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 04-02-2007, 08:56 AM   #21 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
how to use post data
PHP Forms
__________________
Mike
sde is offline   Reply With Quote
Old 04-02-2007, 11:03 AM   #22 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
PHP:Save MySQL Database

SDE,

Yes, but how do you store the information from the form into a .txt file upon the submit button being clicked?

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 04-02-2007, 01:50 PM   #23 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
By combining what you've been giving thus far.
PHP Code:
if(isset($_POST['Name'])||isset($_POST['Sex']))
{
  if (
$fp fopen('c:/file.txt''w+'))
  {
    
fwrite($fp$_POST['Name'].'\n');
    
fwrite($fp$_POST['Sex'].'\n');
    
fclose($fp);
  }

__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 04-02-2007, 01:50 PM   #24 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 745
DJMaze is on a distinguished road
fwrite($fp, $_POST['formfield']);

You beat me redhead
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Old 04-02-2007, 11:02 PM   #25 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
PHP:Save MySQL Database

Redhead,

Can the name and sex be stores on one line, but separated with a ; character or something. Then when another record is enter the name and sex for that record will be saved on the next line of the file, and so on....

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 04-03-2007, 12:21 AM   #26 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
do you understand what that script is doing salch? \n is a new line. use what you now know and make it a colon instead of a new line.
__________________
Mike
sde is offline   Reply With Quote
Old 04-03-2007, 01:13 AM   #27 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
PHP:Save MySQL Database

SDE,

Now how do I read what's in the file, and display the "Name" inside a text box, and the "Sex" using normal text on the page?

Many Thanks,
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 04-03-2007, 01:38 AM   #28 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
do you ever go through the php manual? i am usually not a big fan of rtfm replies but the php manual is a huge resource with lots of examples and user comments.

there's a lot of ways to do it.. check these out

PHP: fgets - Manual
PHP: file - Manual
PHP: file_get_contents - Manual (php5)
__________________
Mike
sde is offline   Reply With Quote
Old 04-03-2007, 01:43 AM   #29 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
I would suggest to use \t as delimitor, since a user with mallicius intentions could easily write ';' as a name... But it's a wee bit harder to write <tab> into an input field, where <tab> means jump to next active field.

And by the way Salch, it isn't ill seen to think for one self, on the other hand, it is ill seen, in the long run, to require others do the thinking for you.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 04-03-2007, 04:17 AM   #30 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 745
DJMaze is on a distinguished road
Quote:
Originally Posted by sde View Post
do you ever go through the php manual? i am usually not a big fan of rtfm replies but the php manual is a huge resource with lots of examples and user comments.
Indeed i already got annoyed. I'm outta here (this topic)
__________________

UT: Ultra-kill... God like!
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
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

BB 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 to insert HTML form data into mysql database ? plomon PHP 5 02-06-2005 09:23 AM
Can't see MySql database records in Mozilla monicao PHP 3 05-02-2004 06:19 PM
open another mysql database using phpMyAdmin infinite_root PHP 5 04-28-2004 09:04 PM


All times are GMT -8. The time now is 10:46 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting