Computer Hope
Internet & Networking => Web design => Topic started by: alex116 on January 14, 2007, 07:25:23 AM
-
Hi again,
I need a function that allows you to read form variables from static HTML and write them on a txt file on the server. I need to make a database but I can only use HTML and javascript because my host allows only that.
The script must be able to read certain fields from a form and write them to a file.
Can you please help me?
Thank you very much...I am not a Javascript expert and I would like it to be complete...if possible.
I have found something while googleing this....if this can help you help me use it...maybe its not complete...or...I don't know :
function getVar(name)
{
get_string = document.location.search;
return_value = '';
do { //This loop is made to catch all instances of any get variable.
name_index = get_string.indexOf(name + '=');
if(name_index != -1)
{
get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
end_of_value = get_string.indexOf('&');
if(end_of_value != -1)
value = get_string.substr(0, end_of_value);
else
value = get_string;
if(return_value == '' || value == '')
return_value += value;
else
return_value += ', ' + value;
}
} while(name_index != -1)
//Restores all the blank space
space = return_value.indexOf('+');
while(space != -1)
{
return_value = return_value.substr(0, space) + ' ' +
return_value.substr(space + 1, return_value.length);
space = return_value.indexOf('+');
}
return(return_value);
}
-
You cannot use client-side scripting (javascript) to write to a server-side file. For that you need server-side scripting, such as PHP, Perl, ASP, Ruby, etc, etc. It would be pretty dangerous if javascript could do things like this, since javascript can be modified at the client (browser) end. So that would allow you to take control of someone's webserver, if what you are suggesting were possible.
Sorry!
-
OK Rob, thank you for your time.
-
alex116, I noticed your avatar is 73,282 bytes. Here's a resized/optimized version that's only 2,199 bytes. Feel free to save it to your hard drive and then replace your current avatar with it.
I believe it also looks better than what you're using now.
(http://i7.photobucket.com/albums/y256/farmpond/forums/svchost21.gif)