Jump to content

Archived

This topic is now archived and is closed to further replies.

danbluenun

Problem with a jump menu

Recommended Posts

Hi.

I am currently attemting to update a website that someone else has created.

On it, there is a form where the user can leave his/her details.

This data is emailed to my client and the user is sent to a "Thank You" page.

Part of the update is to add a drop-down menu onto the form where the user can tell my client how they heard about his company.

This is where I'm stuck. For some reason, the information is not being sent along with the rest of the data from the form. The resulting email reads as follows:

[color=blue] Company name : whatever compant
Company location : whatever location
Contact name : whatever name

email : customer@domain.net
Telephone no. : 071709859382310

Enquiry : blah, blah, blah
Found us by : [/color]




The code for the form is as follows (with the jump-menu at the bottom in red):

[color=blue]<form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST">
                    <span class="sitetext">
                    <?php
if (count($errors) > 0)
echo '<span class="errortext">Please correct the errors in the form and try again.</span><BR><BR>';
?>
                    </span>
                    <table border="0" cellspacing="4" cellpadding="0">
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Company name :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="company_name" type="text" id="company_name" size="30" value="<?= htmlentities($values['company_name']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['company_name'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Company location :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="company_location" type="text" id="company_location" size="30" value="<?= htmlentities($values['company_location']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['company_location'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Contact name :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="contact_name" type="text" id="contact_name" size="30" value="<?= htmlentities($values['contact_name']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['contact_name'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold"> email address :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="email" type="text" id="email" size="30" value="<?= htmlentities($values['email']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['email'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Telephone number :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="phone_no" type="text" id="phone_no" size="30" value="<?= htmlentities($values['phone_no']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['phone_no'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="sitetextbold">Your enquiry :</td>
                        <td align="left" valign="top" class="sitetext">
                          <textarea name="enquiry" cols="28" rows="8" id="enquiry"><?= htmlentities($values['enquiry']) ?></textarea>
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['enquiry'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td class="sitetext">
                          <p>&nbsp;
  [color=red]<select name="select" onChange="MM_jumpMenu('parent',this,0)" >
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Recommendation</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Search
                                              Engine</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Flyer</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Total
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">What
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Computer
                                              Weekly</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Other</option>
                                            </select>[/color]  
  </p>
                                <p>
                                  <input class="sitetext"type="submit" name="Submit" value="Submit">
                                </p></td>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                  </form>[/color]


The data is then sent to my clients email using the following code:

[color=blue]<?php
}

function ProcessForm($values)
{

$msg = "Company name : " . $values['company_name'] ."\n";
$msg .= "Company location : " . $values['company_location'] ."\n";
$msg .= "Contact name : " . $values['contact_name'] ."\n\n";
$msg .= "email : " . $values['email'] ."\n";
$msg .= "Telephone no. : " . $values['phone_no'] ."\n\n";
$msg .= "Enquiry : " . $values['enquiry'] ."\n";
$msg .= "Found us by : " . $values['found_us_by'] ."\n";

mail('dan@dearne.net', 'XS Form Submission', stripslashes($msg), "From: \"{$values['contact_name']}\" <{$values['email']}>");

header( "Location: thank_you.htm" );
}[/color]




Thanks is advance  ???

Share this post


Link to post
Share on other sites
Does it by any chance work if you select Recommendation but not the rest?

Regards
Huggie

Share this post


Link to post
Share on other sites
Afraid not.

Oops! I've just spotted what you noticed and ammended it. Still no luck.

I still get nothing after "Found us by:"


Thanks,

Dan

Share this post


Link to post
Share on other sites
ok, I think I'm missing something here....

Why are you using a jump menu for that option list?  I'm a little out of touch with HTML, but aren't jump menus, designed to move to another section of page/another page all together when you select the value?

Regards
Huggie

Share this post


Link to post
Share on other sites
Yes it is. Clearly, that's not what I need.

I've now changed it to:

[color=blue]<select name="select" >
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Recommendation</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Search
                                              Engine</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Flyer</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Total
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">What
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Computer
                                              Weekly</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Other</option>
                                            </select>[/color]


Still not getting anyhting after "Found us by" though.

Cheers. 

Share this post


Link to post
Share on other sites
I know what it is!...

Look at the name of your select box.  It's called 'select' not 'found_us_by'

Regards
Huggie

Share this post


Link to post
Share on other sites
Right, Huggie. I've just changed it to:

[color=blue]<select name="found_us_by" >
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Recommendation</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Search
                                              Engine</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Flyer</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Total
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">What
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Computer
                                              Weekly</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Other</option>
                                            </select>
[/color]  

Still no luck with it.

thanks,

Dan

Share this post


Link to post
Share on other sites
You need to change the php code too, but because I can't see all of that, I can't tell you what to change.

Are you able to post the php code that deals with the values once it's submitted?

Regards
Huggie

Share this post


Link to post
Share on other sites
Do you mean this?:

[color=blue]<?php
}

function ProcessForm($values)
{

$msg = "Company name : " . $values['company_name'] ."\n";     
$msg .= "Company location : " . $values['company_location'] ."\n";
$msg .= "Contact name : " . $values['contact_name'] ."\n\n";           
$msg .= "email : " . $values['email'] ."\n";         
$msg .= "Telephone no. : " . $values['phone_no'] ."\n\n";               
$msg .= "Enquiry : " . $values['enquiry'] ."\n";     
$msg .= "Found us by : " . $values['found_us_by'] ."\n";

mail('dan@domain.net', 'XS Form Submission', stripslashes($msg), "From: \"{$values['contact_name']}\" <{$values['email']}>");

header( "Location: thank_you.htm" );
}[/color]

Cheers,

Dan

Share this post


Link to post
Share on other sites
There's also the following that goes below that, but i'm not sure if it's relevant:


[color=blue]if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$formValues = $_POST;
$formErrors = array();

if (!VerifyForm($formValues, $formErrors))
DisplayForm($formValues, $formErrors);
else
ProcessForm($formValues);
}
else
DisplayForm(null, null);[/color]


Plus, at the top of the page - as the form is posted to self:

[color=blue]<?php

function outputOptionList(&$list, $selected)
{
foreach ($list as $item)
echo "<option value=\"{$item['Value']}\"" . ($item['Value'] === $selected ? " selected=\"selected\"" : '') . ">{$item['Text']}</option>\n";
}

function VerifyForm(&$values, &$errors)
{
//form validation
if (strlen($values['company_name']) == 0)
$errors['company_name'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['company_location']) == 0)
$errors['company_location'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['contact_name']) == 0)
$errors['contact_name'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (!ereg('.+@.+\..+', $values['email']))
$errors['email'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (!is_numeric($values['phone_no']))
$errors['phone_no'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['phone_no']) == 0)
$errors['phone_no'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['enquiry']) == 0)
$errors['enquiry'] = '<img src="images/exclamation.gif" width="24" height="22">';

return (count($errors) == 0);
}

