Results 1 to 7 of 7
  1. #1
    Shawn is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default Writing to a website

    Hello, I've been searching around but I couldn't find any way to take write a string to a text file on my website, here is an example if you don't understand.

    I take input from the user, we'll use a "bug report" for this example.

    In my source code I handle the bug report and send it to the website.
    (I'm not sure what I'd do after this.) The website handles the input and appends it to a text file.

    What I need to know:
    1) How to send a String to a website.
    2) What the website will have to do to append it to the text file.

    Results: Me being able to open the text file and view the information.

    I'll greatly appreciate any help you may be able to provide.

    -Sean.

  2. #2
    Shawn is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default

    I apologize for the double post but I have this problem half solved.
    On my end I have a php script that reads from the url, EX:
    Url: mywebsite.com/myphp.php?o=hello
    and in the script:
    $Name=_get['o'];
    $Name would equal "hello" in this case.
    I then use that input.

    So on the server end I need to:
    1) Form the URL (Something like: String url = "mysite.com/script.php?o=" + String1";)
    2) Get the script to execute via connecting to the url.(I have no idea how.)

    I hope I explained it clearly enough.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I'm sorry, but I'm trying to see what place Java has in this scenario. Please explain?

  4. #4
    Shawn is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default

    Sorry for the slow reply, I'll try to clarify:

    Webserver side:
    A PHP script takes input from the url, EX: site.com/phpscript.php?name=hello

    Java side:
    Java forms the url, EX:
    String url = "site.com/phpscript?name=hello";
    and uses it the same way a web browser would, therefore executing the PHP script. (That is what I need to know how to do.)

    I hope this clarifies it.

  5. #5
    bubbless is offline Member
    Join Date
    Mar 2009
    Posts
    81
    Rep Power
    0

    Default

    Do you have the source code of the php script?

  6. #6
    Shawn is offline Member
    Join Date
    Mar 2009
    Posts
    4
    Rep Power
    0

    Default

    PHP Code:
    <?php
    $NAME=$_GET['name'];
    if($NAME != null)
    {
    $File="info.txt";
    $Handle=fopen($File,'a') or die("Couldn't find log file.");
    fwrite($Handle,"-------------");
    fwrite($Handle,chr(13));
    fwrite($Handle,$NAME);
    fclose($Handle);
    }
    else {
    	echo("Error.");
    }
    ?>
    It works fine if I go to the url in my web browser, I just need to know how to get Java to do it.

  7. #7
    bubbless is offline Member
    Join Date
    Mar 2009
    Posts
    81
    Rep Power
    0

    Default

    You could make the same but in java, so you don't need to use the website.

    Btw, I don't think your php script is "hacker" proof.
    You should always check POST's and GET's.

Similar Threads

  1. programming website?
    By ragarwal in forum Forum Lobby
    Replies: 11
    Last Post: 12-21-2009, 01:37 PM
  2. website section feedback
    By MuslimCoder in forum Reviews / Advertising
    Replies: 0
    Last Post: 02-25-2009, 08:35 PM
  3. WebSite Update!
    By Xyle in forum Reviews / Advertising
    Replies: 1
    Last Post: 02-16-2009, 09:47 AM
  4. How to download website (Get all link in website)
    By finalmem in forum Advanced Java
    Replies: 0
    Last Post: 11-12-2008, 09:43 AM
  5. Getting character set from a website
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-26-2007, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •