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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:29:33+00:00 2026-06-08T02:29:33+00:00

I have an HTML form as follows: <form enctype="multipart/form-data" action=" " method="post"> <input name="username"

  • 0

I have an HTML form as follows:

<form enctype="multipart/form-data" action=" " method="post">
<input name="username" type="text"/>
<input type="submit" value="Upload" class="btn btn-primary"/><br/>
</form>

I want that the user of this form enters data in the input box. Then I would like this data to be the value of a PHP string – e.g. $username = "MY_NAME"; where MY_NAME is the value of the HTML form entered by the user.

If the input by the user in the input box is e.g. "STACKOVERFLOW" I want the PHP string to be $username = "STACKOVERFLOW";

  • 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-08T02:29:35+00:00Added an answer on June 8, 2026 at 2:29 am

    When the form submits, you need to get the values from the $_POST array

    You can do print_r($_POST) to see everything it contains (all of the form fields) and reference them individually as well.

    Username will be $_POST['username']

    I recommend reading a tutorial on working with forms and PHP… here’s a good one

    Since you’re obviously a beginner I’ll help you out a bit more:

    Give your submit button a name:

    <form enctype="multipart/form-data" action="" method="post">
        <input name="username" type="text"/>
        <input type="submit" name="submit" value="Upload" class="btn btn-primary"/><br/>
    </form>
    

    Because action is blank, it will POST to the current page. At the top of your file, you can check to see if the form was submitted by checking if $_POST['submit'] is set (I gave your submit button that name).

    if(isset($_POST['submit'])) {
        // form submitted, now we can look at the data that came through
        // the value inside the brackets comes from the name attribute of the input field. (just like submit above)
        $username = $_POST['username'];
    
        // Now you can do whatever with this variable.
    }
    // close the PHP tag and your HTML will be below
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html form <form action=process.php method=post> <input type=checkbox name=name[v1] /> <input type=checkbox
I have a simple form like: <form action= method=post> <input type=text name=user id=user class=txt
I use fileuploader Jquery, I tried to form defined as follows: <Form enctype="multipart/form-data" action="<%:Url.Action("Edit","Ticket")%>"
Ok, I have index.html with a form as follows: <form action=process.php method=post> <table> <tr>
I have a html file like following: <form action=/2811457/follow?gsid=3_5bce9b871484d3af90c89f37 method=post> <div> <a href=/2811457/follow?page=2&amp;gsid=3_5bce9b871484d3af90c89f37>next_page</a> &nbsp;<input
I have got a simple HTMl form with one field as follows: <input type=text
I got two simple input text fields in a HTML form: <input type=text name=data[User][name]
I have a html form for uploading a file, which is as follows: $uploadhtml
i have html form i am using <a href="#" onclick="document.aa.submit()"> instead of submit button
My input tag started to go crazy... I have html form for input to

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.