Jump to content

Generate Html Page from Php User Input


webdevdea

Recommended Posts

I cannot understand why my background color is not changing when user selects it ?http://dandewebwonders.com/aliendata/response.php?username=Deanna&background=yellow&submit=Submit+Query

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body { background-color: <?= $_GET['color'] ?>; }
</style>
</head>

<body>
Hello, <?= $_GET['username'] ?>!
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">
option.red { background-color: red; }
option.yellow { background-color: yellow; }
option.blue { background-color: blue; }
option.orange { background-color: #FF8040; }
option.purple { background-color: #800080; }
</style>
</head>

<body>
<form action="response.php" method="get">
	What is your name?
	<input type="text" name="username" size="20" />
	<select name="background">
		<option style="display:none;" selected="selected">color</option>
		<option class="red" value="red">Red</option>
		<option class="yellow" value="yellow">Yellow</option>
		<option class="blue" value="blue">Blue</option>
		<option class="orange" value="orange">Orange</option>
		<option class="purple" value="purple">Purple</option>
	</select>
	<input type="submit" name="submit" />
</form>
</body>
</html>
Link to comment
https://forums.phpfreaks.com/topic/286358-generate-html-page-from-php-user-input/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.