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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:30:21+00:00 2026-06-11T02:30:21+00:00

I have a simple form for this scenario written in razor/webmatrix. I would like

  • 0

I have a simple form for this scenario written in razor/webmatrix. I would like to have a user be able to login to an external website with the login credentials provided by my db.Query via a foreach loop. The login works if I don’t use a foreach loop. It simply returns the first row from the DB Query, and logs in. When I add the foreach loop, it opens the login page without any credentials. Any help would be appreciated. My code is below:

var selectQueryString = "SELECT user_id,password FROM user_table
var user_row = db.Query(selectQueryString);


     <form name="UpdateOrRac" method="POST" action="Login Page URL would be here">      

             @foreach (var row in user_row){
                <div>
                 <input  name="txtUserID" value="@row.user_id" readonly="readonly" />
                 <input  name="txtPassword" value="@row.password" readonly="readonly" />
                 <input type="submit" value="Login" />
                    </div> 
            }

    </form>
  • 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-11T02:30:22+00:00Added an answer on June 11, 2026 at 2:30 am

    With the foreach loop your page sends to the login page all the user/password pairs stored in your database together.

    I think that you should select a user and populate with it the form.
    Somenthing like:

    @{   
        var db = Database.Open("MyDb");
        var selectQueryString = "SELECT user_id,password FROM user_table WHERE user_id = @0";
        var user_row = db.QuerySingle(selectQueryString, "YourUserName");
    }
     <form name="UpdateOrRac" method="POST" action="Login.cshtml">
        <div>
            <input  name="txtUserID" value="@user_row.user_id" readonly="readonly" />
            <input  name="txtPassword" value="@user_row.password" readonly="readonly" />
            <input type="submit" value="Login" />
        </div>
    </form> 
    

    Edit

    In response to your comment, yes, but now your target is clearer.

    To obtain a list of your acccounts with the possibility of login, the easiest way is to use a link to the Login page with a querystring with userid and password:

    @{   
        var db = Database.Open("MyDb");
        var selectQueryString = "SELECT user_id,password FROM user_table";
        var user_row = db.Query(selectQueryString); 
    } 
    
    <div>
        @foreach(var row in user_row)
        {
            <p>
                @row.user_id &nbsp;&nbsp; 
                @row.password &nbsp;&nbsp;
                <a href="~/Login?id=@row.user_id&pwrd=@row.password">Login</a>
            </p>
        }
    </div>  
    

    You can get the passed data in the Login.cshtml page with this statements:

    var user = Request.QueryString["id"];
    var pwrd = Request.QueryString["pwrd"];
    

    If the security is a concern, you must consider that GET and POST are nearly the same (look at Is either GET or POST more secure than the other?)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple form like this which accepts only two values string action and
I have a simple form like this : <form method=post name=change_pass id=change_pass action=change_pass2.php> <input
I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
I have a simple form that looks like this: <%= simple_form_for @study,:url => studies_path,
I have a simple html form that is structured something like this: <form name=test
I have a simple form like: <form action= method=post> <input type=text name=user id=user class=txt
I have this simple form which shows a pop up calendar when clicked on
I have a simple html form. This form has a specific width and margin
I'm creating a simple form and in this form I want to have an
I have started using Simple-form and Bootstrap and I have tried to follow this

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.