Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-05-2006, 07:40 PM Data stored in files
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
Hi!
Can anyone help me with this? I’m trying to learn PHP and MySQL really hard but there is just too much to learn and I need to publish my website before July. All I need is a raw PHP code. I can adjust it to my needs. Now, here is what I need:
There will be a form asking for visitors e-mail, name and country (dropdown). That means 3 windows where “country” would be a drop-down choice of pre-defined countries. I need the data to be stored in a file. Using a database would be just too much trouble at this point. After a person submitted their details I want the system to send an e-mail saying they’ve successfully registered and so on.
Is this doable with just PHP? If not, I could do without sending automated e-mails. But I really need that email, name and country data stored in a file.
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)
frofi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-06-2006, 01:39 AM Re: Data stored in files
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
just put the code for the <select> in a included file

include("page_with_select.ext")
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-11-2006, 06:22 AM Re: Data stored in files
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
Thanks. I'll try.
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)
frofi is offline
Reply With Quote
View Public Profile
 
Old 07-18-2006, 09:08 AM Re: Data stored in files
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
Quote:
Originally Posted by chrishirst
just put the code for the <select> in a included file

include("page_with_select.ext")
OK. I've spent a few days figuring out what you mean. Unfortunately, I don't see how "include" can store any information from a form into a flat file. As far as I know, "include" is only good for calling pieces of whatever code from an external file so you don't have to include the same code in every page. I need to use "fwrite" with "a" parameter to append every submited info to the same file. There are 4 windows in my form. What I need is a code that stores these 4 strings in one line and then appends another user's info (always 4 strings) in another line. I've managed to make a form that works and in the end display's the submitted info and error messages, but I can't find a way how to write this info into a flat file.
I would also need a code that would send an e-mail to every user after they submitted the form.
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)

Last edited by frofi; 07-18-2006 at 09:11 AM..
frofi is offline
Reply With Quote
View Public Profile
 
Old 07-18-2006, 11:55 AM Re: Data stored in files
Mad182's Avatar
Skilled Talker

Posts: 54
Name: Madars
Location: Latvia
Trades: 0
OK, I wrote something like that, If I understand you right.

Make files index.php and data.txt. File data.txt shoud be writable. Here is the code for index.php:

PHP Code:
<?php 
error_reporting 
(E_ALL E_NOTICE); 
if (isset(
$_POST['name'])) 
{
$name htmlspecialchars($_POST['name']); 
$mail htmlspecialchars($_POST['mail']);
if(
strstr($name,"|") or strstr($mail,"|")){
die(
"Can't use |.");

$country $_POST['country'];
$ip $_SERVER["REMOTE_ADDR"];
$newdata = array($name$mail$country$ip);
$newdata implode("|"$newdata);
$db fopen("data.txt""a+");
    if (!
$db) {
    print(
"<b>Error!</b><br />Error while writing data.");
    exit;
    }
fwrite($db$newdata."\n"); 
fclose($db);
print(
"<b>Thanks!</b><br />Yaur data successfuly added!"); 
exit; 

?>
 <html>
<head>
<title>Add info</title>
</head>

<body>
<form action="index.php" method="post">
Name: <input type="text" name="name" /><br />
E-mail: <input type="text" name="mail" /><br />
Country: <select name="country" size="1"> 
<option value=""></option>                
<option value="USA">USA</option> 
<option value="GB">GB</option> 
<option value="Germany">Germany</option> 
<option value="Latvia">Latvia</option> 
</select><br />
<input type="submit" value="Do it :)" />
</form>
</body>
</html>
__________________
There's no place like 127.0.0.1

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Mad182; 07-18-2006 at 12:11 PM..
Mad182 is offline
Reply With Quote
View Public Profile Visit Mad182's homepage!
 
Old 07-27-2006, 07:02 AM Re: Data stored in files
frofi's Avatar
Extreme Talker

Posts: 236
Location: London
Trades: 0
Quote:
Originally Posted by Mad182 View Post
OK, I wrote something like that, If I understand you right.

Make files index.php and data.txt. File data.txt shoud be writable. Here is the code for index.php:
Thanks! That's what I've been looking for. I've already done it in a similar manner. I do not collect IP's but I write submitted info into a comma and line separated file just like your code. It seems I always figure things out before somebody tells me how.
__________________
THE FORCE is with me at last! All I need now is some TALKUPATION ;)

Last edited by frofi; 07-27-2006 at 07:16 AM..
frofi is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Data stored in files
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23596 seconds with 12 queries