close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multi select

Thread began 3/29/2013 1:53 am by chris250441 | Last modified 3/29/2013 11:29 am by Jason Byrnes | 1089 views | 7 replies |

chris250441

Multi select

Hi there,
I have a multi select box in my contact form which also inserts the form into a database and sends an email. All is functioning perfectly except the multi select as nothing is posted for this field.

I have inserted the following code at line 1:

<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
foreach($_POST as $key => $val) {
if(is_array($_POST[$key])) $_POST[$key] = implode(", ", $_POST[$key]);
}
}
?>

and have added [] to the name of the multi select.

I can't seem to get it to work and would greatly appreciate someone guiding me through this to find a solution.

The code for the multi select is as follows:

<select name="Product_Group[]" size="10" multiple="multiple" class="formListfield_Medium" id="Product_Group" tabindex="15" style="width:250px; height:150px;">
<option value="" <?php if (!(strcmp("", (isset($_GET["invalid"])?ValidatedField("CONTACTFORMNEW","Product_Group"):"")))) {echo "selected=\"selected\"";} ?>>Please select</option>
<option value="Other" <?php if (!(strcmp("Other", (isset($_GET["invalid"])?ValidatedField("CONTACTFORMNEW","Product_Group"):"")))) {echo "selected=\"selected\"";} ?>>Other</option>
<?php
do {
?>
<option value="<?php echo $row_rsProdCat['Name']?>"<?php if (!(strcmp($row_rsProdCat['Name'], (isset($_GET["invalid"])?ValidatedField("CONTACTFORMNEW","Product_Group"):"")))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsProdCat['Name']?></option>
<?php
} while ($row_rsProdCat = mysql_fetch_assoc($rsProdCat));
$rows = mysql_num_rows($rsProdCat);
if($rows > 0) {
mysql_data_seek($rsProdCat, 0);
$row_rsProdCat = mysql_fetch_assoc($rsProdCat);
}
?>
</select>

Incidentally, the form is a plugin using the latest Framework. Do I need to change the form action as for some reason it is not seeing the thank you page even when I put the full URL





Many thanks

Sign in to reply to this post

Jason ByrnesWebAssist

Please send a copy of the page so I can see the code in context. you can compress the php page to a zip archive and attach the zip file to your reply.

Sign in to reply to this post

chris250441

Thank Jason, see attached

Sign in to reply to this post

Jason ByrnesWebAssist

change line 88:

php:
GetSQLValueString($_POST['Product_Group[]'], "text"),




to:

php:
GetSQLValueString($_POST['Product_Group'], "text"),
Sign in to reply to this post

chris250441

Jason, I would have spent a lifetime trying to find that one - so many thanks.

I have just tested it and it is posting okay to the database but does not send the selection in the email. Would you mind taking a look at that too please - thanks!!

It is not going to the $GoToPage either. Any idea why? It is a plugin.

Sign in to reply to this post

Jason ByrnesWebAssist

change the go to page:
$GoToPage = "http://bamr.co.za/thank-you.php";

to:
$GoToPage = "/thank-you.php";



to troubleshoot the email body, send a copy of the webassist/email/ folder

Sign in to reply to this post

chris250441

Thanks Jason, here it is:

Sign in to reply to this post

Jason ByrnesWebAssist

in the webassist/email/waue_CONTACT-FORM-NEW_1.php file, change line 140:


php:
$MailBody = $MailBody .  ((isset($_POST["Product_Group"]))?implode(",",$_POST["Product_Group"]):"");




to:

php:
$MailBody = $MailBody .  ((isset($_POST["Product_Group"]))?$_POST["Product_Group"]:"");





there is no need to use implode there, you already have code to implode the form element at line 1 of the contact form page.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...