Raised This Month: $ Target: $400
 0% 

Form information


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 12-06-2006 , 16:03   Form information
Reply With Quote #1

Would anyone know how to make information in a form (HTML) be sent and saved in a .txt file?

I have

Code:
<form action="unsure" name="form1" method="post">
<input type="text" name="Name" value="Name?"><br>
<textarea>Comments?</textarea><br>
<input type="submit" name="submit" value="Submit">
</form>
Not sure how to make that information save into a .txt file for me to view later.

I have done a bit of research an have seen the word CGI a couple times, if this is leading down the right path could I get a little more information?

Thanks in advance
Dizzy is offline
Send a message via AIM to Dizzy
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 12-06-2006 , 20:18   Re: Form information
Reply With Quote #2

Use PHP in cooperation with your html form.
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 12-06-2006 , 20:33   Re: Form information
Reply With Quote #3

Hmm, would you know of a tutorial I could read on this?

I figure you can't do with with javascript and html so I am going to need to learn some PHP inorder to get this working.

Thanks in advance!
Dizzy is offline
Send a message via AIM to Dizzy
Zenith77
Veteran Member
Join Date: Aug 2005
Old 12-06-2006 , 22:08   Re: Form information
Reply With Quote #4

Learn the basics of PHP, and it should cover it. I haven't used PHP in a long while, but if I had, I probably would have wiped up some code for you ;).
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 12-06-2006 , 22:16   Re: Form information
Reply With Quote #5

Thanks for the information guys, I wasn't sure if this HAD to be done a special way or you could just code it.
Dizzy is offline
Send a message via AIM to Dizzy
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 12-07-2006 , 17:34   Re: Form information
Reply With Quote #6

Ack, not sure if it's just me, but PHP code is kinda difficult for me to grasp.

I can't figure out how to get it to save Getting me angry
Dizzy is offline
Send a message via AIM to Dizzy
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 12-07-2006 , 18:34   Re: Form information
Reply With Quote #7

This was just a quick run through. Let me know how it works for you.
PHP Code:
<html>
<head>
    <title>My Form</title>
</head>
<body>
<?php
if(!empty($_POST['FORM_INPUT_NAME'])) //if form was submitted write to file and show sucess.
{
    
$form_name $_POST['FORM_INPUT_NAME'];
    
$form_comment $_POST['FORM_INPUT_COMMENT'];

    
$file_name "myfile.txt";

    
$filestring "Name: ".$form_name."\nComment: \n".$form_comment."\n";

    if(!
$filehandle fopen($file_name 'a'))
    {
        die(
"Cannot open file");
    }
    if(
fwrite($filehandle,$filestring) === false//if it is false not 0 or empty
    
{
        die(
"Cannot write to file");
    }
    
fclose($filehandle);

    echo 
"Thank you for your submission.";
}
else 
//if nothing was submitted show the form.
{
?>
    <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
    Name:<br />
    <input type="text" name="FORM_INPUT_NAME" size="32" /><br />
    Comment:<br />
    <textarea name="FORM_INPUT_COMMENT" rows="7" cols="32"></textarea><br />
    <input type="submit" name="INPUT_SUBMIT" value="Submit" />
    </form>
<?php
}
?>
</body>
</html>
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 12-07-2006 , 20:23   Re: Form information
Reply With Quote #8

I saved it as a .php file and when I put in Name: Dizzy Comments: Hey

it says

Code:
Firefox can't find the file at /C:/Documents and Settings/Dizzy/Desktop/<?=$_SERVER['PHP_SELF']?>.
Dizzy is offline
Send a message via AIM to Dizzy
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-07-2006 , 20:34   Re: Form information
Reply With Quote #9

Xanimos, <?= has been deprecated for quite a while now.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 12-07-2006 , 21:06   Re: Form information
Reply With Quote #10

Ava, you see something wrong?
Dizzy is offline
Send a message via AIM to Dizzy
Reply



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

Forum Jump


All times are GMT -4. The time now is 10:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode