Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

PHP and HTML "form" and GET/POST variables

I am trying to convert a PHP web application to a Titanium desktop app. I have the PHP code working, but the HTML forms don't work. When I click on "submit", it reloads the page, but I don't see the $_GET or $_POST variables filled in from the form.

What is the best way to adjust a standard PHP web form to work within Titantium?

David Jones

http://dxjones.com

— asked July 9th 2010 by David Jones
  • form
  • get
  • html
  • php
  • post
0 Comments

1 Answer

  • I've only be playing with appcelerator for a day so far - just to qualify that I could be wrong! - but here's what I've found…

    If your HTML form's method is get rather than post it should work, but you have to work within the limitations of get. Get form methods place the fields as parameters to the form url they are requesting. Here's some example code where the 1st post form does not work but the 2nd get form does work:

    index.html

    <html>
    <head></head>
    <body>
    <form method="post" action="index.php">
    <input type="text" name="username">
    <input type="submit" value="submit">
    </form>
    <hr>
    <form method="get" action="index.php">
    <input type="text" name="username">
    <input type="submit" value="submit">
    </form>
    </body>
    </html>
    

    index.php

    <html>
    <head></head>
    <body>
    <?
    echo '<br>hello to post = ' . $_POST['username'];
    echo '<br>hello to get = ' . $_GET['username'];
    echo '<br>';
    var_dump($_SERVER);
    ?>
    <br><a href="index.html">back to forms</a>
    </body>
    </html>
    

    I think the reason the get form works and the post form does not work is because of the way Titanium runs PHP in CLI (command line interface mode) which I've also mentioned in another PHP discussion.

    — answered July 14th 2010 by Paul Ireland
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.