function DisplayForm($values, $errors)
{

?>[/color]



All of the other data in the form is emailed fine. It's just the "Found us by" bit that's blank.

Cheers,

Dan

Share this post


Link to post
Share on other sites
ok, do this for me...

After this code:

[code]
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$formValues = $_POST;
$formErrors = array();
[/code]

Put this:

[code]
var_dump($formValues);
[/code]

This will output the contents of your formValues array to the screen.  Can you copy it and paste it here?

Regards
Huggie

Share this post


Link to post
Share on other sites
It outputs:

[color=blue]array(8) { ["company_name"]=> string(10) "My Company" ["company_location"]=> string(2) "UK" ["contact_name"]=> string(3) "Dan" ["email"]=> string(14) "dan@domain.net" ["phone_no"]=> string(11) "12709898310" ["enquiry"]=> string(10) "blah, blah" ["found_us_by"]=> string(0) "" ["Submit"]=> string(6) "Submit" } [/color]

Cheers,

Dan

Share this post


Link to post
Share on other sites
The fact it shows... [b]["found_us_by"]=> string(0) ""[/b] means it's submitting fine, but there's no value.

If you open the page in your browser and before you type anything in, view the source of the page.  Lets have a look at what the html looks like.

Regards
Huggie

Share this post


Link to post
Share on other sites
Code for the select menu:

   [color=blue]<SELECT name=found_us_by> <OPTION
                                value="" selected>Recommendation</OPTION>
                                <OPTION value="">Search Engine</OPTION> <OPTION
                                value="">Flyer</OPTION> <OPTION value="">Total
                                Mobile</OPTION> <OPTION value="">What
                                Mobile</OPTION> <OPTION value="">Computer
                                Weekly</OPTION> <OPTION
                              value="">Other</OPTION></SELECT> </P>[/color]


As you correctly say, there's no value.

I really feel that I've messed up with inserting the php into the value. There's knowhere that says the actual value that is to be passed.


Cheers,

Dan

Share this post


Link to post
Share on other sites
Where you've messed up is here:

[code]
function outputOptionList(&$list, $selected)
{
  foreach ($list as $item)
      echo "<option value=\"{$item['Value']}\"" . ($item['Value'] === $selected ? " selected=\"selected\"" : '') . ">{$item['Text']}</option>\n";
}
[/code]

There's nothing that calls this.  It looks to me as though you've taken a page and tried to modify it, rather than coding it from the beginning, this isn't a major problem, but has meant that it's taken us a long while to find something simple...

Can I suggest you post the code of the whole page.

Regards
Huggie

Share this post


Link to post
Share on other sites
Yes, Huggie, I'm attempting to alter a website that has been created by someone else.

The code for the whole page is:

[color=blue]<?php

function outputOptionList(&$list, $selected)
{
foreach ($list as $item)
echo "<option value=\"{$item['Value']}\"" . ($item['Value'] === $selected ? " selected=\"selected\"" : '') . ">{$item['Text']}</option>\n";
}

function VerifyForm(&$values, &$errors)
{
//form validation
if (strlen($values['company_name']) == 0)
$errors['company_name'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['company_location']) == 0)
$errors['company_location'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['contact_name']) == 0)
$errors['contact_name'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (!ereg('.+@.+\..+', $values['email']))
$errors['email'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (!is_numeric($values['phone_no']))
$errors['phone_no'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['phone_no']) == 0)
$errors['phone_no'] = '<img src="images/exclamation.gif" width="24" height="22">';

if (strlen($values['enquiry']) == 0)
$errors['enquiry'] = '<img src="images/exclamation.gif" width="24" height="22">';

return (count($errors) == 0);
}

