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 03-09-2008, 06:16 AM Form to Text file
Extreme Talker

Posts: 189
Trades: 0
can some fix my code please


form page
HTML Code:
<html>
<head>
        
 <title>Untitled</title>

</head>
<body>

<form method="post" action="4.php">
Day: <input type="text" size="10" maxlength="50" name="1"> <br />
Lvl: <input type="text" size="10" maxlength="50" name="2">
<input type="submit" value="Add"> 
</form>

</body>
</html>
processing page (4.php)
PHP Code:
<?php


$$_POST['1'];
$
$_POST['2'];


$myFile "1.txt";
$fh fopen($myFile'a') or die("can't open file");
$
"<br>";
fwrite($fh, $/n);
fwrite($fh, $/n);
$
"**";
fwrite($fh, $/n);
fwrite($fh, $/n);
fwrite($fh, $/n);
fwrite($fh, $/n);
fclose($fh);

?>

Last edited by simster; 03-09-2008 at 07:00 AM..
simster is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-09-2008, 08:41 AM Re: Form to Text file
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
first: what do you try to do?
second: learn the basics
http://www.php.net/manual/en/language.variables.php
Quote:
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
meaning that $1 and $2 will cause errors.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-09-2008, 06:59 PM Re: Form to Text file
Extreme Talker

Posts: 189
Trades: 0
i did that, it still doesnt work

i changed
$1 - $a
$2 - $b
$3 - $c
$4 - $d
simster is offline
Reply With Quote
View Public Profile
 
Old 03-09-2008, 07:20 PM Re: Form to Text file
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
are you receiving any errors?
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 03-09-2008, 07:48 PM Re: Form to Text file
Extreme Talker

Posts: 189
Trades: 0
no the processing page is totally blank and when i check the txt file it didnt add anything to it.
simster is offline
Reply With Quote
View Public Profile
 
Old 03-09-2008, 09:14 PM Re: Form to Text file
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
As tripy suggested, PHP varibles cannot start with a number. Also joining the entire fwrite string will make things much more effecient.

form page:
HTML Code:
<html>
<head>
        
 <title>Untitled</title>
 
</head>
<body>
 
<form method="post" action="4.php">
Day: <input type="text" size="10" maxlength="50" name="var1"> <br />
Lvl: <input type="text" size="10" maxlength="50" name="var2">
<input type="submit" value="Add"> 
</form>
 
</body>
</html>
processing page (4.php)

PHP Code:
<?php
 
$var1 
$_POST['var1'];
$var2 $_POST['var2'];
 
$myFile "1.txt";
$fh fopen($myFile'a') or die("can't open file");
$var3 "<br>";
$var4 "**";
fwrite($fh"$var3\n$var3\n$var1\n$var4\n$var2\n$var4");
fclose($fh);
 
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Form to Text file
 

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.24599 seconds with 12 queries