-2
REPHRASED THE QUESTION!
I would like the help of you, how to create a button, to copy the result of the function echo
from PHP. For example:
Code in PHP
echo "Nome: " . $row_usuario['nome'] . "<br>";
Show this to the user:
Nome: siclano da silva
How to create this button in HTML (it can be otherwise) to copy the output result of the function echo
from the browser screen, where this copy will be to clipboard, as if it were CTRL + C / CTRL + V?
improving my question, this one is code in question.
<label>Nome: </label>
<input type="text" name="nome" placeholder="Digite aqui"><br><br>
<input name="SendPesqUser" type="submit" value="Pesquisar">
</center>
</form><br><br>
<form>
<center>
<div>
<input type="button" value="cadastra novo solicitante de crédito consignado" onClick="Nova()">
</div>
<div>
<input type="button" value="Consultar crédito" onClick="Novo2()">
</div>
<div>
<input type="button" value="Página Inicial" onClick="NovoInicial()">
</div>
</center>
</form>
<?php
$SendPesqUser = filter_input(INPUT_POST, 'SendPesqUser', FILTER_SANITIZE_STRING);
if($SendPesqUser){
$nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_STRING);
$result_usuario = "SELECT * FROM fornecedores WHERE nome LIKE '%$nome%'";
$resultado_usuario = mysqli_query($con, $result_usuario);
while ($row_usuario = $resultado_usuario->fetch_assoc()) {
echo "Nome: " . $row_usuario['nome'] . "<br>";
echo "Endereço: " . $row_usuario['endereco'] . "<br>";
echo "Cep: " . $row_usuario['cep'] . "<br>";
echo "E-mail: " . $row_usuario['email'] . "<br>";
echo "Celular: " . $row_usuario['celular'] . "<br>";
echo "Valor do crédito: " . $row_usuario['valor'] . "<br>";
echo "Id: " . $row_usuario['id'] . "<br>";
echo "<a href='edit_usuario.php?id=" . $row_usuario['id'] . "'>Editar</a><br>";
echo "<a href='proc_apagar_usuario.php?id=" . $row_usuario['id'] . "'>Apagar</a><br><hr>";
}
}
?>
</body>
</html>
The result would be that as per the image of the link above, the person would do a search by database, then the result that appeared on the screen, would like it to be copied via Clipboard by a button, because the intention is for the person to copy this data and then to post in Whatsapp.
BS: I am a beginner in the field of programming, I apologize for not knowing yet how to express myself properly with my doubts, I deeply thank you for your help.
my level of knowledge is a lot of effort in wanting to learn and many things I may not yet understand.
In short, do you want when you click a button, run a PHP code and the return of that PHP code go to the user’s clipboard? Your question got a little confused
– Rafael Tavares
From what I understand he wants to click on a button to execute a javascript code that copies the content of some html element to clipboard.
– Danizavtz