Post request using Curl

Asked

Viewed 485 times

0

How do I request, after clicking a button, used Curl?

<html>
	<head>
		<title>loja</title>
		<link rel="stylesheet" type="text/css" href="public/css/template.css" />
	</head>
	<body>
		<div class="topo">
		<div class="login">
			<form method="POST" action="requisicaoCurl.php" name="login">
				<input class="btn" type="text" placeholder="Usuário" name="usuario">
				<input class="btn" type="password" placeholder="Senha" name="senha">
				<button type="button" id="btn_entrar">Entrar</button>
			</form>
		</div>
		</div>
	</body>
</html>

need only, after click enter make a post request and return.

  • to using Laravel, in case but n need to authenticate with token, is only a request

1 answer

-1

requisicaoCurl.php

<?php
    //RECEBENDOOS VALORES dos campos usuario e senha, e armazenando em variaveis, $user $password
    $user=$_POST['usuario'];
    $password=$_POST['senha'];
    //EXIBIR OS VALORES DO FORMULARIO  acima da pagina que vai ser carregada.
    echo 'Valor digitado no campo name="usuario" :'.$user;
    echo 'Valor digitado no campo name="senha" :'.$password;
    //CARREGAR A PAGINA REQUISITADA, USANDO www.google.com como exemplo.
    $ch = curl_init('www.google.com');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    //EXIBINDO A PAGINA
    curl_exec($ch);
    // COMPLETANDO REQUISIÇÃO
    curl_close($ch);
    echo '1º - ALORES DO CAMPOS CAMPOS FORAM EXIBIDOS<br>
    2º - a pagina foi carregada<br>
    3º - a pagina foi exibida.<br>
    4º - exbi essa mensagem<br>
    ';
?>
  • after editing what I proposed in the form, creating the file: requisicaoCurl.php, your form is ready to be processed and call a page via Curl. Now you suit your interests the php code. If the answer satisfies your needs, mark the answer as accepted.

  • Solved your problem ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.