Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

What Programming Language To Use?

Options
  • 09-10-2007 9:35pm
    #1
    Registered Users Posts: 8,676 ✭✭✭


    Ok Guys,

    Just a little advice if you will. I have some programming background in java but its been a while , anyways I have to do a small project in work and I am unsure what Language to go for.

    Basically its simple , a web page that takes in 3 textbox inputs and a submit button, these inputs are combined in to txt document thats write to folder on a server, simple, but just wondering what I should use to code it?

    Cheers

    Will


Comments

  • Registered Users Posts: 3,594 ✭✭✭forbairt


    God ... to be honest .. anything will be able to handle that ...

    personally I'd use php ...

    no doubt windows people will say asp ...


    Really use what you're comfortable with ...

    is it on a windows server ? or linux / unix

    http://www.php.net/manual/en/function.fwrite.php

    shows how to write to a file ...

    This will be running from a webserver (webpage) or will you require a stand alone application ?


  • Registered Users Posts: 2,835 ✭✭✭StickyMcGinty


    if its in work, obviously depending on your company, you might have to use something on the .NET framework. otherwise use PHP, easily done


  • Registered Users Posts: 8,676 ✭✭✭Chong


    Its on a Windows box the folder.

    Would PHP be the better choice over ASP?


  • Registered Users Posts: 8,676 ✭✭✭Chong


    Sorry I should have been more clearer , the 3 inputs are written to a txt doc , then this text doc is saved to a folder that sits on a windows box.


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    First html file

    form posts to input.php
    inputText1
    inputText2
    inputText3

    second file
    <?php
    $filename = 'test.txt';
    $somecontent = $_REQUEST["inputText1"].$_REQUEST["inputText2"].$_REQUEST["inputText3"];
    
    // Let's make sure the file exists and is writable first.
    if (is_writable($filename)) {
    
        // In our example we're opening $filename in append mode.
        // The file pointer is at the bottom of the file hence
        // that's where $somecontent will go when we fwrite() it.
        if (!$handle = fopen($filename, 'a')) {
             echo "Cannot open file ($filename)";
             exit;
        }
    
        // Write $somecontent to our opened file.
        if (fwrite($handle, $somecontent) === FALSE) {
            echo "Cannot write to file ($filename)";
            exit;
        }
    
        echo "Success, wrote ($somecontent) to file ($filename)";
    
        fclose($handle);
    
    } else {
        echo "The file $filename is not writable";
    }
    ?> 
    


    and .... you're done ...

    assuming its on the same server the script is running on ...

    Permissions on the folders its writing to will have to be set as well ...

    but thats the general gist of it ...


  • Advertisement
  • Registered Users Posts: 8,676 ✭✭✭Chong


    So its as simple as integrating the piece of php into the HTML , and away I go?


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    <form method="post" action="input.php">
    <input type="text" name="inputText1" />
    <input type="text" name="inputText2" />
    <input type="text" name="inputText3" />
    <input type="submit" name="submit" value="Submit" />
    </form>
    

    First file is this ...

    second file is the previou code ... and name it input.php

    put the two files in the same directory maybe call the other one index.php


    if you want to just set it up to test get a copy of wampserver - http://www.wampserver.com/en/index.php

    its a one click php / mysql / apache install ...

    And .... put two two files .. into a directory underneath
    c:\wamp\www\

    and test it out ...

    that is at its most basic ... but I'm not entirely sure how advanced you want to go ... you can check out various frameworks .. or you could just go with asp ... java .... jsp ...

    thats all untested so I've probably made a bug somewhere but you should be able to get the general gist of it all :)


  • Registered Users Posts: 8,676 ✭✭✭Chong


    Excellent I will give it a go tomorrow , cheers for the great advice guys.


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    Thats what we're getting paid to do ...
    er ... am ... er ... :D


  • Registered Users Posts: 8,676 ✭✭✭Chong


    Ok apparently I am not allowed do this in the company I work , as I we use ASP and are unable to use the server I have with Php.

    Any other ideas, how I can do this, is possible in ASP?


  • Advertisement
  • Registered Users Posts: 3,594 ✭✭✭forbairt


    Just a quick google .. asp write to file .. its your friend ... :D

    <%
    function WriteToFile(FileName, Contents, Append)
    on error resume next
    
    if Append = true then
       iMode = 8
    else 
       iMode = 2
    end if
    set oFs = server.createobject("Scripting.FileSystemObject")
    set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
    oTextFile.Write Contents
    oTextFile.Close
    set oTextFile = nothing
    set oFS = nothing
    
    end function
    
    %>
    
    <HTML>
    <BODY>
    
    <%
    
    WriteToFile "C:\Test1.txt", "Hello How are you", True
    WriteToFile "C:\Test2.txt", "Hello How are you", false
    WriteToFile "C:\Test1.txt", chr(13) & chr(10) & "I am fine", true
    WriteToFile "C:\Test2.txt", chr(13) & chr(10) & "I am fine", false
    'Test1.txt contains:
    'Hello How are you
    'I am fine
    
    'Test2.text contains:
    
    'I am fine
    %>
    Write to File test is complete
    </BODY>
    </HTML>
    


  • Registered Users Posts: 8,676 ✭✭✭Chong


    Cheers for all the help Forbairt everything worked out really well.


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    good to hear and glad to have been of help :)


Advertisement