...

View Full Version : Forms



Jesuspwnt
12-27-2007, 04:05 PM
i have a general site config "module" in my admin panel that you can edit the main parts of the site, title etc..

But the code i have won't even post...

This is the main part of the code:

if(isset($POST['admin_config_save'])){
$flood_time = $_POST['Hours']."h:".$_POST['minutes']."m:".$_POST['seconds']."s";
$update = mysql_query("UPDATE `[db]`.`[column]` SET `name` = '{$_POST['name']}',`description` = '{$_POST['description']}',`keywords` = '{$_POST['keywords']}',`basedir` = '{$_POST['basedir']}',`shoutbox_flood_time` = '{$flood_time}',`footer` = '{$_POST['footer']}' WHERE `cc_config`.`id` =1 LIMIT 1 ;");
echo "<tr><td colspan=\"2\" align=\"center\">";
if($update){
echo "General Site Config Updated Successfully";
}else{
echo "General Site Config Could Not Be Updated";
}
echo "<hr width=\"100&#37;\" color=\"#00ff00\"><br /><br /></td></tr>\n";
}


$id = "1"; # this needs to be here to keep cfvalue from being an invalid mysql_fetch_array
$config_value = mysql_query("SELECT * FROM [column] WHERE id='{$id}' LIMIT 1;");
$cfvalue = mysql_fetch_array($config_value);

echo "<form method=\"post\">\n";
echo "<tr><Td> Website Name : </td><td><input type=\"text\" name=\"name\" value=\"".htmlentities($cfvalue['name'])."\"></td></tr>";
echo "<tr><Td> Description : </td><td><textarea name=\"description\">".htmlentities($cfvalue['description'])."</textarea></td></tr>";
echo "<tr><Td> Keywords : </td><td><input type=\"text\" name=\"keywords\" value=\"".htmlentities($cfvalue['keywords'])."\"><td></tr>";
echo "<tr><Td> Footer Text : </td><td><input type=\"text\" name=\"footer\" value=\"".htmlentities($cfvalue['footer'])."\"></td></tr>";
echo "<tr><Td> BaseDir </td><td><input type=\"text\" name=\"basedir\" value=\"".htmlentities($cfvalue['basedir'])."\"></td></tr>";
echo "<tr><Td> Shoutbox Flood Time : <br />(<small><i>Time between Shouts</i></small>) </td><td>";

$flood_time = mysql_result(mysql_query("SELECT shoutbox_flood_time FROM [column] WHERE id='1'"), 0);
$time = explode(":", $flood_time);
$h = str_replace("h", "", $time[0]);
$m = str_replace("m", "", $time[1]);
$s = str_replace("s", "", $time[2]);

echo "<Select name=\"Hours\">\n";
$i = 0;
while($i <= 24){
echo "<option";
if($h == $i){
echo " SELECTED ";
}
echo ">".$i."</option>\n";
$i++;
}
echo "</select> : ";

echo "<Select name=\"minutes\">\n";
$i = 0;
while($i <= 60){
echo "<option";
if($m == $i){
echo " SELECTED ";
}
echo ">".$i."</option>\n";
$i++;
}
echo "</select> : ";

echo "<Select name=\"seconds\">\n";
$i = 0;
while($i <= 60){
echo "<option";
if($s == $i){
echo " SELECTED ";
}
echo ">".$i."</option>\n";
$i++;
}
echo "</select>\n</td></tr>";

echo "<tr><Td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"admin_config_save\" value=\"Save!\"></form>";

abduraooft
12-27-2007, 04:10 PM
<form method=\"post\">
You missed the action= part.
Also it's a good practice to validate your html code taken from browser's view source option using w3validator (http://validator.w3.org)

Jesuspwnt
12-27-2007, 04:13 PM
lol! you don't NEED the action in order for it to work, none of the forms on my site have actions...

Inigoesdr
12-27-2007, 04:17 PM
You don't need it, but you should have it. What do you mean by "won't even post"? When you click submit the form doesn't submit, or the form submits and the data isn't updated?

Jesuspwnt
12-27-2007, 04:20 PM
Edit: Fixed.

missed the _ in $POST.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum