Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:22:32+00:00 2026-06-13T04:22:32+00:00

What I am tying to do is to login to a website from Xcode.

  • 0

What I am tying to do is to login to a website from Xcode. I am communicating with the website by using JavaScript and the DOM. Here is my issue. I can enter the username and password into the website and then submit that form and it will log me in but what I don’t know how to do is to see if the password is valid or not.

On the website if the password is invalid it will say “Unable to login.”

this is what i have so far

-(IBAction)Login:(id)sender {

   stud_pass = Username.text;
   password1 = Password.text;

   //Puts the 2 NSStrings into the websites text fields
   [webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"document.getElementById('stud_pass').value = ('%@');", stud_pass]];
   [webView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"document.getElementById('password1').value = ('%@');", password1]];

   //Sends the form
   [webView stringByEvaluatingJavaScriptFromString:@"document.forms[0].submit();"];


   //See if login was sucsessfull
   if (

   } else {

   }
}

This is where I am stuck, and I don’t know how I can make the webview tell xcode that the login was unsuccessful and then based on that make xcode have a certain output.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:22:33+00:00Added an answer on June 13, 2026 at 4:22 am

    The basic problem with what you are assuming you can do in the “//See if login was sucsessfull” portion of your code is that this function will have returned long before(in machine time) your UIWebView will have loaded the page stating whether or not you have successfully logged in. This is how it should be since your IBAction method is tied to the UI and locking that method with a network request would, in short, be bad.

    What you will need to do is to determine whether you have a successful login by using a stringByEvaluatingJavaScriptFromString: call while in one of the UIWebView‘s delegate methods, probably webViewDidFinishLoad:. The implementation of that function will vary greatly based on the structure of the website you are attempting to login to. But could look something like this:

    -(void)webViewDidFinishLoad:(UIWebView *)webView{
        if ([webView.request.URL.absoluteString isEqualToString:@"LoginResponceURLHere"]){
            NSString *successString = [webView stringByEvaluatingJavaScriptFromString:@"SomeJavaScriptTestOfSuccess"];
            // Check successString for known responces to test.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send a website my username or password using some jar
I'am trying to get the Login button from Facebook to work on my website
I'm trying to login automatically in a website using Perl with WWW::Mechanize . What
I'm trying to implement a login system to sign into a website using public
I am thinking of tying in a Facebook JavaScript-based application with an existing website
I am trying to login to my JBoss webapp using the example code from
I am attempting to grab revenue from a website past a login page through
I'm working on a website located here: http://www.travelanchevacations.com/mainlogin.aspx When trying to login, I get
I would like to know more about how to login on a website from
I'm trying to make a login page for my website I am using xampp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.