Sort
Profile photo for Bulat Bochkariov

It looks like your solution already does what you want, but it does have the downside of taking the user to another page when they submit the form. Here's a somewhat hacky but Javascript-free fix: Keep doing what you're doing, but submit the form to a hidden iframe instead.

  1. <!--  
  2. Your new HTML. Note the target="sneaky" on the form and the matching  
  3. name="sneaky" on the iframe. 
  4. --> 
  5.  
  6. <iframe src="doesnt-matter" class="hidden" name="sneaky"></iframe> 
  7.  
  8. <form method="post" action="." target="sneaky"> 
  9. <input type="hidden" name="confirm" value="1" /> 
  10. <input type="submit" value="OK" /> 
  11. </form> 

  1. /* And some CSS to hide the iframe */ 
  2.  
  3. .hidden { 
  4. display:none; 
  5. } 

Just like using target on a link to make it open in a certain window, you can use it on a form to control where the submission results show up. A hidden iframe is a valid target too, so the data will go where you send it and the results will just "appear" in a piece of the UI that your users never see.

Profile photo for Metis Chan

With today’s modern day tools there can be an overwhelming amount of tools to choose from to build your own website. It’s important to keep in mind these considerations when deciding on which is the right fit for you including ease of use, SEO controls, high performance hosting, flexible content management tools and scalability. Webflow allows you to build with the power of code — without writing any.

You can take control of HTML5, CSS3, and JavaScript in a completely visual canvas — and let Webflow translate your design into clean, semantic code that’s ready to publish to the web, or hand off

With today’s modern day tools there can be an overwhelming amount of tools to choose from to build your own website. It’s important to keep in mind these considerations when deciding on which is the right fit for you including ease of use, SEO controls, high performance hosting, flexible content management tools and scalability. Webflow allows you to build with the power of code — without writing any.

You can take control of HTML5, CSS3, and JavaScript in a completely visual canvas — and let Webflow translate your design into clean, semantic code that’s ready to publish to the web, or hand off to developers.

If you prefer more customization you can also expand the power of Webflow by adding custom code on the page, in the <head>, or before the </head> of any page.

Get started for free today!

Trusted by over 60,000+ freelancers and agencies, explore Webflow features including:

  • Designer: The power of CSS, HTML, and Javascript in a visual canvas.
  • CMS: Define your own content structure, and design with real data.
  • Interactions: Build websites interactions and animations visually.
  • SEO: Optimize your website with controls, hosting and flexible tools.
  • Hosting: Set up lightning-fast managed hosting in just a few clicks.
  • Grid: Build smart, responsive, CSS grid-powered layouts in Webflow visually.

Discover why our global customers love and use Webflow.com | Create a custom website.

Profile photo for Md. Rusul Azom

To send data from PHP to HTML, you can use a combination of PHP and HTML tags. Here are some ways to do it:

  1. Using the echo statement: You can use the PHP echo statement to output data to an HTML page. For example, if you have a variable in PHP called $name that contains a name, you can use the following code to output it in HTML:html
  1. <p><?php echo $name; ?></p> 

2.Using HTML forms: You can use HTML forms to get user input and send it to a PHP script for processing. For example, you can create an HTML form with a text input field and a submit button, and set the form's action attribute to the URL o

To send data from PHP to HTML, you can use a combination of PHP and HTML tags. Here are some ways to do it:

  1. Using the echo statement: You can use the PHP echo statement to output data to an HTML page. For example, if you have a variable in PHP called $name that contains a name, you can use the following code to output it in HTML:html
  1. <p><?php echo $name; ?></p> 

2.Using HTML forms: You can use HTML forms to get user input and send it to a PHP script for processing. For example, you can create an HTML form with a text input field and a submit button, and set the form's action attribute to the URL of your PHP script. When the user submits the form, the data will be sent to the PHP script for processing.

3. Using the GET method: You can use the GET method to send data from an HTML page to a PHP script via the URL. For example, you can create a link in HTML that includes data in the URL, like this:

  1. <a href="example.php?name=John">Click here</a> 

In the PHP script, you can retrieve the data using the $_GET superglobal variable, like this:

  1. $name = $_GET['name']; 

4. Using the POST method: You can use the POST method to send data from an HTML form to a PHP script. In the HTML form, set the method attribute of the form to "post", and in the PHP script, retrieve the data using the $_POST superglobal variable. For example:

  1. <form method="post" action="example.php"> 
  2. <input type="text" name="name"> 
  3. <input type="submit" value="Submit"> 
  4. </form> 

