Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

305
Vistas
How do i connect PHP files to HTML?

Quick Note

I'm on a fair beginner's level of web development HTML, CSS, javascript ran locally. For this, I'm using Visual Studio Code.

To The Problem

Recently I've gotten to the part where I need web server functions and database control. For this, I decided to go with XAMPP & MySQL Community Server. There have been no issues with setting this up locally.

So when I started delving into PHP coding, it's fun and I've already created a couple of files and also managed to make the PHP files connect to my database.

HOWEVER I can't seem to find one obvious way to actually connect my ".php" files to my actual main document which is the HTML document.

I might have misunderstood how PHP actually works, though to make an example to my question;

Just like you have your HTML document separated from a CSS document, at least in VS Code, you establish a connection link rel="stylesheet" href="index.css" for example, for my reasons at least to make the workspace much cleaner than bombarding the HTML document with CSS.

How do I do this with PHP files? Cause whenever I run my PHP files as they are, they work as intended, but I can't find a way to actually bind/connect them to my HTML document.

I'd love some input or a proper answer to this, and I will gladly respond with the necessary information.

Cheers :)!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You will use html inside the php file. So instead of having an index.html, you will have an index.php file where you place all your html in there doctype, head, etc. And then inside the html you inject php code with <?php echo 'foo'; ?>

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <title></title>
  <base href="">
  <script src="script.js"></script>
  <link rel="stylesheet" href="style.css">
</head>
<body>

<h1>Some html text</h1>
<?php echo 'This is php code'; ?>

</body>
</html>
over 4 years ago · Santiago Trujillo Denunciar

0

HTML and Javascript is Client side and PHP is Server side.

That mean you have 2 possibilities:

  1. Send data from your HTML Site to your .php

  2. Receive Data from your .php in your HTML

For Begginers:

To send data to your .php use <form> Tag This allows you to send Data to your .php file

Example:

HTML Site:

<form action="yourphpfile.php" action='post'>

Firstname <input type=text id=firstname name=name> 

Lastname <input type=text id=lastname name=lastname> 

<button type=submit> Go! </button>

</form>

Your .php file

<?php

$firstname = $_POST['firstname'];
$lastname= $_POST['lastname'];

echo("<p>Welcome " . $firstname . " " . $lastname . " </p");
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda