take input data in php + phpmyadmin database

Asked

Viewed 722 times

-2

How to get these html input 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 connected 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 he has a radio input,...

  • To get the data from input in php has to be by attribute name. Ex.: $section2 = $_POST["Greeting"];

  • this error appears Parse error: syntax error, Unexpected '"' in line 61

  • In this line there is this excerpt : $input_registration "INSERT INTO Registration(Greeted)VALUE('$section2')";

  • Your code is a little fuzzy and with a lot of errors!

1 answer

0

you must use a magic variable from PHP itself, using the $_POST. But in each HTML "input", it has to 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 help you!

  • In parts yes. there are more than one inputs to answer several questions and this way it keeps marking more than one ...there are questions in section3 in section4...

  • in php I can get searching from class "section2" ?? that would already pick the inputs I marked for each type of question.. I can do so ?

  • If there is something like this I don’t know. What you have to do with each input is add the name attribute. And in PHP code, you’ll have to add more variables. Ex: $radio1 = $_POST['radio1']; | $Radio2 = $_POST['Radio2']; | $Radio3 = $_POST['Radio3']; | $radio4 = $_POST['radio4''];

  • Php guy I understood.. except that in html I change the name= "radio1" .. another input name = "Radio2" it will mark the two I want it to mark only one from 1 to 1 and not from 1 to N.. This in my html there are N’s inputs so I divided it into class in my html again

  • The attribute name has to be equal according to that Section,I think I have to take ,create a php variable with Section to access the inputs ???

  • Yes I understand. If in each question, you will have a radio button group

  • Let’s just say, you have the question, which is your favorite band? you will have a group with three radio button, these three radio button will receive in the attribute name, the same.

  • What’s your favorite band? <input type="radio" name="band-rock" value="Beatles"/>The Beatles <input type="radio" name="band-rock" value="led-Zeppelin"/> Led Zeppelin <input type="radio" name="band-rock" value="pink-Floyd"/>Pink Floy

Show 3 more comments

Browser other questions tagged

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