In the PHP script: $name = $_POST['name'];

These are just a few examples of how to send data from PHP to HTML. The method you choose will depend on your specific needs and requirements.

Profile photo for Frank Berger

The answer is - maybe

A POST request is first and foremost the way to send larger amounts of data to the server - that is much more data than in the GET requests’ url parameters.

A server may or may not answer with a body - or data if you want - to that request, it depends on to the nature of the data sent back and forth, and the implementation of the server-side.

An often used workflow for example is to send form data with post. If the data is incorrect / invalid the server answers with the form again, but with the fields pre-filled with the received data and a note what is wrong (not an email,

The answer is - maybe

A POST request is first and foremost the way to send larger amounts of data to the server - that is much more data than in the GET requests’ url parameters.

A server may or may not answer with a body - or data if you want - to that request, it depends on to the nature of the data sent back and forth, and the implementation of the server-side.

An often used workflow for example is to send form data with post. If the data is incorrect / invalid the server answers with the form again, but with the fields pre-filled with the received data and a note what is wrong (not an email, missing field, etc).

If the data is correct though it answers with a 302 or 303 redirect to some other page (the ‘thank you’ page for example) - this is done to prevent double posts (sending the same data again) if the user to decided to reload the browser at this point or to go back with the history-back button.

If POST is used through a XML-HTTP api (ajax) the response usually either is an error report or an ok status, usually with json in the body. But you could get back whole snippets of html as well, that depends again on the implementation

Profile photo for Rohit Rana

POST method is suitable in the condition where a significant amount of information can pass through. When a server receives the request by a form employing POST, it continues to “listens” for the left information. In simple words, the method transfers all the relevant information of the form input instantly after the request to the URL is made.

The POST method needs to establish two contacts with the web server whereas GET just makes one. The requests in the POST are managed in the same way as it is managed in the GET method where the spaces are represented in the plus (+) sign and rest charact

POST method is suitable in the condition where a significant amount of information can pass through. When a server receives the request by a form employing POST, it continues to “listens” for the left information. In simple words, the method transfers all the relevant information of the form input instantly after the request to the URL is made.

The POST method needs to establish two contacts with the web server whereas GET just makes one. The requests in the POST are managed in the same way as it is managed in the GET method where the spaces are represented in the plus (+) sign and rest characters are encoded in the URL pattern. It can also send the items of a file.

POST is one of the most common HTTP methods.

Some other notes on POST requests:

  • POST requests are never cached
  • POST requests do not remain in the browser history
  • POST requests cannot be bookmarked
  • POST requests have no restrictions on data length

Key Differences Between GET and POST Method in HTML

  1. GET method places the parameters inside the URI while POST method appends the parameters into the body.
  2. GET is essentially used for fetching the information. As against, the purpose of POST method is to update the data.
  3. POST query results cannot be bookmarked whereas GET query results can be bookmarked because it exists in the form of URL.
  4. In GET method the information is visible in the URL which increases vulnerabilities and the risk of hacking. In contrast, the POST method does not show variable in URL and multiple encoding techniques can also be used in it, which make it resilient.
  5. When GET method is used in the form, only ASCII characters are accepted in data types. On the contrary, POST method does not bind form data types and permit binary as well as ASCII characters.
  6. The variable size in GET method is approx 2000 characters. Inversely, POST method allows up to 8 Mb variable size.
  7. GET method data is cacheable while data of POST method is not.

If you find it useful kindly upvote it.

Profile photo for Fiverr

The reason you should hire a digital marketing freelancer is that it can be very overwhelming trying to do this on your own–which is why so many people and businesses outsource that work. Fiverr freelancers offer incredible value and expertise and will take your digital marketing from creation to transaction. Their talented freelancers can provide full web creation or anything Shopify on your budget and deadline. Hire a digital marketing freelancer on Fiverr and get the most out of your website today.

Profile photo for Rituparna Sonowal

With only HTML you can't do that. If it's a PHP based website then you have to have use PHP for the easiest way to send mail.

Or alternatively you can you mailto: with a href so that opens the user mail client.

  1. <a href="mailto:mail@example.com?cc=someone@example.com, another@example.com&bcc=person@example.com&subject=mail%20subject&body=Body-goes-here">Email button</a> 

This way the click will open the default mail program! Try it

Profile photo for Quora User

A website, in its most basic form, is a set of files that are stored on a webserver (technically, stored somewhere that a webserver can access. I'm going to try to keep this answer basic, though, which means leaving out details and exceptions.)

A webserver is a program whose job is to listen for requests and return data to the requester. Usually this data is the contents of a file (such as an image or an HTML document) which is part of a website. The server does not actually execute the file, just sends a copy of it to the requester.

The webserver may be configured to take an extra step with spe

A website, in its most basic form, is a set of files that are stored on a webserver (technically, stored somewhere that a webserver can access. I'm going to try to keep this answer basic, though, which means leaving out details and exceptions.)

A webserver is a program whose job is to listen for requests and return data to the requester. Usually this data is the contents of a file (such as an image or an HTML document) which is part of a website. The server does not actually execute the file, just sends a copy of it to the requester.

The webserver may be configured to take an extra step with specific kinds of requests by sending them to a separate program for special processing. This program could do all sorts of things, such as querying a database and formatting the results, or issuing commands to a device like a printer or a coffee maker, or even performing a financial transaction. Often the program will open a file on the server (such as a PHP file) and carry out the instructions in it.

But whatever else the program does, it also returns some data to the webserver, which then relays it to the original requester. Usually that data is a string of text containing HTML, and often CSS and Javascript code as well, but it could also be image data, or all sorts of other things.

The requester doesn't necessarily know (or care) whether the data came directly from a file or a separate program, as long as it is in a useful format.

Usually, the requester is a web browser, which will render some sort of visual display for the user. This may involve making additional requests to a webserver, such as for an image that needs to be displayed along with text, or for additional CSS or Javascript code to execute.

The main point here is that a web browser does most of the work. The server mainly fetches files when requested by the browser, though it may call other programs to perform special operations as well. Modern websites often require lots of these special operations, so webservers do more than they used to, but still most of the work happens in the browser.

Circling back to the specific question: as long as the webserver is already set up, creating a website can be as simple as uploading a few HTML documents and/or images.

86% of Gusto customers say automatic sync between payroll & benefits brings peace of mind.
Profile photo for Milind Wankhade

you can use forms for that purpose in form you will take button as submit and input as text.

at the back end you can use GET or POST method in PHP.

<form action="/action.php" method="get">

<input type="text" name="name"><br>

<input type="submit" value="Submit">
</form>

Explanation

here action.php is the php file.

method is GET or POST you are going to use.

action.php file content

<?php

$var = $_POST["name"];

//database operations

?>

or

<?php

$var = $_GET["name"];

//database operations

?>

Profile photo for Viktor Karpov

There’s one not so obvious way to make a GET request – make an image (`<img src=”…”>`). When a browser renders the page it makes one (trying to get the image).

Actually it could be used to exploit vulnerabilities in websites. Imagine a private part of a website (which could not be accessed without authentication, e.g. your cookies) and there’s an URL within, for instance, let it be `/remove-blog-post/?id=1`. When you go to that address it removes your first blog post since it’s accessible only by you. Seems reliable, right? Nope!

Now imagine that you open some forum page and there’s an image whi

There’s one not so obvious way to make a GET request – make an image (`<img src=”…”>`). When a browser renders the page it makes one (trying to get the image).

Actually it could be used to exploit vulnerabilities in websites. Imagine a private part of a website (which could not be accessed without authentication, e.g. your cookies) and there’s an URL within, for instance, let it be `/remove-blog-post/?id=1`. When you go to that address it removes your first blog post since it’s accessible only by you. Seems reliable, right? Nope!

Now imagine that you open some forum page and there’s an image which source points to that address. What does your browser do? It follows the link, passes you cookies and your blogpost is gone! That’s why we need POST requests too :-)

Headway makes it easy for therapists and psychiatrists to accept insurance and practice from one place.
Profile photo for Mohammed Sijas

Hi Rabul,
Thanks to A2A.

I exactly did not get your question. I hope you mean in case of get request, the data is visible in the URL and can be manipulated. But in case of POST Can you do something ?

If your question is that, yes we can.
You have to understand that both requests are HTTP, where one send data through URL or Query String. The other sends through the payload section of HTTP Header.

Hi Rabul,
Thanks to A2A.

I exactly did not get your question. I hope you mean in case of get request, the data is visible in the URL and can be manipulated. But in case of POST Can you do something ?

If your question is that, yes we can.
You have to understand that both requests are HTTP, where one send data through URL or Query String. The other sends through the payload section of HTTP Header.

There are application available which could interrupt the request being gone from the system and change it on the run.

Fiddler [ http://...

Profile photo for Tanjila Akter

Obviously it's possible to upload a file using PHP without an HTML form. You can achieve this by using a different method to send the file to the server, such as through a POST request using cURL or a similar method.

Here's an example of how you can achieve this using cURL:

  1. phpCopy code<?php 
  2. // File to be uploaded 
  3. $file_path = '/path/to/your/file.txt'; 
  4.  
  5. // URL where the file will be uploaded 
  6. $upload_url = 'https://yourwebsite.com/upload.php'; 
  7.  
  8. // Initialize cURL 
  9. $curl = curl_init(); 
  10.  
  11. // Set cURL options 
  12. curl_setopt($curl, CURLOPT_URL, $upload_url); 
  13. curl_setopt($curl, CURLOPT_POST, 1); 
  14. curl_setopt($curl, CURL 

Obviously it's possible to upload a file using PHP without an HTML form. You can achieve this by using a different method to send the file to the server, such as through a POST request using cURL or a similar method.

Here's an example of how you can achieve this using cURL:

  1. phpCopy code<?php 
  2. // File to be uploaded 
  3. $file_path = '/path/to/your/file.txt'; 
  4.  
  5. // URL where the file will be uploaded 
  6. $upload_url = 'https://yourwebsite.com/upload.php'; 
  7.  
  8. // Initialize cURL 
  9. $curl = curl_init(); 
  10.  
  11. // Set cURL options 
  12. curl_setopt($curl, CURLOPT_URL, $upload_url); 
  13. curl_setopt($curl, CURLOPT_POST, 1); 
  14. curl_setopt($curl, CURLOPT_POSTFIELDS, [ 
  15. 'file' => new CURLFile($file_path) 
  16. ]); 
  17.  
  18. // Execute cURL request 
  19. $response = curl_exec($curl); 
  20.  
  21. // Check for errors 
  22. if ($response === false) { 
  23. echo 'Error: ' . curl_error($curl); 
  24. } else { 
  25. echo 'File uploaded successfully!'; 
  26. } 
  27.  
  28. // Close cURL session 
  29. curl_close($curl); 
  30. ?> 

Then, on the server-side in your upload.php file, you can handle the uploaded file using PHP. For instance, to move the uploaded file to a specific directory, you can use move_uploaded_file:

  1. phpCopy code<?php 
  2. // Check if the file was sent 
  3. if (isset($_FILES['file'])) { 
  4. $file = $_FILES['file']; 
  5.  
  6. // Specify the directory where you want to save the uploaded file 
  7. $target_directory = '/path/to/your/target/directory/'; 
  8.  
  9. // Move the uploaded file to the target directory 
  10. $target_file = $target_directory . basename($file['name']); 
  11.  
  12. if (move_uploaded_file($file['tmp_name'], $target_file)) { 
  13. echo 'File uploaded successfully!'; 
  14. } else { 
  15. echo 'Error uploading file.'; 
  16. } 
  17. } else { 
  18. echo 'No file sent.'; 
  19. } 
  20. ?> 

Remember to set appropriate permissions on the server for the target directory where you want to save the uploaded files. Also, consider implementing security measures like file type validation, size restrictions, and sanitization to prevent potential security issues.

https://bit.ly/3tFtISR

Profile photo for Al Kirby

Google Forms:
http://docs.google.com/support/bin/answer.py?hl=en&answer=87809

This is a customized Google form that I created (scroll down) with JQ form validation and custom "success page".
http://www.urel.ufl.edu/publicRelations/marquees.html

Profile photo for Hardik Kumawat

By using PHP Script we can upload selected file or Image to server without refresh of page. After done uploading selected Image we have also uploaded image on web page without refreshing of page.

Profile photo for Mark Agius

As well as $_GET and $_POST there is $_FILES for uploading a file.

<FORM NAME="UserPhotoForm" ENCTYPE="multipart/form-data" ACTION="#" METHOD="POST">

<INPUT TYPE="FILE" NAME="Photo_file" ACCEPT=".png, .gif, .jpg, .jpeg, .*">

<INPUT TYPE="SUBMIT" VALUE="Upload image file">

</FORM>

<?php

$PostedFileInfo = $_FILES["Photo_file"];

print "<PRE>\n";

print_r($PostedFileInfo);

print "</PRE>\n";

$yourDir = "path-to-dir";

$ok = move_uploaded_file($PostedFileInfo["tmp_name"],$yourDir."/".$PostedFileInfo["name"]);

if($ok){

print "File ".$PostedFileInfo["name"]." uploaded.<BR>\n";

} else {

print "Upload failed!<BR>\n";

}

?>

Profile photo for Varun Kumar

Suppose when the POST Form is submitted, the data is going from Page A to Page B. Now if you want to modify data that is received on Page B, you need these edits:

- On Page A: change the form action from Page B to Page C.
- Create another file Page C, that gets the form data from Page A, you can manipulate the form data on Page C, and then use JavaScript to create a form on Page C, and submit it to Page B.

There is also another smart way to do that, for that you need to add a JS file on Page A. Once included, create an event that is called when user clicks the submit form button. In that event,

Suppose when the POST Form is submitted, the data is going from Page A to Page B. Now if you want to modify data that is received on Page B, you need these edits:

- On Page A: change the form action from Page B to Page C.
- Create another file Page C, that gets the form data from Page A, you can manipulate the form data on Page C, and then use JavaScript to create a form on Page C, and submit it to Page B.

There is also another smart way to do that, for that you need to add a JS file on Page A. Once included, create an event that is called when user clicks the submit form button. In that event, manipulate the form data, and then submit it.

Profile photo for Mohammad Raquib

HTML Form

  1. <form action="sendmail.php" method="post"> 
  2. <input type="text" name="name" placeholder="Enter Your Name Here"> 
  3. <input type="email" name="email" placeholder="Enter Your E-Mail Here"> 
  4. <input type="text" name="subject" placeholder="Enter The E-Mail's Subject Here"> 
  5. <textarea name="message" placeholder="Enter The Message Here"></textarea> 
  6. <button type="submit">Send E-Mail</button> 
  7. </form> 

Code For “sendmail.php”

  1. <?php 
  2. if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['message'])){ 
  3. $name = $_POST['name']; 
  4. $email = $_POST['email']; 
  5. $subject = $_POST['subject' 

HTML Form

  1. <form action="sendmail.php" method="post"> 
  2. <input type="text" name="name" placeholder="Enter Your Name Here"> 
  3. <input type="email" name="email" placeholder="Enter Your E-Mail Here"> 
  4. <input type="text" name="subject" placeholder="Enter The E-Mail's Subject Here"> 
  5. <textarea name="message" placeholder="Enter The Message Here"></textarea> 
  6. <button type="submit">Send E-Mail</button> 
  7. </form> 

Code For “sendmail.php”

  1. <?php 
  2. if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['message'])){ 
  3. $name = $_POST['name']; 
  4. $email = $_POST['email']; 
  5. $subject = $_POST['subject']; 
  6. $message = $_POST['message']; 
  7. $sent = mail('adminemail@domain.com', $subject, $message, 'From: '.$name.'<'.$email.'>'); 
  8. if($sent){ 
  9. echo 'Mail Sent Successfully.'; 
  10. } else { 
  11. echo 'There Was An Error While Sending Mail.'; 
  12. } 
  13. } else { 
  14. echo 'One or More Required Fields Were Missing'; 
  15. } 
Profile photo for Sune Jakobsson

Yes, the server will respond with a HTTP code, and possibly some data. It all depends on what it is, a transaction code is quite usual, or a object creation link.

Profile photo for Narendra Pawar

1. Create an HTML form with the required data collection fields.

2. Connect to the MySQL database with PHP and enter the form data into a table.

3. Send an email with the form data to the selected recipient using PHP's mail function.(s).

As an example, consider the following PHP code:

<?php

// Connect to the MySQL database

$servername = "localhost";

$username = "username";

$password = "password";

$dbname = "database_name";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}

// Collect form data

$na

1. Create an HTML form with the required data collection fields.

2. Connect to the MySQL database with PHP and enter the form data into a table.

3. Send an email with the form data to the selected recipient using PHP's mail function.(s).

As an example, consider the following PHP code:

<?php

// Connect to the MySQL database

$servername = "localhost";

$username = "username";

$password = "password";

$dbname = "database_name";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}

