update : You can understand my problem if you see my test link. http://smstostudents.com/rmk/index3.php (select any name and submit)
Here is my HTML form code
<input type="checkbox" name="student[]" value="1"><label>student name 1/label>
<input type="checkbox" name="student[]" value="2"><label>student name 2</label>
<input type="checkbox" name="student[]" value="3"><label>student name 3</label>
<textarea id="message" class="input" name="message" rows="7" cols="50">
Dear $studentname you have not paid the fees, please pay it as soon as possible.
</textarea><br />
The Php code is as follows.
<?php
$message = $_POST['message'];
$servername = "localhost";
$dbusername = "xxxxxx";
$dbpassword = "xxxxxxx";
$dbname = "xxxxxxxx";
foreach($_POST['student'] as $value)
{
// Create connection
$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$getID = mysqli_fetch_assoc(mysqli_query($conn, "SELECT firstname, email FROM Students WHERE id = $value"));
$studentname = $getID['firstname'];
$email = $getID['email'];
echo $message;
}
?>
What I am trying to achieve is, in the form text box "$studentname" will be replaced by student's name from the database. But echo $message doesn't display the students name, instead it just displays,
"Dear $studentname you have not paid the fees, please pay it as soon as possible."
how can I replace the "$studentname" by the Student's name. Sorry if it is easy, but I am stuck. Sorry, my English is bad, and I am a beginner in coding.
Update :
Actually i have no problem in the form. The form correctly posts the values to php. But, the textbox value contains "$studentname", which must be replaced with the student's name which is taken from the Database. But, the php code is not doing it, it is juts diplaying the textbox content as it is.
Thanks in advance.