Hello I am newbie and I would like to ask how can I parse the value that the user makes from the radio button to database. I tried to do it but when I go to database I don't see the value, only the text on. What am I doing wrong? can you please help me? Any suggestions are welcome. I have this code:
<?php
/*
Template Name: Form
*/
?>
<?php global $pc_theme_object; /* Reference theme framework class */ ?>
<?php get_header(); ?>
<form action="" id="postjob" method="post">
<fieldset>
<legend>blalala;</legend>
<input type="hidden" name="question1" value="blalala;"/>
<div>
<input type="radio" id="Α. Ίδια" name="answer1" checked />
<label for="Α. Ίδια">Α. Ίδια</label>
</div>
<div>
<input type="radio" id="Β. Διαφορετικές" name="answer1" />
<label for="Β. Διαφορετικές">Β. Διαφορετικές</label>
</div>
<div>
<input type="radio" id="Γ. Δεν γνωρίζω" name="answer1" />
<label for="Γ. Δεν γνωρίζω">Γ. Δεν γνωρίζω</label>
</div>
</fieldset>
<fieldset>
<legend>rororor</legend>
<input type="hidden" name="question2" value="rororor"/>
<div>
<input type="radio" id="Α. Ναι" name="answer2" checked />
<label for="Α. Ναι">Α. Ναι</label>
</div>
<div>
<input type="radio" id="Β. Όχι" name="answer2" />
<label for="Β. Όχι">Β. Όχι</label>
</div>
<div>
<input type="radio" id="Γ. Δεν γνωρίζω" name="answer1" />
<label for="Γ. Δεν γνωρίζω">Γ. Δεν γνωρίζω</label>
</div>
</fieldset>
<button type="submit" name="submit">Submit</button>
</form>
<?php
$servername ="localhost";
$username = "username";
$password = "password";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $db_name);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$question1 = $_POST['question1'];
$answer1 = $_POST['answer1'];
$question2= $_POST['question2'];
$answer2 = $_POST['answer2'];
global $wpdb;
if(isset($_POST['submit'])){
$wpdb->insert( 'survey_test', array( 'question1' =>
$_POST['question1'], 'answer1' => $_POST['answer1'], 'question2' =>
$_POST['question2'], 'answer2' => $_POST['answer2'] ),
array( '%s', '%s', '%s', '%s' ) );
}
echo "Connected successfully";
?>
<?php get_footer(); ?>
</div>