How to display input on one web page on another?

Discussion in 'Computing and Networks' started by Markd77, Jun 15, 2012.

  1. Markd77

    Thread Starter Senior Member

    Sep 7, 2009
    2,803
    594
    I'd like to have a web page www example com/input.html with an input box.
    Whatever gets typed into that input box I'd like to display on the page www example com/input.html (actually my computer will be sending to the input box but I'm pretty sure I can do that easily with Python).
    A visitor to output.html shouldn't be able to find the location of input.html (or I could just put a password on input.html).

    The problem is I don't know where to start looking or even what to search for. Any tips?
    My host has the following available:
    PHP4
    PHP5 with SOAP Support
    Perl
    Python
    Ruby Hosting

    <ed> I should probably mention that although this could be done with FTP, my host has a system where to use FTP, you have to log in to their site and unlock it for a period. </ed>
     
    Last edited: Jun 15, 2012
  2. BMorse

    Senior Member

    Sep 26, 2009
    2,675
    234
    In order to do this, you have to find out if your host will allow you to run scripts on the server, you would have to have the input "post" data to the host server, which could then be retrieved ("get") by the output form (would be best if the output form just queried the server for data every now and then, basically set up a timer to update the form periodically, or when a user clicks a button to refresh)..... you can write these scripts in any of the server supported languages you posted above..... here is some light reading on the "post" and "Get" methods used for this type of stuff... http://catcode.com/formguide/getpost.html
     
  3. Markd77

    Thread Starter Senior Member

    Sep 7, 2009
    2,803
    594
    Finally managed it, still have to sort out a couple of things:
    Whatever you put here:
    http://www.marksphotos.info/in.shtml
    You have to click back to input again.

    should turn up here:
    http://www.marksphotos.info/out.shtml

    I might not leave the pages up for very long, if anyone spots any problems or security issues please let me know.
    No typing rude things in the box!


    in.shtml
    Code ( (Unknown Language)):
    1. <html>
    2. <body>
    3.  
    4. <form action="/cgi-bin/in.py" method="post">
    5. <input type="submit" value="Send Data" />
    6. First name: <input type="text" name="first" />
    7.   <br />
    8.   <!-- form contents go here -->
    9. </form>
    10.  
    11. </body>
    12. </html>
    13.  
    out.shtml
    Code ( (Unknown Language)):
    1. <html>
    2. <body>
    3.  
    4.  
    5.  
    6. <!--#exec cgi="/cgi-bin/test.py" -->
    7.  
    8. </body>
    9. </html>
    test.py (for output)
    Code ( (Unknown Language)):
    1. #!/usr/bin/python
    2.  
    3. print "Content-type: text/html\n"
    4.  
    5. print """
    6. <html>
    7.  
    8. <head>
    9.   <title>Test</title>
    10. </head>
    11.  
    12. <body>
    13.  
    14. Below text comes from file
    15. <BR>
    16.  
    17. """
    18.  
    19. file_in = open("test.txt", "r")
    20. count = file_in.readline()     # it *is* a text file
    21. file_in.close()
    22. print count    
    23.  
    24. print "</body>"
    25. print "</html>"
    26.  

    in.py
    Code ( (Unknown Language)):
    1. #!/usr/bin/python
    2.  
    3. import cgi
    4. form = cgi.FieldStorage() # instantiate only once!
    5. name = form.getfirst('first', 'empty')
    6.  
    7. # Avoid script injection escaping the user input
    8. name = cgi.escape(name)
    9.  
    10. print """\
    11. Content-Type: text/html\n
    12. <html><body>
    13. <p>File should be updated to "%s"</p>
    14.  
    15. """ % name
    16.  
    17. file_out = open("test.txt", "w")
    18. file_out.write(str(name))
    19.  
    20. file_out.close()
    21.    
    22.  
    23. print "</body>"
    24. print "</html>"
    25.  
     
  4. c0de3

    Active Member

    May 1, 2009
    50
    1
    Looks pretty good. I didnt see the code and went and tried some injections. They all failed. Then I saw the code and see you are scrubbing for it. Nice.


    I don't see a length limit. someone could try to fill up your drive or crash the system by putting huge amounts of data into the post.
     
  5. Markd77

    Thread Starter Senior Member

    Sep 7, 2009
    2,803
    594
    I think I probably should put a length check on it, someone just put 93kB of Lorem ipsum text on there. I had no idea you could paste that much into an input box. I'll probably give the input page an unguessable name anyway, with no links to it.
    I'm going to take the input page down now.
     
  6. techmonster1

    New Member

    Jul 24, 2012
    1
    0
    In my point of view Processing data from an HTML form can not be done with HTML.

    You either need to use a server side scripting language (such as PHP), or a client side scripting language (such as Javascript).

    In general it is better to use a server side scripting language because that will work for all visitors. Perhaps 10% of people have javascript turned off. Consequently javascript based form processing will not work for them.
     
Loading...