467,875 Members | 1,503 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,875 developers. It's quick & easy.

how to make a custom contact form using HTML and CSS.

2Bits
hey i am running a website. i want to make a custom contact form for users using HTML CSS. can anyone guide me or have a code related to this please send me.
3 Days Ago #1
  • viewed: 756
Share:
3 Replies
64KB
Hello,

Refer to the following site:
https://www.w3schools.com/howto/howt...ntact_form.asp
2 Days Ago #2
Bit
Hey hi,

The HTML form is used to collect the user inputs. HTML provides a <form> tag to create forms. To take input from the user we use the <input> tag inside the form so that all collected user data can be sent to the server for processing. There are different input types like ‘button’, ‘checkbox’, ‘number’, ‘text’, ‘password’, ‘submit’ etc.

<form action="/submit_data.php">
<label>Enter your name: </label>
<input type="text" name="name" />
<label>Enter Mobile number </label>
<input type="number" name="mobile_no"/>
<input type="submit" value="Submit">
</form>

Additionally, you could visit W3Schools for more information.
2 Days Ago #3
16bit
While you can use a form with html alone, you need php or something similar to be able to do anything with the post data you get back from the form.

Therefore, you would do something like this in a php file. In this case, the form submits back to the same file and the php then executes the code to do something with name. It is important that we place the php code first, and then do the HTML code second. (Otherwise we have to configure the server to execute html documents as php code.) If we want to submit the form elsewhere, we put a file path in action attribute of the form, For example:
Expand|Select|Wrap|Line Numbers
  1. <form action="/foo.php">
  2.  
will submit the form to foo.php located in the root directory of the server (in which case we would put the everything from <?php to ?> in the foo.php file.) the first forward slash assumes the server root.

In this case we submit the form to self, and simply echo the name to output it to the screen:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. if ( !isset($_POST['name']) ) {
  4. // !isset means "not set", $_POST['name'] is the post data for the name field sent to php by the HTML code. 
  5. echo ' some error message if there is no input for name';
  6. exit;
  7. } elseif ( isset($_POST['name]) ) {
  8. //  isset is the oposite of !isset . We then grab the post data to a php variable to make it 
  9. //  easier to work with, and then do whatever you want to do with the data. here, we simply print it to the screen using echo.  
  10. $name = $_POST['name'];
  11. echo $name;
  12. } else {
  13. //error message to do if we got post data for name, but the code can't execute.
  14. echo 'there was an unidentified error';
  15. exit;
  16. }
  17. //continue php code here after we have dealt with working with name.
  18. exit;
  19. ?>
  20.  
  21. <!DOCTYPE html>
  22.      <head>
  23.      </head>
  24.      <body>
  25.  
  26.           <form action="" method="post">
  27.           <label for="name">Enter your name: </label>
  28.           <input type="text" name="name" placeholder="your name here" id="name" required />
  29.           </form>
  30.  
  31.      </body>
  32. </html>
  33.  
22 Hours Ago #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Luiz Siqueira Neto | last post: by
3 posts views Thread by John | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.