A
A
Anton2021-03-27 12:39:53
PHP
Anton, 2021-03-27 12:39:53

Getting the selected radio item and passing it to the email body, how to display the selected item?

Hello.
I made a form, from the form I pass through the action to the php handler to send a letter to the mail.
Normal fields without problems I can give.

There are items that you need to select by marking, and this is radio.
How do I pass the selected item in the message of the letter.

There are 3 possible options.

<input type="radio" name="radio" id="radio1" value="Deck Officer" checked="checked">
<label for="radio1">Deck Officer</label>

<input type="radio" name="radio" id="radio2" value="Engine Officer">
<label for="radio2">Engine Officer</label>

<input type="radio" name="radio" id="radio3" value="Rating">
<label for="radio3">Rating</label>


So I send to php, or rather I receive there
$radio1 = Arr::get($_POST, 'radio1');
      $radio2 = Arr::get($_POST, 'radio2');
      $radio3 = Arr::get($_POST, 'radio3');


I pass to php all the id that I write in the message (but in this way all the options will be visible in the letter, or rather the headers, as I understand it, and only the one that was chosen, but how to display only the one that was chosen), and hide the rest.
$message = '<h2>Анкета с сайта</h2>'. '<br/><br/>'
. ' <b>Main info</b><br/>'
. ' <b>Deck Officer</b>: ' . htmlspecialchars($radio1). '<br/>'
. ' <b>Engine Officer</b>: ' . htmlspecialchars($radio2). '<br/>'
. ' <b>Rating</b>: ' . htmlspecialchars($radio3). '<br/>'
;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tester_toster, 2018-03-27
@tester_toster

"SELECT COUNT(id) as count FROM users WHERE email = ? LIMIT 0,1"

Get a string, use fetch to see the value of count

C
coderisimo, 2018-03-27
@coderisimo

$mysqli = new mysqli(SERVER, DBUSER, DBPASS, DATABASE);
$result = $mysqli->query("SELECT `id` FROM `users` WHERE `email` = '$email' ");
if($result->num_rows == 0) {
     // НЕТУ.
} else {
    // ЕСТЬ.
}
$mysqli->close();

add your email directly to the request. maybe the data just doesn't get there. In one place you have $email , in another $email_1. What is the exact name of the variable? In general, write directly in the script. if everything works, then it's clear where the error is)))
good luck

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question