Almost got it,
but when trying to post data from a form with mutli-picklists (pull downs)
It posts the the first pick, but adds the word array to it, as an example I have a pull down that has 15 items on it, you can select multi-item, but only the first choice is posted to the database and the word array is added, so it looks like:
arrayArguing with Admin
Also, the other pick lists, also add the word array to the choices.
Snipet of the Form
<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 Admin (AA)</option>
<option value='Bug Exploit'>Bug Exploit (BE)</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>
<option value='Mschadt'>MsChadt</option>
<input type=submit value='Send' >
Forms Proccessor
<?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)/"," <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 = "";
}
$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 (usernname,offense,admin,date,time,server,notes) values ('".$_POST['Username']."','$Offense','$Admin','".$_POST['Date']."','".$_POST['Time']."',
'$Server','".$_POST['Notes']."')";
mysql_query($query);
header("Refresh: 0;url=form8.html");
}
?>
I think I just about got it, but not sure if this is the correct way to do it, using an example, was not sure of if I needed to change all the words Offense to something different.
In this, should it refference Offense as the array and strings? (if that is the correct nomenclature)
$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 = "";
}
So it take Offense, and puts in the Actual Offense, is this the correct way to lay this out? And this little part will handel say 8 choices?
Somewhere doing something wrong, just do not know enough to figure it out yet..
Many Thanks again for putting up with one that is way lost
Regards
TB.