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?
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:
<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>
<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.