HTTP Post Form Data With Fields That Already Have Values - android

I am attempting to add a native login for a Jasig CAS to my Android app. I am using OkHttp (and/or RetroFit) to perform the HTTP post operation. The HTML login form looks like this:
<form id="form1" name="login" class="fm-v" action="/cas/login" method="post">
<input type="hidden" name="lt" value="LT-{login ticket}">
<input type="hidden" name="execution" value="{execution value}">
<input type="hidden" name="_event" value="submit">
<input type="text" id="username" name="username" tabindex="1"
placeholder="Username" class="textfield" autocomplete="off">
<input type="password" id="password" name="password" tabindex="2"
placeholder="Password" class="textfield" autocomplete="off">
<input type="submit" id="submit" name="submit" tabindex="3"
class="button" value="Submit">
</form>
From what I understand the "POST" method when added to the URL looks something like this:
"url.base.com/extension?post_name=post_value&..."
So I have found that when I use either OkHttp or RetroFit, the post method uses a URL like this:
"login.example.com/cas/login?username={username}&password={password}"
When typed into any browser, this is redirected to the standard login page: login.example.com/cas/login. But what I have found, is that if I follow this format:
"login.example.com/cas/login?lt=LT-{current-login-ticket}
&execution={current-execution-value}&_event=submit&username={username}
&password={password}&submit=Submit"
I receive a successful login! But I have to use a current login ticket and execution value. Therefore, is there any way to automatically fill out the rest of the form data based on the values that are given? Or do I have to parse the HTML response myself to get the login ticket and execution value?

Related

How can i submit form from android?

I am submitting form using html and now i have to create a form in android that will send message from textbox same as the website.
I don't want to use webview.
here is my html code:
<form action="http://example.com/form/" method="post">
<input type="text" name="name"/>
<input type="text" name="email" placeholder="Email Address" />
<textarea name="message" placeholder="Type your Message"></textarea>
<input type="submit" value="Send" />
</form>
Thanks

input type="file" accept="image/*" capture="camera" not working for mobile

I've got a simple form that uploads some basic info and an image to my formtools database. It works perfectly on desktop but not on mobile. On my Android phone when I test it it asks me to select the camera or file browser I have tried both camera and file browser and I take a picure / upload an image which it seems to do then loads the thank you page, but when I go the the form tools database the image has not been uploaded.
Anyone know why this isn't working?
here's the form
<form enctype="multipart/form-data" id="competitionform" class="uniForm cmxform" name="competitionform" method="post" action="/formtools/process.php">
<input type="hidden" name="form_tools_form_id" value="110" />
<header>
<h2>Upload your image</h2>
</header>
<label>Your Name </label>
<input width="100px;" type="text" placeholder=" " name="name" />
<label>Your Email </label>
<input type="text" placeholder=" " name="email" /> <
<label for="file">Upload Selfie</label>
<input type="file" name="uploadselfie"/>
<input type="submit" id="submit" value="Upload Selfie" />
</form>
I've also tried adding
accept="image/*" capture="camera"
to the input which opens the camera lets you take a picture then loads the thank you page but again no image is uploaded to the formtools database.
Thanks
<form> with enctype="multipart/form-data" can only upload pic/files and so on .It can't send other input which type is text to the database.
This point, you must set two forms, one for input type=text, another for input type=file.

Phonegap - email html form content

I have the below HTML code which basically sends mail on click of submit button
<form action="mailto:xxx#gmail.com" method="post" enctype="text/plain">
Name:<br>
<input type="text" name="name" value="Name"><br>
E-mail:<br>
<input type="text" name="mail" value="E-Mail"><br>
Comment:<br>
<input type="text" name="comment" value="Comments" size="50"><br><br>
<input type="submit" value="Send">
<input type="reset" value="Reset">
</form>
when I hit the submit button in the phonegap application I get the below in the logcat.
DroidGap: GapViewClient.onReceivedError: Error code=-10 Description=net::ERR_UNKNOWN_URL_SCHEME URL=mailto:xxx#gmail.com?body=name%3Dyour%20name%0D%0Amail%3Dxxx%40gmail.com%0D%0Acomment%3Dyour%20comment%0D%0A
I am not able to resolve this issue. Any suggestions or help would be appreciated.
I think you should use email composer Plugins to send email.
SMSComposer plugin

Submit html form with results in webview

If I have a HTML form like this:
<form action="form_action.php" method="post">
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
<input type="submit" value="Submit" />
</form>
And then I want to fill the fname & lname then like "press" the submit button programmatically and after that show the form_action.php with the post's in a webview.
And just so you know, I can't change the form, b'cause it's not my site I'm using.
Is that possible?
Hope you get it.
Thanks in advance. (Very sorry for bad english!)

have form act as a simple redirect (HTML/PhoneGap)

I'm making a prototype and the manipulation of the url when submitting a form is causing me issues. I just want to redirect to the link but keep my styling.
<form method = "link" action="portal.html" class="forms">
<label>Username:</label>
<input type="text" name="username" />
<label>Password:</label>
<input type="password" name="password" />
<input type="submit" class="submit" />
</form>
I want the submit to act a a straight redirect.. w/ appending the ?username=&password= to the redirect.
If it makes a difference this is an html5 project for android using phonegap.
If I understood correctly, you just want to submit the form and go to another page, while appending the form's fields to the URL as a query string (?foo=bar&foo=bar). For that you have to declare your form's method as GET, like so:
<form method="GET" action="portal.html" class="forms">
EDIT: turns out the desired behavior is exactly the opposite.
To don't append a query string, you could set your form's method to POST
<form method="POST" action="portal.html" class="forms">

Categories

Resources