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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:17:05+00:00 2026-05-31T03:17:05+00:00

I have a form for a ‘user profile’ with the following fields: <form> First

  • 0

I have a form for a ‘user profile’ with the following fields:

<form>
    First Name: <input id="first_name" />
    Last Name: <input id="last_name" />
    Phone Number: <input id="phone_number" />
    City:   <input id="city" />
</form>

However, what if I don’t want “phone number” and “city” to be visible to a select set of users?

How can I dynamically hide these fields, depending on, say for example, which user is logged in? I am currently using PHP and MySQL. Would it be best to add the “field id’s” to the database, and then query the database record to see which fields should be hidden and which fields should be visible? Or is there a better way to do this?

My apologies if this is a bit ambiguous. If it doesn’t make sense, I can try to clarify.

Thanks very much.

EDIT: I’d like to clarify what I am trying to achieve. I am trying to dynamically show the fields based on which user logs in. Also, when I said “hidden”, I actually should have said “removed.” See my example below

E.g.,

If JoeUser logs in, he would see:

<form>
    First Name: <input id="first_name" />
    Last Name: <input id="last_name" />
    Phone Number: <input id="phone_number" />
    City:   <input id="city" />
</form>

But, if JaneUser logs in, she would see (based on preferences set in the database):

<form>
    First Name: <input id="first_name" />
    Last Name: <input id="last_name" />
</form>

My question is: What is the best way to achieve this? I’m assuming these preferences need to be database-driven. Any input would be great.

  • 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-05-31T03:17:06+00:00Added an answer on May 31, 2026 at 3:17 am

    Depending on how you’ve built the site there are quite a few ways to do this but since you’re new to PHP I’ll assume that it’s just an inline procedural script. In which case you need to check whether or not the user is set in the session and then show or hide depending on the output.

    Something similar to the following

    <?php if(isset($_SESSION['id'])) : ?>
    
    <form>
        First Name: <input id="first_name" />
        Last Name: <input id="last_name" />
        Phone Number: <input id="phone_number" />
        City:   <input id="city" />
    </form>
    
    <?php endif; ?>
    

    The if statment checks if a session ID is set (this will likely change depending on how you’re handling user sessions etc) and then shows the form.

    Edit:
    Just noticed that you’ve edited your original question. To do this you could so something similar to the following, this assumes once again that you’re using sessions and that you have the users user type set in a session (not great, but as a beginner it’s quick).

    <?php if(isset($_SESSION['id'])) : ?>
    
        <form>
            First Name: <input id="first_name" />
            Last Name: <input id="last_name" />
        </form>
    
    <?php else if(isset($_SESSION['id']) && (isset($_SESSION['user_type']) && $_SESSION['user_type'] == 'phoneuser')) : ?>
    
        <form>
            First Name: <input id="first_name" />
            Last Name: <input id="last_name" />
            Phone Number: <input id="phone_number" />
            City:   <input id="city" />
        </form>
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form like this: <input type='text' name='people' id='namepeople'> <input type='hidden' name='idpeople' id='idpeople'> <input
I have form like this: <form method=POST> <p> Nazwa kategorii: <br /> <input name=NazwaKat
I have form fields which are checkboxes as below : <input id=abirrules@gmail.com type=checkbox checked=checked
I have form fields where the user enters in: percents: 50.5% money: $144.99 dates:
I have form who validate user input, I use PHP, Javascript and AJAX. I
i have form with user data to input and javascript ajax to send information
I have form like this: <div class=satu> <input type='text' size='1' maxlength='1' name='score[1][]' id='score[1][]'> </div>
I have form build with yii framework. The first 2 inputs is first_name and
I have form with user defined filters ( combobox with column names, combobox with
I have form with one input for email and two submit buttons to subscribe

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.