Fórum O PHP aceita arquivo externo do CSS?? #620391

11/08/2023

0

Comecei a estudar PHP recentemente, e tentei criar um pequeno projeto de cadastro, entretanto ao programar o CSS percebi que ele não estava editando o HTMl por conta do PHP.
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<html lang="pt-br">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/cadastro/index.css">
    <title>cadastrar</title>
</head>
<body>
    <h1>Cadastro</h1>
    <label>Nome: </label>
    <input type="text" name="nome" id="nome" placeholder="Nome Completo"><br><br>
    <label>E-mail: </label>
    <input type="email" name="email" id="email" placeholder="seu melhor email"><br><br>
    <label>Telefone: </label>
    <input type="number" name="tell" id="tell" placeholder="telefone com DDD"><br><br>
    <input type="submit" value="Cadastrar" name="CadUsu" class="BTN_cadastro">
 
</body>
</html>


index.css
1
2
3
4
5
6
7
8
.BTN_cadastro {
    background-color: blue;
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
}
Rhyan 05

Rhyan 05

Responder

Posts

11/08/2023

Rhyan 05

OBS: eu retirei a parte do php pois nao conseguia colocar aqui, mas ela esta funcionando
Responder

Gostei + 0

31/08/2023

Israel Ruiz

Olá

Não entendi qual exatamente foi o seu problema, independente de usar PHP ou outra linguagem o HTML sempre funcionará da mesma maneira, talvez a forma como estruturou se arquivo não esteja correta, por exemplo no código abaixo meu arquivo é .php e estou usando html para exibir um resultado na tela:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
if (file_exists('montaFunc.php')) {
    require('montaFunc.php');
}  
$dataHoje = dataDiaAnteriorHtml();
echo '
    <!doctype html>
    <html lang="pt-BR">
      <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
 
        <!-- Bootstrap CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
        <title>Acesso VPN</title>
      </head>
      <body>
        <div class="container">
            <form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'" name="formulario" method="post">
              <div class="form-group">
                <label for="dataInformada">Informe uma data</label>
                <input type="date" required="required" class="form-control"  value="';echo $dataHoje; echo '" id="dataInformada" name="dataInformada" aria-describedby="Informar uma data">
                <small id="dataInformada" class="form-text text-muted">Informe a data para pesquisa no calendário e utilize o ckecklist para ano ou mês</small>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="ano">
                    <label class="form-check-label" for="inlineRadio1">Ano</label>
                </div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="mes">
                    <label class="form-check-label" for="inlineRadio2">Mês</label>
                </div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" checked value="dia">
                    <label class="form-check-label" for="inlineRadio3">Dia</label>
                </div>
              </div>
              <button type="submit" class="btn btn-primary">Pesquisar</button>
            </form>';
    /* pegando o dia e mostrando na tabela*/
    if(!empty($_POST)){
        $tipo_pesquisa = $_POST['inlineRadioOptions'];//verificaTipo($_POST['inlineRadioOptions']);
        $dataEscolhida = $_POST['dataInformada']; // yyyy-mm-dd
        $diaEscolhido = substr($dataEscolhida, 8, 2);
        $mesEscolhido = substr($dataEscolhida, 5, 2);
        $anoEscolhido = substr($dataEscolhida, 0, 4);
        $nomeDoArquivo = $diaEscolhido.'-'.$mesEscolhido.'-'.$anoEscolhido;
 
        if ($tipo_pesquisa =='dia'){
            $titulo = ' do dia '.$nomeDoArquivo;
            //$caminho ='C:/xampp/htdocs/relatorioVPN/VPN-'.$anoEscolhido.'/'.$mesEscolhido.'/'.$nomeDoArquivo.'.html';
            $caminho ='/var/www/htdocs/relatorioVPN/VPN-'.$anoEscolhido.'/'.$mesEscolhido.'/'.$nomeDoArquivo.'.html';
        } elseif($tipo_pesquisa == 'mes') {
            //$caminho ='C:/xampp/htdocs/relatorioVPN/VPN-'.$anoEscolhido.'/'.$mesEscolhido.'.html';
            $caminho ='/var/www/htdocs/relatorioVPN/VPN-'.$anoEscolhido.'/'.$mesEscolhido.'.html';
            $titulo = ' do mês '.$mesEscolhido;
        } else {
            //$caminho ='C:/xampp/htdocs/relatorioVPN/VPN-'.$anoEscolhido.'/'.$anoEscolhido.'.html';
            $caminho ='/var/www/htdocs/relatorioVPN/VPN-'.$anoEscolhido.'/'.$anoEscolhido.'.html';
            $titulo = ' do ano '.$anoEscolhido;        
        }  
 
    } else {
        $caminho = '';
        $titulo ='';
    }      
 
echo '     
        </div>
        <h1 class="text-center">Relatório de acessos a VPN '. $titulo.'</h1>
        <table class="table table-striped">
          <thead class="thead-dark">
            <tr>
              <th scope="col">Nome</th>
              <th scope="col">IP</th>
              <th scope="col">Data inicial</th>
              <th scope="col">Data final</th>
              <th scope="col">Tempo total</th>
            </tr>
          </thead>
          <tbody>';
    if(!empty($_POST)){
        if (file_exists($caminho)) {
     
            //Se o arquivo existir podemos incluí-lo.
            include($caminho);
     
        }
        else {
            echo '<tr><td colspan ="5" class="alert alert-danger"  role="alert" scope="col"><div class="text-center">Não há registro a mostrar ou período não foi marcado corretamente</div></td></tr>';
        }  
    } else {
        echo '<tr><td colspan ="5" class="alert alert-danger" role="alert" scope="col"><div class="text-center">Não há registro a mostrar ou período não foi marcado corretamente</div></td></tr>';
    }  
 
echo '       
 
          </tbody>
        </table>
         
        <!-- Optional JavaScript -->
        <!-- jQuery first, then Popper.js, then Bootstrap JS -->
        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
      </body>
    </html>';
?>

Este código funciona perfeitamente bem e apresenta uma tela estilizada com css.
Ajudou?
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar