Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Forms

  1. #1
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Forms

    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:
    PHP 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%\" 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>"

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    <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
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    lol! you don't NEED the action in order for it to work, none of the forms on my site have actions...

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    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?

  • #5
    New Coder
    Join Date
    Nov 2007
    Location
    Kent, United Kingdom
    Posts
    67
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Edit: Fixed.

    missed the _ in $POST.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •