Jump to content

Generate Html Page from Php User Input


webdevdea
Go to solution Solved by 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>
Edited by webdevdea
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.