How to input a user entered string into an HTML (Swift)
I'm trying to develop an app for my school's grade portal (Using the Home Access Center platform).
(Im a bit of a beginner so please excuse any lapses in the information I have provided and if you need to me to provide it, I will be active)
So far I've been able to send the request and receive a response in the form of a string through .responseString, and when I print the response I'm getting an HTML doc type with the login parameters near the bottom. I have gotten this far, but I'm not sure how to pass my user-inputted data to the correct location. (I know where the parameters are located, but don't know how to access them).
The HTML file output looks like this,
<div>
<label class="sg-logon-left" for="LogOnDetails_UserName">User Name:</label>
<input class="sg-logon-right" data-val="true" data-val-required="The User Name: field is required." id="LogOnDetails_UserName" name="LogOnDetails.UserName" type="text" value="" />
<span class="field-validation-valid sg-logon-validation" data-valmsg-for="LogOnDetails.UserName" data-valmsg-replace="true"></span>
</div>
(just a small chunk of the file)
I've tried passing multiple different combinations of the parameters using a dictionary, but none of them have actually made it to that location. This website uses a action form (I'm a beginner, so I'm not sure about different interactions with HTML elements), but this is what passes when I run my program
<form action="/HomeAccess/SessionReset?ReturnUrl=%2FHomeAccess%2FAccount%2FLogOn%3FReturnUrl%3D%252fhomeaccess%252f" method="post">
< div class="sg-container" id="SignInSectionContainer">
I will send my current Swift code if need be, but if you might have a solution, the website is https://hac.friscoisd.org/HomeAccess/Account/LogOn?ReturnUrl=%2fhomeaccess%2f and I'm using Alamofire and Xcode (latest versions)
I have looked extensively for a thread that might have my answer, but I'm unable to find anything besides information on how to parse HTML files.
Thanks a ton for any help and please reroute me if this is a duplicate question.
Swift Code
@IBAction func getLoginData(_ sender: Any) {
let username = Username.text!
let password = Password.text!
if (username != "" && password != "")
{
let params : [String : String] = ["name" : "LogOnDetails.UserName","type" : "text", "value" : username]
//Make database a choosable number parameter later
sendLoginRequest(url: HAC_URL, parameters: params)
}
else
{
errorOutput.text = "Invalid Login"
}
}
func sendLoginRequest(url: String, parameters : [String : String])
{
Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding()).responseString
{
response in
if response.result.isSuccess
{
self.errorOutput.text = "Success"
print(response.result.value!)
}
else if response.result.isFailure
{
self.errorOutput.text = "Connection Issues"
print(response.error.debugDescription)
}
else
{
self.errorOutput.text = "Program Failure"
}
}
}
Edit
I need to input a user entered string into an HTML
ios swift alamofire
add a comment |
I'm trying to develop an app for my school's grade portal (Using the Home Access Center platform).
(Im a bit of a beginner so please excuse any lapses in the information I have provided and if you need to me to provide it, I will be active)
So far I've been able to send the request and receive a response in the form of a string through .responseString, and when I print the response I'm getting an HTML doc type with the login parameters near the bottom. I have gotten this far, but I'm not sure how to pass my user-inputted data to the correct location. (I know where the parameters are located, but don't know how to access them).
The HTML file output looks like this,
<div>
<label class="sg-logon-left" for="LogOnDetails_UserName">User Name:</label>
<input class="sg-logon-right" data-val="true" data-val-required="The User Name: field is required." id="LogOnDetails_UserName" name="LogOnDetails.UserName" type="text" value="" />
<span class="field-validation-valid sg-logon-validation" data-valmsg-for="LogOnDetails.UserName" data-valmsg-replace="true"></span>
</div>
(just a small chunk of the file)
I've tried passing multiple different combinations of the parameters using a dictionary, but none of them have actually made it to that location. This website uses a action form (I'm a beginner, so I'm not sure about different interactions with HTML elements), but this is what passes when I run my program
<form action="/HomeAccess/SessionReset?ReturnUrl=%2FHomeAccess%2FAccount%2FLogOn%3FReturnUrl%3D%252fhomeaccess%252f" method="post">
< div class="sg-container" id="SignInSectionContainer">
I will send my current Swift code if need be, but if you might have a solution, the website is https://hac.friscoisd.org/HomeAccess/Account/LogOn?ReturnUrl=%2fhomeaccess%2f and I'm using Alamofire and Xcode (latest versions)
I have looked extensively for a thread that might have my answer, but I'm unable to find anything besides information on how to parse HTML files.
Thanks a ton for any help and please reroute me if this is a duplicate question.
Swift Code
@IBAction func getLoginData(_ sender: Any) {
let username = Username.text!
let password = Password.text!
if (username != "" && password != "")
{
let params : [String : String] = ["name" : "LogOnDetails.UserName","type" : "text", "value" : username]
//Make database a choosable number parameter later
sendLoginRequest(url: HAC_URL, parameters: params)
}
else
{
errorOutput.text = "Invalid Login"
}
}
func sendLoginRequest(url: String, parameters : [String : String])
{
Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding()).responseString
{
response in
if response.result.isSuccess
{
self.errorOutput.text = "Success"
print(response.result.value!)
}
else if response.result.isFailure
{
self.errorOutput.text = "Connection Issues"
print(response.error.debugDescription)
}
else
{
self.errorOutput.text = "Program Failure"
}
}
}
Edit
I need to input a user entered string into an HTML
ios swift alamofire
Please put your current code that you are trying with swift, just like you have writen HTML, so we can help you. Plus see on stackoverflow how to ask a good question here stackoverflow.com/help/how-to-ask
– Xcodian Solangi
Nov 22 '18 at 17:43
Alright I included the Swift code, and changed the question a bit
– Charan
Nov 22 '18 at 17:48
Your list of parameters doesn't look right. As far as I can tell Alamofire request parameters are just name value pairs, you don't need type or text, just the value. You also haven't actually attempted to send the password. Try ["LogOnDetails.UserName":username, "LogOnDetails.Password":password]
– Dale
Nov 22 '18 at 22:53
I tried that and am running into the same issue. I'm also suspecting that I need to set up something that triggers the button on the site.
– Charan
Nov 25 '18 at 0:17
add a comment |
I'm trying to develop an app for my school's grade portal (Using the Home Access Center platform).
(Im a bit of a beginner so please excuse any lapses in the information I have provided and if you need to me to provide it, I will be active)
So far I've been able to send the request and receive a response in the form of a string through .responseString, and when I print the response I'm getting an HTML doc type with the login parameters near the bottom. I have gotten this far, but I'm not sure how to pass my user-inputted data to the correct location. (I know where the parameters are located, but don't know how to access them).
The HTML file output looks like this,
<div>
<label class="sg-logon-left" for="LogOnDetails_UserName">User Name:</label>
<input class="sg-logon-right" data-val="true" data-val-required="The User Name: field is required." id="LogOnDetails_UserName" name="LogOnDetails.UserName" type="text" value="" />
<span class="field-validation-valid sg-logon-validation" data-valmsg-for="LogOnDetails.UserName" data-valmsg-replace="true"></span>
</div>
(just a small chunk of the file)
I've tried passing multiple different combinations of the parameters using a dictionary, but none of them have actually made it to that location. This website uses a action form (I'm a beginner, so I'm not sure about different interactions with HTML elements), but this is what passes when I run my program
<form action="/HomeAccess/SessionReset?ReturnUrl=%2FHomeAccess%2FAccount%2FLogOn%3FReturnUrl%3D%252fhomeaccess%252f" method="post">
< div class="sg-container" id="SignInSectionContainer">
I will send my current Swift code if need be, but if you might have a solution, the website is https://hac.friscoisd.org/HomeAccess/Account/LogOn?ReturnUrl=%2fhomeaccess%2f and I'm using Alamofire and Xcode (latest versions)
I have looked extensively for a thread that might have my answer, but I'm unable to find anything besides information on how to parse HTML files.
Thanks a ton for any help and please reroute me if this is a duplicate question.
Swift Code
@IBAction func getLoginData(_ sender: Any) {
let username = Username.text!
let password = Password.text!
if (username != "" && password != "")
{
let params : [String : String] = ["name" : "LogOnDetails.UserName","type" : "text", "value" : username]
//Make database a choosable number parameter later
sendLoginRequest(url: HAC_URL, parameters: params)
}
else
{
errorOutput.text = "Invalid Login"
}
}
func sendLoginRequest(url: String, parameters : [String : String])
{
Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding()).responseString
{
response in
if response.result.isSuccess
{
self.errorOutput.text = "Success"
print(response.result.value!)
}
else if response.result.isFailure
{
self.errorOutput.text = "Connection Issues"
print(response.error.debugDescription)
}
else
{
self.errorOutput.text = "Program Failure"
}
}
}
Edit
I need to input a user entered string into an HTML
ios swift alamofire
I'm trying to develop an app for my school's grade portal (Using the Home Access Center platform).
(Im a bit of a beginner so please excuse any lapses in the information I have provided and if you need to me to provide it, I will be active)
So far I've been able to send the request and receive a response in the form of a string through .responseString, and when I print the response I'm getting an HTML doc type with the login parameters near the bottom. I have gotten this far, but I'm not sure how to pass my user-inputted data to the correct location. (I know where the parameters are located, but don't know how to access them).
The HTML file output looks like this,
<div>
<label class="sg-logon-left" for="LogOnDetails_UserName">User Name:</label>
<input class="sg-logon-right" data-val="true" data-val-required="The User Name: field is required." id="LogOnDetails_UserName" name="LogOnDetails.UserName" type="text" value="" />
<span class="field-validation-valid sg-logon-validation" data-valmsg-for="LogOnDetails.UserName" data-valmsg-replace="true"></span>
</div>
(just a small chunk of the file)
I've tried passing multiple different combinations of the parameters using a dictionary, but none of them have actually made it to that location. This website uses a action form (I'm a beginner, so I'm not sure about different interactions with HTML elements), but this is what passes when I run my program
<form action="/HomeAccess/SessionReset?ReturnUrl=%2FHomeAccess%2FAccount%2FLogOn%3FReturnUrl%3D%252fhomeaccess%252f" method="post">
< div class="sg-container" id="SignInSectionContainer">
I will send my current Swift code if need be, but if you might have a solution, the website is https://hac.friscoisd.org/HomeAccess/Account/LogOn?ReturnUrl=%2fhomeaccess%2f and I'm using Alamofire and Xcode (latest versions)
I have looked extensively for a thread that might have my answer, but I'm unable to find anything besides information on how to parse HTML files.
Thanks a ton for any help and please reroute me if this is a duplicate question.
Swift Code
@IBAction func getLoginData(_ sender: Any) {
let username = Username.text!
let password = Password.text!
if (username != "" && password != "")
{
let params : [String : String] = ["name" : "LogOnDetails.UserName","type" : "text", "value" : username]
//Make database a choosable number parameter later
sendLoginRequest(url: HAC_URL, parameters: params)
}
else
{
errorOutput.text = "Invalid Login"
}
}
func sendLoginRequest(url: String, parameters : [String : String])
{
Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding()).responseString
{
response in
if response.result.isSuccess
{
self.errorOutput.text = "Success"
print(response.result.value!)
}
else if response.result.isFailure
{
self.errorOutput.text = "Connection Issues"
print(response.error.debugDescription)
}
else
{
self.errorOutput.text = "Program Failure"
}
}
}
Edit
I need to input a user entered string into an HTML
ios swift alamofire
ios swift alamofire
edited Nov 22 '18 at 18:44
Charan
asked Nov 22 '18 at 17:34
CharanCharan
13
13
Please put your current code that you are trying with swift, just like you have writen HTML, so we can help you. Plus see on stackoverflow how to ask a good question here stackoverflow.com/help/how-to-ask
– Xcodian Solangi
Nov 22 '18 at 17:43
Alright I included the Swift code, and changed the question a bit
– Charan
Nov 22 '18 at 17:48
Your list of parameters doesn't look right. As far as I can tell Alamofire request parameters are just name value pairs, you don't need type or text, just the value. You also haven't actually attempted to send the password. Try ["LogOnDetails.UserName":username, "LogOnDetails.Password":password]
– Dale
Nov 22 '18 at 22:53
I tried that and am running into the same issue. I'm also suspecting that I need to set up something that triggers the button on the site.
– Charan
Nov 25 '18 at 0:17
add a comment |
Please put your current code that you are trying with swift, just like you have writen HTML, so we can help you. Plus see on stackoverflow how to ask a good question here stackoverflow.com/help/how-to-ask
– Xcodian Solangi
Nov 22 '18 at 17:43
Alright I included the Swift code, and changed the question a bit
– Charan
Nov 22 '18 at 17:48
Your list of parameters doesn't look right. As far as I can tell Alamofire request parameters are just name value pairs, you don't need type or text, just the value. You also haven't actually attempted to send the password. Try ["LogOnDetails.UserName":username, "LogOnDetails.Password":password]
– Dale
Nov 22 '18 at 22:53
I tried that and am running into the same issue. I'm also suspecting that I need to set up something that triggers the button on the site.
– Charan
Nov 25 '18 at 0:17
Please put your current code that you are trying with swift, just like you have writen HTML, so we can help you. Plus see on stackoverflow how to ask a good question here stackoverflow.com/help/how-to-ask
– Xcodian Solangi
Nov 22 '18 at 17:43
Please put your current code that you are trying with swift, just like you have writen HTML, so we can help you. Plus see on stackoverflow how to ask a good question here stackoverflow.com/help/how-to-ask
– Xcodian Solangi
Nov 22 '18 at 17:43
Alright I included the Swift code, and changed the question a bit
– Charan
Nov 22 '18 at 17:48
Alright I included the Swift code, and changed the question a bit
– Charan
Nov 22 '18 at 17:48
Your list of parameters doesn't look right. As far as I can tell Alamofire request parameters are just name value pairs, you don't need type or text, just the value. You also haven't actually attempted to send the password. Try ["LogOnDetails.UserName":username, "LogOnDetails.Password":password]
– Dale
Nov 22 '18 at 22:53
Your list of parameters doesn't look right. As far as I can tell Alamofire request parameters are just name value pairs, you don't need type or text, just the value. You also haven't actually attempted to send the password. Try ["LogOnDetails.UserName":username, "LogOnDetails.Password":password]
– Dale
Nov 22 '18 at 22:53
I tried that and am running into the same issue. I'm also suspecting that I need to set up something that triggers the button on the site.
– Charan
Nov 25 '18 at 0:17
I tried that and am running into the same issue. I'm also suspecting that I need to set up something that triggers the button on the site.
– Charan
Nov 25 '18 at 0:17
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435928%2fhow-to-input-a-user-entered-string-into-an-html-input-swift%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435928%2fhow-to-input-a-user-entered-string-into-an-html-input-swift%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please put your current code that you are trying with swift, just like you have writen HTML, so we can help you. Plus see on stackoverflow how to ask a good question here stackoverflow.com/help/how-to-ask
– Xcodian Solangi
Nov 22 '18 at 17:43
Alright I included the Swift code, and changed the question a bit
– Charan
Nov 22 '18 at 17:48
Your list of parameters doesn't look right. As far as I can tell Alamofire request parameters are just name value pairs, you don't need type or text, just the value. You also haven't actually attempted to send the password. Try ["LogOnDetails.UserName":username, "LogOnDetails.Password":password]
– Dale
Nov 22 '18 at 22:53
I tried that and am running into the same issue. I'm also suspecting that I need to set up something that triggers the button on the site.
– Charan
Nov 25 '18 at 0:17