// Collect form data

$name = $_POST['name'];

$email = $_POST['email'];

$message = $_POST['message'];

// Insert data into the MySQL database

$sql = "INSERT INTO table_name (name, email, message)

VALUES ('$name', '$email', '$message')";

if ($conn->query($sql) === TRUE) {

echo "Data inserted successfully";

} else {

echo "Error: " . $sql . "<br>" . $conn->error;

}

// Send email with form data

$to = "recipient@example.com";

$subject = "New form submission";

$body = "Name: $name\nEmail: $email\nMessage: $message";

$headers = "From: sender@example.com";

if (mail($to, $subject, $body, $headers)) {

echo "Email sent successfully";

} else {

echo "Email sending failed";

}

// Close MySQL database connection

$conn->close();

?>

Please keep in mind that this code is only an example and should be updated to meet your individual use case. To avoid security risks, form data should be sanitized and validated.

Profile photo for Manoj Kulkarni

Its pretty simple you can achieve it by Web Scraping or Parsing.

The Best available tool is Simple DOM parser in PHP. This hwlpsy you to parse the HTML page using the class , ids, div or tags in the HTML. And this is pretty simple to use as well.


Once you parse your required data you can post this to MySql database.

Profile photo for Quora User

Yes, an example would be to use the JavaScript framework, jQuery, to send a GET or a POST request using the functions $.get(...) and $.post(...) respectively.

