Discussion Forums  >  WebViews and HTML for Mobile

Replies: 14    Views: 393

Dromundi
I hate code!
Profile
Posts: 43
Reg: Feb 17, 2012
location unknow...
730
04/24/12 03:58 AM (13 years ago)

Contact form with PHP

Hi all, I am doing an app with BT v1.5 and on iOS. I have done a nice form in my app on an HTML page. But now my problem is to send the email with all the inputs from the form. Apparently PHP is recommended to do that. I tried to look on some resources on internet but I am stuck because I know nothing about PHP. Just for test I tried a template I found on internet and when I click on "submit" on the form, the php files open instead of executing it. So yeah... I am totally lost.
 
Vali
buzztouch Evangelist
Profile
Posts: 193
Reg: May 22, 2011
Bucharest
5,830
like
04/24/12 04:17 AM (13 years ago)
Hi Dromundi, You can try http://www.jotform.com/ After you're done customizing the form on their site you can output the form to a number of formats. Give it a try and tell me if it does what you need.
 
Dromundi
I hate code!
Profile
Posts: 43
Reg: Feb 17, 2012
location unknow...
730
like
04/24/12 05:04 AM (13 years ago)
Hi Vali, Thanks for the link. However that doesn't help much because I need this form to be completely somehow "offline" except when the user clicks on submit. The form itself is not the problem. This is the email sent based on this form which is tricky to me.
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/24/12 08:07 AM (13 years ago)
All the webform scripts I've seen are server side and will only work on forms that are located on the server as to keep outsiders from using the scripts. I have a form in my app but the html is hosted on the server to call the scripts, will not work anyother way that I know of with a webform script. Or, You can use ‘mailto:[email protected]’ in the action field of the form, it may work
 
Dromundi
I hate code!
Profile
Posts: 43
Reg: Feb 17, 2012
location unknow...
730
like
04/24/12 08:20 AM (13 years ago)
Thanks for the tip, so basically I can use the mailto function. I guess it will open the mailbox for the iPhone which is absolutely no problem. But will it summarize all the data put in the form?
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/24/12 08:22 AM (13 years ago)
Guess I didnt see the php in your title above still stands the mailto link was more of a javascript form: <form action="mailto:[email protected]" method="post" enctype="text/plain" > FirstName:<input type="text" name="FirstName"> Email:<input type="text" name="Email"> <input type="submit" name="submit" value="Submit"> </form>
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/24/12 08:24 AM (13 years ago)
Never tried it on a phone, It'll either warn user about their email address being exposed or it will open their email client, havent tested it.
 
Vali
buzztouch Evangelist
Profile
Posts: 193
Reg: May 22, 2011
Bucharest
5,830
like
04/24/12 12:52 PM (13 years ago)
Hi Dromundi, I get your two cents, but the whole point of a form is to able to send something online, so it is assumed that the user at the moment of using that form will be online in order to use it. I admit that I never used PHP for any of my Web or iOS dev, but I think it has to be related to updating a database, so unless you are building this database with entries from the form you are supplying, a simple HTML form(that you can build yourself or use services like JotForm) would be enough. Best of luck either way ! :)
 
Dromundi
I hate code!
Profile
Posts: 43
Reg: Feb 17, 2012
location unknow...
730
like
04/25/12 01:01 AM (13 years ago)
Thanks both, Yes Vali I see what you mean by the fact of being somehow online, you are right and I was not very clear. As I don't want to use a server to send the email I try to use the mailto function. I have tried it on my computer and it works perfectly but on the iPhone simulator when I click on the link it opens the mail (which is good) but puts everything ([email protected]?Subject=...) in recipient instead of spliting the information in recipient subject and body. Do you have any clue what I am doing wrong, I can't find anything that answer my question on the net? Here is the code I use in the javascript which is called when I click on "submit" in the form : location.href = "mailto:[email protected]?Subject=" + escape(document.mmail.subj1.value) + "&Body=Dear,%0A" + escape(document.getElementById('result1').innerHTML) + " aaa " + escape(document.getElementById('result2').innerHTML) + "%0ABest regards,%0A" + escape(document.mmail.textinput1.value);
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/25/12 08:03 AM (13 years ago)
<form action="mailto:[email protected]?Subject=MYAPP" method="post" enctype="text/plain" > FirstName:<input type="text" name="FirstName"> Email:<input type="text" name="Email"> <input type="submit" name="submit" value="Submit"> </form> This example the subject would be a fixed value of MYAPP everything else would go in the body but the format in the body would be as its shown above: Subject Myapp FirstName=input value Email=inputvalue Submit=Submit
 
Dromundi
I hate code!
Profile
Posts: 43
Reg: Feb 17, 2012
location unknow...
730
like
04/25/12 12:02 PM (13 years ago)
Arubaman, Thanks! I tried your code, basically I copied and pasted it in my HTML document. Unfortunately when I click on "Submit" I have the mail app which opens only with the recipient "[email protected]?Subject=MYAPP..." and subject and body are still empty... I don't know what is wrong, maybe because I built my HTML doc with Jquery mobile...
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/25/12 06:36 PM (13 years ago)
Checked on iphone browser it works for me, but I havent tried it from inside a app.
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/25/12 06:38 PM (13 years ago)
http://support.microsoft.com/kb/279460 heres a old form page from ms, maybe it'll help more.
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
04/25/12 07:05 PM (13 years ago)
 
Dromundi
I hate code!
Profile
Posts: 43
Reg: Feb 17, 2012
location unknow...
730
like
04/27/12 02:44 AM (13 years ago)
Hey Arubaman, After reading articles here and there (including your links) I have come to the conclusion that the iPhone simulator is not able to handle the "mailto" function because he doesn't really have the mailapp. That would explain why the code works on our desktops but not on the simulator. When I will test the app, I will see what happens when I click on the link. Thanks a lot for your help.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.