In: Computer Science
Hi, I am trying to write a php file which control the text size,
color and the parameters of a registration page. My code is not
working, the registration page always stay in the default
color.
Could I get some help ? My code is below.
display file
<?php session_start() ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>User display window</title>
<style>
.center { text-align:center}
</style>
</head>
<body>
<fieldset>
<legend class="center">Text
editing control </legend>
<form
class="center" name="session_editing" action="process.php"
method="post">
<label for="style">Select a control to
style </style></br>
<select
class="form_control" name="controlF" required>
<option
value="backG">Background </option>
<option
value="logIn">Login button</option>
<option
value="inputText">Input text </option>
</select></br></br>
<label for="font_size">Select the font
size</label></br>
<input
class="form_control" type="range" name="fontS" min="6" max="42"
required></br></br>
<label for="color_pick">Select the
color</label></br>
<input
class="form_control" type="color" name="color"
required></br></br>
<label for="visibility">
<input type="checkbox"
name="visible">Select the
visibility</label></br></br>
<input type="submit"
value="Submit">
</form>
</fieldset>
</body>
</html>
process file...
<?php
session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<style
type="text/css">
<?php if
(isset($_POST['controlF']) && isset($_POST['fontS'])
&& isset($_POST['color'])) {
$controlT=$_POST['controlF'];
$_SESSION["fontControl"]=$_POST['fontS'];
$_SESSION["colorControl"]=$_POST['color'];
if (!isset($_POST['visible']))
{
$_SESSION["elemVisible"]='none';
} } ?>
body {
text-align: center;
<?php
if
($controlT == 'backG') { ?>
background: <?php echo
$_SESSION["colorControl"]; ?>
font-size: <?php echo
$_SESSION["fontControl"].'px'; ?>
<?php
}else { ?>
background: #ffffff;
<?php }
?>
}
.text {
<?php
if
($controlT == 'inputText') { ?>
color: <?php echo $_SESSION["colorControl"];
?>
font-size: <?php echo
$_SESSION["fontControl"].'px'; ?>
<?php if ($_SESSION["elemtVisible"] ==
'none') {
echo 'display: none;';
} else { ?>
color: #000000;
<?php }
} ?>
}
.login {
<?php
if
($controlT == 'logIn') { ?>
background-color: <?php echo
$_SESSION["colorControl"]; ?>
font-size: <?php echo
$_SESSION["fontControl"].'px'; ?>
<?php if ($_SESSION["elemtVisible"] ==
'none') {
echo 'display: none;';
} }
?>
}
</style>
</head>
<body>
<?php echo
$controlT; ?>
<h1
class="text"> Sign In</h1> </br></br>
<label
class="text"> Username </label></br>
<input
name="client_username" size="25" placeholder="Username..."
/></label></br></br>
<label class="text">Password </br>
<label>
<input
name="client_password" type="password" id="client_password"
placeholder="********" /></br></br>
<input
class="login" type="submit" value="Log In" />
</body>
</html>
Thank you!!
I have rectified the problem its working
process.php
<?php
session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
<?php if
(isset($_POST['controlF']) && isset($_POST['fontS'])
&& isset($_POST['color'])) {
$controlT=$_POST['controlF'];
$_SESSION["fontControl"]=$_POST['fontS'];
$_SESSION["colorControl"]=$_POST['color'];
if (!isset($_POST['visible']))
{
$_SESSION["elemVisible"]='none';
} } ?>
body {
text-align: center;
<?php
if ($controlT == 'backG') { ?>
background: <?php echo $_SESSION["colorControl"]; ?>;
font-size: <?php echo $_SESSION["fontControl"].'px';
?>;
<?php }else { ?>
background: #ffffff;
<?php } ?>
}
.text {
<?php
if ($controlT == 'inputText') { ?>
color: <?php echo $_SESSION["colorControl"]; ?>;
font-size: <?php echo $_SESSION["fontControl"].'px';
?>;
<?php if ($_SESSION["elemtVisible"] == 'none') {
echo 'display: none;';
} else { ?>
color: #000000;
<?php } } ?>
}
.login {
<?php
if ($controlT == 'logIn') { ?>
background-color: <?php
echo$_SESSION["colorControl"];?>;
font-size: <?php echo $_SESSION["fontControl"].'px';
?>;
<?php if ($_SESSION["elemtVisible"] == 'none') {
echo 'display: none;';
} } ?>
}
</style>
</head>
<body>
<?php echo $controlT ?>
<h1
class="text"> Sign In</h1> </br></br>
<label class="text"> Username </label></br>
<input name="client_username" size="25"
placeholder="Username..."
/></label></br></br>
<label class="text">Password </br> <label>
<input name="client_password" type="password"
id="client_password" placeholder="********"
/></br></br>
<input class="login" type="submit" value="Log In" />
</body>
</html>
Output