function DisplayForm($values, $errors)
{

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="Keywords" CONTENT="XS mobile phones, Excess mobile phones, sell your phones, sell your mobiles, sell mobiles, sell mobile, money for your handset,sell phone,sell phones for cash,old mobile phones,turning mobiles into cash, mobile,mobile phones,old phones,money for old mobiles, Redundant mobile phones, unwanted phones, unwanted mobiles,sell mobile phones, Mobile phone recycling,Mobile trading,Mobile phone trading,cash for phones,cash for old mobiles,Old mobiles,sell mobiles online,Trade mobiles,Old mobile phones, mobile phone buyer, phone buyer, ">

<META NAME="Description" CONTENT="Turn old mobiles into cash. Sell your unwanted mobile phones online. Recycle unwanted mobile phones and raise funds for your company or chosen charity.">
<style type="text/css">
<!--
body {
background-color: #B6D6FF;
}
-->
</style>
<link href="xs.css" rel="stylesheet" type="text/css">
</head>

<body>
<br>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #0053A4;">
  <tr>
    <td bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center"><div align="left"><img src="images/xs_logo.gif" width="131" height="72"><a href="index.html"><img src="images/header_home_off.gif" width="77" height="72" border="0"></a><a href="about_xs_mobile_phones.htm"><img src="images/header_about_off.gif" width="96" height="72" border="0"></a><a href="xs_mobile_phones_corporate_service.htm"><img src="images/header_corporate_off.gif" width="158" height="72" border="0"></a><img src="images/header_contact_on.gif" width="109" height="72"><a href="xs_mobile_phones_faq.htm"><img src="images/header_faq_off.gif" width="187" height="72" border="0"></a></div></td>
      </tr>
      <tr>
        <td><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="20">
          <tr>
            <td><span class="sitetext">We operate primarily as an Internet based business and therefore email enquiries using the contact form below have a much faster response time.
              </p>
            </span>
              <p><span class="sitetext">Please complete the form and leave as much information as possible. We aim to respond to all enquiries as a matter of urgency.
</span>             
              <table width="100%"  border="0" cellspacing="0" cellpadding="20">
                <tr>
                  <td width="55%" align="left" valign="top"><form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST">
                    <span class="sitetext">
                    <?php
if (count($errors) > 0)
echo '<span class="errortext">Please correct the errors in the form and try again.</span><BR><BR>';
?>
                    </span>
                    <table border="0" cellspacing="4" cellpadding="0">
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Company name :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="company_name" type="text" id="company_name" size="30" value="<?= htmlentities($values['company_name']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['company_name'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Company location :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="company_location" type="text" id="company_location" size="30" value="<?= htmlentities($values['company_location']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['company_location'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Contact name :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="contact_name" type="text" id="contact_name" size="30" value="<?= htmlentities($values['contact_name']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['contact_name'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold"> email address :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="email" type="text" id="email" size="30" value="<?= htmlentities($values['email']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['email'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="middle" class="sitetextbold">Telephone number :</td>
                        <td align="left" valign="middle" class="sitetext">
                          <input name="phone_no" type="text" id="phone_no" size="30" value="<?= htmlentities($values['phone_no']) ?>">
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['phone_no'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="sitetextbold">Your enquiry :</td>
                        <td align="left" valign="top" class="sitetext">
                          <textarea name="enquiry" cols="28" rows="8" id="enquiry"><?= htmlentities($values['enquiry']) ?></textarea>
                        </td>
                        <td align="left" valign="top" class="sitetext">
                          <?= $errors['enquiry'] ?>
                        </td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td class="sitetext">
                          <p>&nbsp;
  <select name="found_us_by" >
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Recommendation</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Search
                                              Engine</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Flyer</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Total
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">What
                                              Mobile</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Computer
                                              Weekly</option>
                                              <option value="<?= htmlentities($values['found_us_by']) ?>">Other</option>
                                            </select>
 
  </p>
                                <p>
                                  <input class="sitetext"type="submit" name="Submit" value="Submit">
                                </p></td>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                  </form></td>
                  <td align="left" valign="top" class="sitetext"></td>
                </tr>
              </table>              </td>
          </tr>
        </table>          </td>
      </tr>

    </table></td>
  </tr>
</table>
<div align="center" class="sitetextsmall"></span>XS Mobile Phones &copy; 2006</div><br>
</body>
</html>

<?php
}

function ProcessForm($values)
{

$msg = "Company name : " . $values['company_name'] ."\n";
$msg .= "Company location : " . $values['company_location'] ."\n";
$msg .= "Contact name : " . $values['contact_name'] ."\n\n";
$msg .= "email : " . $values['email'] ."\n";
$msg .= "Telephone no. : " . $values['phone_no'] ."\n\n";
$msg .= "Enquiry : " . $values['enquiry'] ."\n";
$msg .= "Found us by : " . $values['found_us_by'] ."\n";

mail('dan@domain.net', 'XS Form Submission', stripslashes($msg), "From: \"{$values['contact_name']}\" <{$values['email']}>");

header( "Location: thank_you.htm" );
}

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$formValues = $_POST;
$formErrors = array();
var_dump($formValues);


if (!VerifyForm($formValues, $formErrors))
DisplayForm($formValues, $formErrors);
else
ProcessForm($formValues);
}
else
DisplayForm(null, null);
?>[/color]


Thanks, and sorry for being such a dummy,

Dan

Share this post


Link to post
Share on other sites
OK, you're hard coding the option descriptions, so you may as well just hard code the values...

<select name="found_us_by" >
<option value="Recommendation">Recommendation</option>
<option value="Search Engine">Search Engine</option>
<option value="Flyer">Flyer</option>
<option value="Total Mobile">Total Mobile</option>
<option value="What Mobile">What Mobile</option>
<option value="Computer Weekly">Computer Weekly</option>
<option value="Other">Other</option>
</select>

Regards
Huggie

Share this post


Link to post
Share on other sites
Of course, it works.


Basically, i tried to insert it using (what i thought were) the same methods as the guy that built the site. A little bit alien for somebody of my standard.

I can't believe that the solution was to do it more simply.


Sorry, and thanks loads.

I wish I had your patience!


Dan

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.