From: Adam Kennedy Date: 2013-01-18T00:23:15+09:00 Subject: Re: Adding file directory automatically Hi, Yeah I have a File.open function opening, a file called david.txt. In that file it has a few bit of information. One of those pieces of information is price. £0.00. The code needs to open the text file david.txt, add it to an array and then save it, displaying the new price. I can do this fine, but I basically want to have it that when the user inputs their bid via a form input and submit, it opens the file dynamically, father than having 12 different bid.cgi files for each text file. Hope this explains it a bit better the code is as follows: #Displaying information #!/media/Apache/ruby/bin/ruby #!/usr/local/bin/ruby #encoding: utf-8 puts "Content-type: text/html\n\n" #Adds information from david.txt to an array f = File.open("../logs/david.txt") a = f.readlines puts "" puts "" puts "David Quetta - Nothing But the Beat" puts "" puts "" puts "

Name :" puts a[0] puts "

" puts "

Description :" puts a[1] puts "

" puts "

Price :£" puts a[2] puts "

" puts "

Item Number :" puts a[3] puts "

" puts "
" puts "Bid: £" puts "" puts "
" puts "Please enter in the format £0.00" puts "
" puts "" puts "" #Adding bid (its broken at this stage) #!/media/Apache/ruby/bin/ruby #!/usr/local/bin/ruby #Adds information from david.txt to an array f = File.open("../logs/david.txt") a = f.readlines #Sets params for form data require 'cgi' cgi = CGI.new() bid = cgi.params['bid'] a[2] = bid puts "Content-type: text/html\n\n" puts "" puts "" puts "Thank you" puts "" puts "" puts "

Thank you for your bid, it will now be logged and you will be redirected now.

" puts "" puts "" In the bid.cgi which is the second file, the f = File.open needs to be changed automatically. Thanks Adam k -- Posted via http://www.ruby-forum.com/.