get input data in php + phpmyadmin bank

-2

How to get these input from the html by going to the phpmyadmin database Html

class="section2"  

 input type="radio"name="CumprimentoParada"id"A"value="CumprimentoParada"/>

 input type="radio"name="CumprimentoParada" id=B"value="CumprimentoParada"/>

My php ...

 $section2 =  $_POST["section2"];

My connection bank

$servidor = "localhost";
$user = "root";
$pass = "root";
$banco = "cadastro";
//criar conexao
$conn = mysql_connect($servidor,$user,$pass)or die(mysql_error());
;
mysql_select_db($banco)or die (mysql_error());

 $inserindo_cadastro "INSERT INTO cadastro($section2)VALUE('CumprimentoParada')";

 $resultado_cadastro    $sql = mysql_query($conn,$result_cadastro);

   echo ("Respondido com sucesso!");

In this form it has a series of input radios, I would like to know if to be sure to call php and setup with the bank ...

    
asked by anonymous 30.05.2016 / 23:32

1 answer

0

You should use a magic variable from PHP itself, use $ _POST . But in every "input" of HTML, it must have the attribute "name".

HTML

<div class="section2">
   <input type="radio" name="radio1" id="radio1" value="Algo..."/>
   <input type="radio" name="radio2" id="radio2" value="Algo..."/>
</div>

PHP

<?php
 $servidor = "localhost";
 $user = "root";
 $pass = "root";
 $banco = "cadastro";
 //criar conexao
 $conn = mysql_connect($servidor,$user,$pass) or die(mysql_error());

 mysql_select_db($banco)or die (mysql_error());

 $radio1 = $_POST['radio1'];
 $radio2 = $_POST['radio2'];

 $sql =  "INSERT INTO cadastro(nome_da_coluna_1, nome_da_coluna_2) VALUE ($radio1)";

 $resultado_cadastro  = mysql_query($conn, $sql);
    echo ("Respondido com sucesso!");
?>

I hope I can help you!

    
31.05.2016 / 00:57