Menu

Form Not posting Data

Help
Anonymous
2003-01-14
2003-01-14
  • Anonymous

    Anonymous - 2003-01-14

    Using your FormGen proggie, which by the way is great. I created a form and connection to MySql.

    The only thing is, I am doing multi-Pick Lists and can not get it to post the data (pick-list) arrays.

    (Data Form) /snipet
    <form enctype='multipart/form-data' action='process_1.php' method='post'>

    <select name="Offense[]" class="textfield" multiple size="5">
    <option value='Arguing with Admin'>Arguing with (AR)</option>
    <option value='Bug Exploit'>Bug Exploit (BE)</option>
    <option value='Banlist'>Banlist(BL)</option>

    <select name="Admin[]" class="textfield" multiple>
    <option value='Acedel'>Acedeal</option>
    <option value='Coby_Wan_Kenobi'>Coby_Wan_Kenobi</option>
    <option value='Bush_8'>Bush_8</option>

    (Form Processor)

    <?php

    include("admin/config.inc.php");

    $errors=0;
    $error="The following errors occured while processing your form input.<ul>";
    $_POST['Notes']=preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />",
    $_POST['Notes']);if($_POST['Username']==""
    || $_POST['Offense']=="" || $_POST['Admin']=="" ||
    $_POST['Date']=="" || $_POST['Time']=="" || $_POST['Server']=="" ||
    $_POST['Notes']=="" ){

    $errors=1;
    $error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
    }
    if($errors==1) echo $error;
    else
    {

    $Offense = $_POST["Offense"];
    if (is_array($Offense))
           {
      for ($i=0; $i<count($Offense); $i++) {
        $Offense .= $Offense[$i].", ";
      }
      $Offense = substr ($Offense, 0, strlen ($Offense)-2);
         }
    else
        {
      $Offense = "";
         }

    $Admin = $_POST["Admin"];
    if (is_array($Admin)) {
      for ($i=0; $i<count($Admin); $i++)
         {
        $Admin .= $Admin[$i].", ";
      }
      $Admin = substr ($Admin, 0, strlen ($Admin)-2);
      }
    else 
    {
      $Admin = "";
    }

    $Server = $_POST["Server"];
    if (is_array($Server))
    {
      for ($i=0; $i<count($Server); $i++)
    {
        $Server .= $Server[$i].", ";
      }
      $Server = substr ($Server, 0, strlen ($Server)-2);
    }
    else
    {
      $Server = "";
    }

    */
    //change $_POST to $_GET or $_SESSION or $ENV, etc. whichever array you need to view.
    echo "Values submitted via POST method:<br>";
    reset ($_POST);
    while (list ($key, $val) = each ($_POST)) {
        echo "$key => $val<br>";
    }
    /*

    $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$_SERVER['HTTP_HOST'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
    $message="Username: ".$_POST['Username']."
    Offense: $Offense
    Admin: $Admin
    Date: ".$_POST['Date']."
    Time: ".$_POST['Time']."
    Server: $Server
    Notes: ".$_POST['Notes']."
    ";

    $link = mysql_connect($hostname,$username, $password) or die("Connetion to database failed!");
    mysql_select_db($dbname);

    $query="insert into server_user_banlist (username,offense,admin,date,time,server,notes) values ('".$_POST['Username']."','$Offense','$Admin','".$_POST['Date']."','".$_POST['Time']."',
      '$Server','".$_POST['Notes']."')";
    mysql_query($query);
    header("Refresh: 0;form8.html");
    }
    ?>

    As you can see I muddled with your code a bit, trying to get it to post the arrays, but I can not seem to get it right.
    When I echo the array to the screen all it shows is
    Array = [Array] and not the choice.
    Also, when posting the the data, it will post the data as  arrayArguing with admin
    some reason it does not see that I have made multi-choice picks and it also wants to add the word array to the choice..

    THanks

     
    • Musawir Ali

      Musawir Ali - 2003-01-14

      Multiselect is not an option in the program. If you are adding it in your forms, then you should provide valid handling for it in the processor file. For now, I can only tell you that the multiselect sends data as an array, so you cannot just treat it as $some_variable, it should be $some_variable[i] ,
      If you still can't manage it, then wait for the next release and I will add multiselect option to it.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.