Saving contact form information when submit is pressed?

This is a discussion on "Saving contact form information when submit is pressed?" within the JavaScript Forum section. This forum, and the thread "Saving contact form information when submit is pressed? are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Dec 12th, 2007, 16:00
New Member
Join Date: Dec 2007
Location: UK
Age: 30
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Saving contact form information when submit is pressed?

I would like to use java to save what the user inputs into a contac us form to a text file as opposed to having the data mailed via na email address.

I would prefer to use javascript to do this? Does anyone have any ideas on it ? I am quite new to java so i hope it is simple.

I cannt find anything on the web.

any help would be awesome.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Dec 12th, 2007, 16:35
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

I'm not sure that would be the best idea.

JavaScript is vulnerable to attack, You'd be better of use a server side language such as PHP or ASP. They are quite easy to learn.

Although, if you would really like to use JS. Have a look at this: http://4umi.com/web/javascript/filewrite.htm

Or just google, JavaScript - Writing files.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Dec 12th, 2007, 17:06
Up'n'Coming Member
Join Date: Jun 2007
Location: Birmingham, UK
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

I'm not quite sure what you want to do.

Do you want to save contact data on the server? That can't be done with JavaScript. You need a server side language for this. You could use PHP to save a file on the server instead of emailing the data to you.

Also note: JavaScript is not Java. They are two completely different languages used for different purposes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Dec 12th, 2007, 17:43
New Member
Join Date: Dec 2007
Location: UK
Age: 30
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

No no

all i need to know is what code i can put behind a submit button to save the form data the user enters to a text file as opposed to using a mailto

I have something written here but it seems very long winded.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Dec 12th, 2007, 17:52
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

There is no simple code that you can use to save a file. It is usually done on the server using PHP or similar.

But you can view a JavaScript code here: http://4umi.com/web/javascript/filewrite.htm#thescript

The problem is it only works in Internet Explorer.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Dec 13th, 2007, 07:01
Reputable Member
Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

Ok, I get it. You want to save the details in a textfile instead of having them mailed to some emailed address.

Instead of adding it to a MySQL database, you want to add it to a textfile so that the file is human readble. Correct? Is this what you want?
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Dec 13th, 2007, 07:07
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

As blake121 says there is no way to do this with cross-compatible javascript. ActiveX (bad choice of programming) has some functions for manipulating local files but the security of end users has prevented this being anything other than closet code for niche purposes.

What you really want to look into is ajax -- which is javascript communicating with a server-side language such as PHP.

You can use PHP to write the text file and store on the server ( or serve as download to user as required)
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Dec 13th, 2007, 07:08
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,612
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Saving contact form information when submit is pressed?

I think he want both of them (email and text file)
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Dec 13th, 2007, 07:15
Reputable Member
Join Date: Nov 2007
Location: India
Posts: 150
Blog Entries: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

This is the PHP script you would need to do it. Remember, this is PHP not javascript.
Just create a HTML form and point it towards this script. The rest would be taken care by the PHP script
PHP: Select all

<?php
$string1
=$_POST['string1'];
$string1=$_POST['string2'];
$string1=$_POST['string3'];
$string1=$_POST['string4'];
$content ="$string1&nbsp;&nbsp;&nbsp;$string2&nbsp;&nbsp;&nbsp;$string3&nbsp;&nbsp;&nbsp;$string4";
$fp fopen("YourTextFile.txt""a+");
fwrite($fp$content)
?>
Replace YourTextFile with file name of your choice.
The &nbsp;&nbsp;&nbsp; are used to produce tab spaces so that you can read conveniently.
Last Blog Entry: Cross browser nuisance (Feb 11th, 2008)

Last edited by RohanShenoy; Dec 13th, 2007 at 07:22.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Dec 13th, 2007, 22:47
Junior Member
Join Date: Dec 2007
Location: UK
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Saving contact form information when submit is pressed?

Again this is a job for server side languages. This is because end users can manipulate javascript as it is ran in there browsers plus the fact javascript cant do this by definition becuase its a client side scripting language so your snookered anyway.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

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
[SOLVED] PHP contact form redirect to same form Posie PHP Forum 14 Jan 29th, 2008 20:28
submit many forms - auto submit the same form many times divs JavaScript Forum 0 May 24th, 2007 10:10
Submit information field escaflowne11 Starting Out 1 Feb 14th, 2007 12:52
Need Quote Form and Contact Form Av8er Flash & Multimedia Forum 5 Oct 30th, 2003 17:14


All times are GMT. The time now is 02:27.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved