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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

What Programming Language To Use?

  • 09-10-2007 8:35pm
    #1
    Registered Users, Registered Users 2 Posts: 8,679 ✭✭✭


    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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 8,679 ✭✭✭Chong


    Its on a Windows box the folder.

    Would PHP be the better choice over ASP?


  • Registered Users, Registered Users 2 Posts: 8,679 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 8,679 ✭✭✭Chong


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


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 8,679 ✭✭✭Chong


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


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


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


  • Registered Users, Registered Users 2 Posts: 8,679 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 8,679 ✭✭✭Chong


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


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


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


Advertisement