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 7868619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:03:40+00:00 2026-06-03T01:03:40+00:00

I have a login view controller that uses the php/mysql/POST function to verify if

  • 0

I have a login view controller that uses the php/mysql/POST function to verify if a user is authorized. Once authorized, they enter the application.

My question is, once they are in the application, how do I “grab” their username and use it to append to any data that they upload to my database while they are in my app?

I am assuming I append it to my current NSMutableData string that carries the text blocks that they upload, but how would I “grab” this username to append it?

Assuming I have two view controllers, “login” and “main”, and the content is being uploaded on “main”, how do I pass the username from the “login” view to the “main” view so that I can append it when the user hits the upload button (which resides on the main view)?

EDIT: Where I want this username retrieved is in the following:

-(IBAction)uploadImage:(id)sender  {
NSLog(@"uploadImage");



//and for retrieval





NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *authenticatedUsersName = [defaults objectForKey:@"username"];


NSMutableString *postString = [NSMutableString stringWithString:kPostURL]; 



[postString appendString:[NSString stringWithFormat:@"&%@=%@", kText, textField.text]];



[postString setString:[postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
  • 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-03T01:03:42+00:00Added an answer on June 3, 2026 at 1:03 am

    If you’re not concerned with security of a username, why don’t you store the username in NSUserDefaults upon successful authentication? You can do something like this….

    //upon authentication...
    
    NSUserDefault *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"username"] == nil) //we haven't saved anything yet
         [defaults setObject:authenticatedUsersName forKey:@"username"];
    
    [defaults synchronize];  //saves the new defaults
    
    //and for retrieval
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *authenticatedUsersName = [defaults objectForKey:@"username"];
    

    I think this design gives you more flexibility so you can use the username across all view controllers in your app.

    post re-edit

    Why can’t you just format the string somewhere in this function? Whats the exact post url format?

        -(IBAction)uploadImage:(id)sender  {
        NSLog(@"uploadImage");
    
        //and for retrieval     
    
        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        NSString *authenticatedUsersName = [defaults objectForKey:@"username"];
    
        //MY CHANGES, CAN YOU DO EITHER OF THESE?
    
        NSMutableString *postString = [NSMutableString stringWithString:[NSString stringWithFormat:@"%@-%@", kPostURL, authenticatedUsersName]; 
    
        [postString appendString:[NSString stringWithFormat:@"&%@=%@&%@", kText, textField.text, authenticatedUsersName]];
    
        [postString setString:[postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login view controller that appears only if a user is not
So I have two view controller that I load on the app delegate when
I have login view that takes a LoginPageViewModel: public class LoginPageViewModel : PageViewModel {
I have a storyboard set up with working login and main view controller, the
I have to create a simple form that uses JSP for the view with
I'm writing an iPhone program that has a login view controller that allows the
hai all, in my iphone application i have a login view with two text
I have this login form. This form is a grouped table view where the
In my View, I have included the css : <link rel=stylesheet type=text/css href='<%=Url.Content(~/Content/login.css)%>'/> in
I have encapsulated all my table view logic on a UITableViewController that is linked

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.