Home > Software design >  How can I send data to the server via HTML?
How can I send data to the server via HTML?

Time:01-14

I just started with Html and I want to send some input info collected from the front end to my server. The source I’m learning from is very blunt on this point. How can I do this?

CodePudding user response:

Use an HTML form.

<form action="https://url.goes.here" method="post">
  <label for="full-name">Full Name</label>
  <input type="text" id="full-name" name="full-name" placeholder="Your Full Name" required autocomplete="name" />
  <button type="submit">Submit</button>
</form>

CodePudding user response:

<form action="https://<yourwebsitedomain>/login_form" method="post">
  <label for="username">Your Username</label>
  <input type="text" id="username" name="username" placeholder="Type your username" required />
  <label for="email">Type your email</label>
  <input type="text" id="email" name="email" placeholder="Type your email" required />
  <button type="submit">Submit</button>
</form>

At the server side the parameters will be like a hash with keys as the name attribute of the input field and the value will be the value filled by the user. Lets say user fills the username as "username" and email as "[email protected]", then the hash will be like { 'username' => 'username', 'email' => '[email protected]' } The way that you extract and use these parameters/hash will depend on the language that you are using for the back end.

  •  Tags:  
  • html
  • Related