OneCompiler

Web_Preferences

103

Fristpage.html

<!DOCTYPEhtml> <html> <head> <title>Changepreferences</title> </head> <body> <h1>Changepreferences</h1> <formaction=”secondpage.php”method=”post”> <labelfor=”fontstyle”>FontStyle:</label> <selectname=”fontstyle”id=”fontstyle”> <optionvalue=”Arial”>Arial</option> <optionvalue=”TimesNewRoman”>TimesNewRoman</option> <optionvalue=”Verdana”>Verdana</option> </select><br><br> <labelfor=”fontsize”>FontSize:</label> <selectname=”fontsize”id=”fontsize”>

<optionvalue=”12”>12</option>
<optionvalue=”14”>14</option>
<optionvalue=”16”>16</option>
</select><br><br>
<labelfor=”fontcolor”>FontColor:</label>
<inputtype=”color”name=”fontcolor”id=”fontcolor”><br><br>
<labelfor=”bgcolor”>BackgroundColor:</label>
<inputtype=”color”name=”bgcolor”id=”bgcolor”><br><br>
<inputtype=”submit”name=”submit”value=”Save”>

</form> </body> </html>

Secondpage.php

<?php If(isset($_POST[‘submit’])){ $fontstyle=$_POST[‘fontstyle’]; $fontsize=$_POST[‘fontsize’]; $fontcolor=$_POST[‘fontcolor’]; $bgcolor=$_POST[‘bgcolor’]; //Setthecookievalues Setcookie(‘fontstyle’,$fontstyle,time()+86400); Setcookie(‘fontsize’,$fontsize,time()+86400); Setcookie(‘fontcolor’,$fontcolor,time()+86400); Setcookie(‘bgcolor’,$bgcolor,time()+86400); //Redirecttothenextpage Header(‘Location:thirdpage.php’); Exit(); } ?>

Thirdpage.php

<?php //Retrievethecookievalues $fontstyle=isset($_COOKIE[‘fontstyle’])?$_COOKIE[‘fontstyle’]:‘Arial’; $fontsize=isset($_COOKIE[‘fontsize’])?$_COOKIE[‘fontsize’]:‘12’; $fontcolor=isset($_COOKIE[‘fontcolor’])?$_COOKIE[‘fontcolor’]:‘#000000’; $bgcolor=isset($_COOKIE[‘bgcolor’])?$_COOKIE[‘bgcolor’]:‘#FFFFFF’; ?><!DOCTYPEhtml><html> <head> <title>Pagewithnewsettings</title> <styletype=”text/css”> Body{ Font-family:<?phpecho$fontstyle?>; Font-size:<?phpecho$fontsize?>px; Color:<?phpecho$fontcolor?>; Background-color:<?phpecho$bgcolor?>; } </style> </head><body><h1>Pagewithnewsettings</h1> <p>Thisisthepagewiththenewsettings.Thefontstyleis<?phpecho$fontstyle?>,the fontsizeis<?phpecho$fontsize?>px,thefontcoloris<?phpecho$fontcolor?>,andthe backgroundcoloris<?phpecho$bgcolor?>.</p> </body> </html>