I am trying to update some placeholder text (not the placeholder attribute) with values that come from a form-input, that are all on the same HTML page. So I have one index.html file and one test.php file.
I am very new to PHP. I barely understand what it is and how it works. I couldn't find anything online specific to my issue.
I am using an Apache2 Server and PHP 7.2 installed on Linux Mint 19.1.
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel = "stylesheet" type = "text/css" href = "master.css">
<title>Home Page</title>
</head>
<body>
<div id = "center_text_box">
<p>URL:</p> <p><span>%PLACEHOLDER_URL%</span></p>
<p>URL Refresh Rate:</p><p><span>%PLACEHOLDER_URR%</span>(s)</p>
<p>Brightness:</p> <p><span><?php echo 'Brightness: '.$Brightness;?></span>(%)</p>
</div>
<form method="post" action="">
<input id="text-input" type="url" inputmode="url" placeholder="Enter URL" name="getURL" value="" title = "URL">
<input class="URR" id="text-input" inputmode="numeric"
title="Enter a Refresh Time(s) between 1 and 10"
type="text"
pattern="([0-9]{1,2})"
oninvalid="this.setCustomValidity('Please enter a number between 1 and 10')"
onchange="try{setCustomValidity('')}catch(e){}"
oninput="setCustomValidity(' ')"
maxlength="2"
placeholder="*Enter URL Refresh Time (s)" name="getRefreshRate" value="">
<input class="Brightness" id="text-input" inputmode="numeric" type="text" maxlength="2" pattern="([0-9]{1,2})"
oninvalid="this.setCustomValidity('Please enter a number between 2 and 99')"
onchange="try{setCustomValidity('')}catch(e){}"
oninput="setCustomValidity(' ')"
placeholder="*Enter Brightness (2-99)" name="getBrightness" value="" title="Enter a Brightness value between 2 and 99">
<input id="button" type="submit" name="save_values" value="Save Values">
</form>
</body>
</html>
<?php
// Check if the form is submitted
if ( isset( $_POST['save_values'] ) ) { // retrieve the form data by using the element's name attributes value as key
$Brightness = $_POST['getBrightness'];
$RefreshRate = $_POST['getRefreshRate'];
$message = "Success ! You have entered Brightness: ".$Brightness." and RefreshRate: ".$RefreshRate;
exit;
}
?>
I would like for %PLACEHOLDER_URR%
to update whenever I input a value using <input class="URR" name="getRefreshRate" value="">
.
As you can see with Brightness
I've tried replacing
<span>%PLACEHOLDER_Brightness%</span>
with
<span><?php echo 'Brightness: '.$Brightness;?></span>
but it did not work.
What can I do ?