Current location: Hot Scripts Forums » Programming Languages » PHP » Simple webform question


Simple webform question

Reply
  #1 (permalink)  
Old 01-15-06, 11:00 PM
wearetwo wearetwo is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Simple webform question

Hey guys!

My server's mail script has been very unreliable so I want to replace a little script I have running. It's basically a little webform that sends the input to my email.

Instead, I want it to replace the script with a script that updates a little txt file instead of email. ie, I have a form like

Name:

email:

comments:

[sumbit]

and whenver someone fills this out it inserts that much in a txt file

How would I go around doing this? A very simple example will be very nice!

thansk very much!
Reply With Quote
  #2 (permalink)  
Old 01-16-06, 01:53 AM
digioz's Avatar
digioz digioz is offline
Community VIP
 
Join Date: Oct 2003
Location: Chicago, IL
Posts: 2,171
Thanks: 3
Thanked 9 Times in 9 Posts
Here is a simple one:

PHP Code:

<?
// If the form has been submitted -------------------------
if (isset($_POST['Submit']))
{
$name $_POST['name'];
$email $_POST['email'];
$comments $_POST['comments'];
 
// Disable HTML Code Insert into text file --------------
 
$name str_replace("<""&lt;"$name);
$name str_replace(">""&gt;"$name);
$email str_replace("<""&lt;"$email);
$email str_replace(">""&gt;"$email);
 
$comments str_replace("<""&lt;"$comments);
$comments str_replace(">""&gt;"$comments);
 
// Write the Output to text file in append mode --------
 
$output $name." | ".$email." | ".$comments."\n";
$fp fopen("messages.txt""a");
fwrite($fp$output);
fclose($fp);
}
?>
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method=post>
<input type="text" name="name" size=20 maxlength=50>
<input type="text" name="email" size=20 maxlength=50>
<textarea name="comments" cols="60" rows="10"></textarea>
<input type="Submit" name="Submit" value="Submit">
</form>
Copy and past the code above into notepad, and save it as something like "feedback.php". In the same directory, create a blank text file and call it "messages.txt", and CHMOD it to 777 (give it read, write and execute permission to all).

Every message will be added to the text file on a new line, and the name, email and message will be seperated by a " | ".
__________________
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple mySQL Question, Multiplying Entire Column Luke2 PHP 2 07-21-05 08:00 PM
Simple question Maniax JavaScript 4 08-31-04 01:08 PM
Simple PHP question about JPEG? snooky5 PHP 4 08-14-04 03:36 PM
Simple question kashi PHP 5 08-13-04 10:23 PM
question about simple login system magsec4 PHP 5 02-23-04 03:35 AM


All times are GMT -5. The time now is 06:28 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.