Can't figure out my problem...
Posted: Tue Oct 24, 2006 5:06 pm
Please look at the code below. It supposed to allow you to sign up for an item, and then your name will repost after you've signed up. It allows you to sign up, but it doesn't repost your name. Thank you for your help.
Here is the site
Here is the site
Code: Select all
<?php
$dbh=mysql_connect ("localhost", "dvdcreat_dev", "dev") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dvdcreat_unionsbcdevelopment");
#echo "you did it!!";
$types = array ("No Camera","With Camera");
$count = 8;
if ($_POST)
{
#print_r ($_POST);
$signeduptypes=array();
foreach($_POST as $name => $value)
{
if ($value)
{
$newname=explode("_",$name);
$newname=$newname [0];
$signeduptypes[]=$newname;
#echo "You signed up for $newname";
$sql="insert into signupnov(type,name) values('$newname','$value')";
mysql_query($sql);
}
}
if ($signeduptypes)$message="You signed up for ".implode(", ",$signeduptypes);
header("Location: ".$_SERVER["SCRIPT_NAME"]."?message=".urlencode($message));
}
$sql="select type, name from signupnov";
$result=mysql_query($sql);
#print_r($result);
while($savedresultsnov=mysql_fetch_array($result))
{
$signupsheetnov[$savedresultsnov[0]][]=$savedresultsnov[1];
}
$message=$_GET["message"];
#print_r($savedresultsnov);
#print_r ($signupsheetnov);
?>Code: Select all
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>the Union - Sign Up Sheet November</title>
</head>
<body bgcolor="#FFFFCD">
<form method="POST" action="<?=$PHP_SELF?>" name="Signupnov">
<h2><font face="Comic Sans MS"><?=$message?></font></h2>
<p><font face="Comic Sans MS" color="#FF9900">Please sign up for at least one of the following:</font></p>
<table border="0" style="border-collapse: collapse" cellpadding="10" width="509" id="table1">
<?php
foreach ($types as $number => $type)
{
if ($number % 2 == 0)
{
?>
<tr>
<?php
}
?>
<td style="vertical-align:top; text-align:right" width="100"><font face="Comic Sans MS" color="#FF9900"><?=$type?>:</font></td>
<td>
<?php
for ($i=0;$i<$count;++$i)
{
if ($signupsheetnov[$type][$i])
{
?>
<font face="Comic Sans MS"><?=$signupsheetnov[$type][$i]?></font><br>
<?php
}
else
{
$inputavailable=true;
?>
<font color="#FF9900">
<input type="text" name="<?=$type."_".$i?>"size="auto"></font><br>
<?php
}
}
?>
</td>
<?php
if ($number %2 != 0)
{
?>
</tr>
<?php
}
}
?>
</table>
<p><font face="Comic Sans MS" color="#FF9900">Thank you.</font></p>
<p>
<?php
if($inputavailable)
{
?>
<input type="submit" value="Submit"><input type="reset" value="Reset" name="B2">
<?php
}
?></p>
</form>
</body>
</html>