Profile photo for Abdulbasit Rubeiyya

Well there is one easy way to so with PHP

  1. $content = http_build_query (array (  
  2. // this is where you list all data you want to post 
  3. 'key' => '123456789', 
  4. 'secret' => '13456abcdef' 
  5. )); 
  6.  
  7. $context = stream_context_create (array ( 
  8. 'http' => array ( 
  9. 'method' => 'POST', 
  10. 'content' => $content, 
  11. ) 
  12. )); 
  13.  
  14. $result = file_get_contents('http://localhost/poster.php', null, $context); 

the submission will just act the same way you submit the normal HTML form , but we have something extra on line 14 file_get_content(), this function will fetch and return all printing out functios (i.e echo, print, var_dum,

Well there is one easy way to so with PHP

  1. $content = http_build_query (array (  
  2. // this is where you list all data you want to post 
  3. 'key' => '123456789', 
  4. 'secret' => '13456abcdef' 
  5. )); 
  6.  
  7. $context = stream_context_create (array ( 
  8. 'http' => array ( 
  9. 'method' => 'POST', 
  10. 'content' => $content, 
  11. ) 
  12. )); 
  13.  
  14. $result = file_get_contents('http://localhost/poster.php', null, $context); 

the submission will just act the same way you submit the normal HTML form , but we have something extra on line 14 file_get_content(), this function will fetch and return all printing out functios (i.e echo, print, var_dum, print_r etc) to the current page.

Profile photo for Shemika Donalene

Sending data from PHP to HTML is a very common requirement in web development. Here are several common methods, combined with my experience to explain in detail the advantages, disadvantages, and usage scenarios of each method.

Firstly, you need to deploy the development environment through Servbay and install PHP with just one click. Then solve it through the following two methods

Method 1: Directly embed PHP code into HTML

This is the most common and simplest method, suitable for small projects or simple pages. You can directly embed PHP code in HTML to pass data to HTML.

Example code

<? php

//PHP

Sending data from PHP to HTML is a very common requirement in web development. Here are several common methods, combined with my experience to explain in detail the advantages, disadvantages, and usage scenarios of each method.

Firstly, you need to deploy the development environment through Servbay and install PHP with just one click. Then solve it through the following two methods

Method 1: Directly embed PHP code into HTML

This is the most common and simplest method, suitable for small projects or simple pages. You can directly embed PHP code in HTML to pass data to HTML.

Example code

<? php

//PHP section

$title="My Website";

Welcome to my website;

$items=["apples", "bananas", "oranges"];

?>

<! DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF-8">

<title><? php echo $title; ?></title>

</head>

<body>

<h1><? php echo $title; ?></h1>

<p><? php echo $description; ?></p>

<ul>

<? php foreach ($items as $item): ?>

<li><? php echo htmlspecialchars($item); ?></ li>

<? php endforeach; ?>

</ul>

</body>

</html>

Advantages and disadvantages

Advantages: Simple and direct, suitable for rapid development.

Disadvantages: Not suitable for large projects, poor code maintainability.

Method 2: Use Template Engine

For more complex projects, template engines such as Twig, Smarty, etc. can be used. These engines can help you better separate logic and display, improving code maintainability.

Example of using Twig

Install Twig:

composer require "twig/twig:^3.0"

Create PHP file and render template:

<? php

require_once 'vendor/autoload.php';

//Initialize Twig

$loader = new \Twig\Loader\FilesystemLoader('templates');

$twig = new \Twig\Environment($loader);

data

$title="My Website";

Welcome to my website;

$items=["apples", "bananas", "oranges"];

//Rendering Template

echo $twig->render('index.html.twig', [

'title' => $title,

'description' => $description,

'items' => $items

]);

Create template file index.html.twig:

<! DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF-8">

<title>{{ title }}</title>

</head>

<body>

<h1>{{ title }}</h1>

<p>{{ description }}</p>

<ul>

{% for item in items %}

<li>{{ item }}</li>

{% endfor %}

</ul>

</body>

</html>

Profile photo for Quora User

The browser makes a GET request to the address you set with action attribute.

The data is sent as a query string, which is basically a string of all data that is sent.

The query string looks something like this:

  1. ?name=Bojan&surname=Durmic&website=Quora 

It is added to the URL where the GET request is performed. As you can see, the data is sent in a key=value format.

The data is then available to the server, which can process the data, but it is not the scope of this question.

One more thing to add is, it is not recommended to send data using GET request. GET request is used for fetching data, and the

The browser makes a GET request to the address you set with action attribute.

The data is sent as a query string, which is basically a string of all data that is sent.

The query string looks something like this:

  1. ?name=Bojan&surname=Durmic&website=Quora 

It is added to the URL where the GET request is performed. As you can see, the data is sent in a key=value format.

The data is then available to the server, which can process the data, but it is not the scope of this question.

One more thing to add is, it is not recommended to send data using GET request. GET request is used for fetching data, and the data sent should only be related to the data you’re trying to fetch, such as page number or search query.

Using GET request to send passwords, credit card information and any kind of data you wouldn’t want to publicly post on your Facebook is extremely insecure. For submitting data, use POST.

Profile photo for Minato Uchiha

POST method is used to send some data to the server in form of body. The data can be in various different forms like JSON, plain-text, XML, image files, etc.

So, whenever we try to send something to server, maybe a form is filled and the data is to be sent, maybe a file is being uploaded, maybe new password needs to be set, so all these kind of stuff happens with POST request.

Profile photo for Terry Woods

The POST method is the technique that a form interacts with the server. There are two main methods to send form data, POST and GET, They work pretty much the same way but the POST method sends the form data inside the IP Packet where it is more secure.

The Get method send the data as a suffix to the URL and it is visible to the world.

HTTP Methods GET vs POST

Profile photo for Peter Mierau

So the PHP code works on your local development machine, but not when you upload it to a server? There could be lots of reasons, but here are some that come to mind:

  • There is some difference in the way that PHP on the server is configured. Write a little PHP script that does <?php phpinfo(); ?> and run it on both machines. Then compare the two.
  • There is some difference in the way the server is configured. For example, you might have MySQL on your development machine, but the server doesn’t.
  • There is some difference in require credentials. Using MySQL as an example again, perhaps your PHP code can

So the PHP code works on your local development machine, but not when you upload it to a server? There could be lots of reasons, but here are some that come to mind:

  • There is some difference in the way that PHP on the server is configured. Write a little PHP script that does <?php phpinfo(); ?> and run it on both machines. Then compare the two.
  • There is some difference in the way the server is configured. For example, you might have MySQL on your development machine, but the server doesn’t.
  • There is some difference in require credentials. Using MySQL as an example again, perhaps your PHP code can’t connect to the database because the credentials are wrong.
  • You are including some PHP file which is available on your local machine, but not on the server.
  • The PHP code on the server doesn’t have permissions to read or write to some file.
  • And so on…
Profile photo for Digital Pig, LLC

In your <form> action, use the “mailto:” protocol. When the form is submitted, the contents will be sent to whomever’s email address is after the mailto.

Example:

  1. <form method="POST" action="mailto:my-business-email@gmail.com"> 
  2. <div class="form-group"> 
  3. <label for="subject">Subject: </label> 
  4. <input id="subject" name="subject" class="form-control" /> 
  5. </div> 
  6. . 
  7. . 
  8. . 

…etc.

This is off the top of my head so play around with it, but this is how we used to do it 20+ years ago.

HTH

Profile photo for Lokesh Kumar

Web developers write HTML code by using an HTML editor. An HTML editor is a program that helps to create, edit, and debug HTML code. HTML editors typically have features such as syntax highlighting, auto-completion, and more to make coding easier and faster.

Popular HTML editors include Visual Studio Code, Atom, Sublime Text, and Notepad++.

Profile photo for Kousik Nandy

HTML is a markup language. It doesn't support a message transfer protocol. However you can embed javascript code to do it for you. As a reference, you can use XMPP for your message transfer protocol, and you can find node-xmpp or strophe or some other javascript implementation to embed in your HTML file.

Profile photo for Alexander Lehmann

you cannot as the browser does not have a mail send function

you can use mailto:address to open a mail window if the user has a client configured, but that will mean that they have to click send to actually send the mail

Profile photo for Tim Urista

HTTP server is a server that respects the HTTP client-server protocol. Meaning it its TCP connection where the client and server exchange the respective headers when connecting. See

An overview of HTTP - HTTP | MDN
HTTP is a protocol for fetching resources such as HTML documents. It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser. A complete document is typically constructed from resources such as text content, layout instructions, images, videos, scripts, and more.

for more details.

HTTP server is one of the most basic kinds of servers without the (s) at the end means it’s unencrypted 2 way traffic. Almost every page today makes use of the http connection.

For example on this very page you can see the request for javascript script file in this html script tag:
```
<script type="text/javascript" src="
https://qsbr.cf2.quoracdn.net/-4-ans_frontend

HTTP server is a server that respects the HTTP client-server protocol. Meaning it its TCP connection where the client and server exchange the respective headers when connecting. See

An overview of HTTP - HTTP | MDN
HTTP is a protocol for fetching resources such as HTML documents. It is the foundation of any data exchange on the Web and it is a client-server protocol, which means requests are initiated by the recipient, usually the Web browser. A complete document is typically constructed from resources such as text content, layout instructions, images, videos, scripts, and more.

for more details.

HTTP server is one of the most basic kinds of servers without the (s) at the end means it’s unencrypted 2 way traffic. Almost every page today makes use of the http connection.

For example on this very page you can see the request for javascript script file in this html script tag:
```
<script type="text/javascript" src="
https://qsbr.cf2.quoracdn.net/-4-ans_frontend-relay-27-329bee9737fd7179.webpack" async="1" onerror="addAssetErr(this.src)" id="entryjs"></script>
```

Above the browser will send a GET request to the https:// for the webpack resource.

How do you write a simple server for http?
There are many options, but the best is to use the language you are most comfortable in if you are starting out :). Python is great along with node and there are many tutorials on using an express server or flask with python to construct a simple server.

https://www.softwaretestinghelp.com/python-flask-tutorial/

If you install node > 14 on your machine you can make use of the npx node command which will download / run commands.

One of these super helpful commands is `npx serve .` which will serve the content in your current path just like a web server. It’s fast and I make use of it all the time to get a index.html file to load locally for me along with other resources.

Profile photo for Rajesh Chittampally

You can send it within a form by using hidden tag.

  1. <form action="submit.php"> 
  2. <input type="hidden" id="page-name" class="hidden" value="home.HTML" /> 
  3. <input type="text" id="normal-text" class="normal" /> 
  4. <input type=submit" value="Send" /> 
  5. </form> 

If you look at the code above, there is a hidden input type and a normal text input.

When a user look at this form, only the normal text input box and a Submit button will be visible.

But, when user will submit the form, then a user input text and a pre-filled hidden input will be sent to the server (here submit.php file), where you can perform l

You can send it within a form by using hidden tag.

  1. <form action="submit.php"> 
  2. <input type="hidden" id="page-name" class="hidden" value="home.HTML" /> 
  3. <input type="text" id="normal-text" class="normal" /> 
  4. <input type=submit" value="Send" /> 
  5. </form> 

If you look at the code above, there is a hidden input type and a normal text input.

When a user look at this form, only the normal text input box and a Submit button will be visible.

But, when user will submit the form, then a user input text and a pre-filled hidden input will be sent to the server (here submit.php file), where you can perform logic that is for home.HTML (or for a specific page only)

About · Careers · Privacy · Terms · Contact · Languages · Your Ad Choices · Press ·
© Quora, Inc. 2025