Forums
This topic is locked
simple poll
Posted 25 Oct 2007 19:12:03
1
has voted
25 Oct 2007 19:12:03 Karen Faris posted:
I am trying to create a simple poll for the web. I would like to create a photo album where users can vote for their favorite photo. I would like to allow only one answer and the results to go to an e-mail address. What is the easiest way. Replies
Replied 01 Nov 2007 20:32:13
01 Nov 2007 20:32:13 john newsome replied:
looks like you need some form of script to post the result to an email address look at php mail() function just create a form that when submited sends the result to an email basic exaple below if you need help let me know
<pre id=code><font face=courier size=2 id=code><?
if ($_POST[action]){
$to = "email address"
$subject = "poll result";
$msg = $_POST[result];
$headers = "from "
mail ($to,$subject,$msg.$headers);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Untitled Document</title>
<script language="javascript">
function show(divValue){
document.getElementById("picture".innerHTML = '<img src='+divValue+' />';
}
</script>
</head>
<body>
<form action="" method="post" name="theform">
<input type="hidden" name="action" value="1" />
<input type="radio" name="result" value="radio1" />
<br />
<input type="radio" name="result" value="radio2" />
<br />
<input type="submit" value="submit" />
</form>
</body>
</html> </font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code><?
if ($_POST[action]){
$to = "email address"
$subject = "poll result";
$msg = $_POST[result];
$headers = "from "
mail ($to,$subject,$msg.$headers);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Untitled Document</title>
<script language="javascript">
function show(divValue){
document.getElementById("picture".innerHTML = '<img src='+divValue+' />';
}
</script>
</head>
<body>
<form action="" method="post" name="theform">
<input type="hidden" name="action" value="1" />
<input type="radio" name="result" value="radio1" />
<br />
<input type="radio" name="result" value="radio2" />
<br />
<input type="submit" value="submit" />
</form>
</body>
</html> </font id=code></pre id=code>