Ok I’m not great at explaining things so here goes.
There is one section of our customer contact form that I’m having problems with. (I’ve cut out all the other pieces of validation just to zoom in on this section for readability.)
There is an input field for phone number and beside it a check box if the customer wants to request a call back. When this is sent to email it will mean there are three options for the variable $phone_me this will replace the echo statements that are there now.
Any way my problem, I have tried so many different ways of doing this and I get the outcome I want but I keep getting the error Undefined index: call which is related to where the variables have been set. Just before the if statement. Where $call = $_POST[‘call’]; is set to the variable $call. It’s driving me loopy to be honest. I’ve been at it all day. I’m new to php, so if I have made a classic school boy error would someone be kind enough to point it out. Or if there is a better way of writing this, if you wouldn’t mind showing me an example I would be ever so grateful.
Many many thanks in advance for any advice and info given,
Oraya
[php]
<?php //IF FORM NOT YET SUBMITTED //DISPLAY THE FORM if (!isset($_POST['submit'])) { ?>[/php]
<form name="ContactUs" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<fieldset class="form_fieldset">
<legend> Contact Us </legend>
<div><label class="mail_label">Title:</label>
<select name="title" class="select" id="required">
<option></option>
<optgroup label="--- Title ---">
<option>Mr</option>
<option>Mrs</option>
<option>Miss</option>
<option>Ms</option>
</optgroup>
</select></div>
<div>
<label class="mail_label">First Name:</label>
<input type="text" name="first_name" value="" class="mail" id="required"/>
</div>
<div>
<label class="mail_label">Last Name:</label>
<input type="text" name="last_name" value="" class="mail" id="required"/>
</div>
<div>
<label class="mail_label">Email:</label>
<input type="text" name="email" value="" class="mail" id="required"/>
<div class="mail_checkbox">
<input type="checkbox" name="call" value="Yes" /> Do you wish us to call you?:
</div></div>
<div>
<label class="mail_label">Phone:</label>
<input type="text" name="phone" value="" class="mail" id="not_required"/>
</div>
<div>
<label class="mail_label">Subject:</label>
<select name="subject" class="subject-select" id="required">
<option></option>
<optgroup label="--- Subject ---">
<option>Report Website Issuses</option>
<option>Enquiries</option>
<option>Other</option>
</optgroup>
</select>
</div>
<label class="mail_label">Message:</label>
<br />
<textarea wrap="physical" id="form_textarea" name="message" class="mail"></textarea>
<div class="warning"><strong>Please Note:</strong> Required fields are highlighted in <ins>Blue</ins>!</div>
<br />
<div class="contact_submit"><input type="submit" name="submit" value=" Contact Us " class="form_submit"/> <input type="reset" value="Clear Form" class="form_submit"/></div>
</fieldset>
</form>
[php]
<?php // IF FORM SUBMITTED // PROCESS FORM THE DATA INPUT } else { // SET THE VARIABLES. $phone = $_POST['phone']; $call = $_POST['call']; if(strlen($phone) ==0) { echo "Do nothing"; } elseif ($call == "Yes") { echo "Customere left phone number, and requested call back. Their phone number is: "; echo $_POST['phone']; } else { echo "Phone left their phone number but not request a call back: Their phone numnber is: "; echo $_POST['phone']; } }?>[/php]