We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25607
    • 22 Posts
    Hello-

    I working on a new php form.

    The from works fine/submits ’outside’ MODx:

    http://www.csuanimalcancercenter.org/assets/php/rdvm_consult_mx.php

    but it will not work properly/submit in MODx as a snippet.

    <?php
    require(’assets/php/rdvm_consult_mx.php’);
    ?>

    http://www.csuanimalcancercenter.org/rdvm


    Does anyone have any suggestions?

    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      How are you calling the snippet? Cached [[SnippetName]]or uncached [!SnippetName!] For a form, it must be uncached.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 25607
        • 22 Posts
        On the Create/edit snippet page the snippet name is: [[rDVM]], I don’t think I can change the ’[[ ]]’ parameters there, so in the web page I changed it to [!rDVM!].

        <table class="content" border="0">
        <tbody>
        <tr>
        <td class="content_td" valign="top">
        <h1>rDVM Consulting Form</h1>
        <p>[!rDVM!]</p>
        </td>
        </tr>
        </tbody>
        </table>


        Still no luck. I’m using MODx 0.9.6.3, does that matter? Am I missing something?

        Thanks!!!
          • 16278
          • 928 Posts
          I think you need to have a return at the end of the snippet code. It doesn’t work at the end of an included file.
          smiley KP
            • 25607
            • 22 Posts
            No sure I follow. Here is my snippet code;

            <?php
            require(’assets/php/rdvm_consult_mx.php’);
            ?>

            Can you please explain?

            Thanks!
              • 16278
              • 928 Posts
              Sorry, I misunderstood the way you are working. It would help if we could see the PHP code. Presumably you are using echo or print statements to generate the HTML? Generally it is better to build up the HTML as a string, and to deliver it to the page as the output of a snippet using a return statement Which can’t be in an include file -- hence my comment.

              Looking at the page as HTML, there are a lot of things that are not valid XHTML, and some that are not valid HTML. For instance, you can’t have a DIV within a P tag. Whether that affects the operation of the form, I don’t know. You have a STYLE block in the body; in my experience it works, but it’s not correct. Does the table around the form serve any purpose? It only has one row and one cell, and it shows up as a problem in my editor. You could probably get rid of it.

              I doubt if any of the above is preventing the form from working. That’s probably because you are naming /index.php as the action for the form, and that file is heavily tied up parsing MODx stuff. In the one that works, the page containing the form is the action.
              wink KP
                • 25607
                • 22 Posts
                Great, thank you for your response. Here is my PHP code.

                Thanks!


                <?php
                	$errors = array();
                	
                	if ($_SERVER['REQUEST_METHOD']=="POST"){
                	
                	$fields = array('information', 'requested_date_month', 'requested_date_day', 'requested_date_year', 'requested_time_hour', 'requested_time_minute', 'veterinarian', 'clinic_name', 'address', 'city', 'state', 'zip', 'email', 'client_name', 'animal_name', 'animal_age', 'animal_breed', 'animal_gender', 'animal_intact');
                	
                	foreach ($fields as $field) {
                		if(!$_POST[$field]) {
                			array_push($errors, $field);
                		}
                	}
                	
                	if((!$_POST['home_phone']) && (!$_POST['mobile_phone']) && (!$_POST['work_phone'])){ array_push($errors, 'phone'); }
                	
                	if(count($errors) == 0){
                	
                	// Assign TO, FROM, and SUBJECT
                	$to="eamil address here";
                	$from="CSU Animal Cancer Center <[email protected]";
                	$subject="CSU ACC rDVM Consulting Form Submission";
                	
                	$diagnosis = stripslashes($_POST['diagnosis']);
                	$information = stripslashes($_POST['information']);
                	
                	$requested_date_month = stripslashes($_POST['requested_date_month']);
                	$requested_date_day = stripslashes($_POST['requested_date_day']);
                	$requested_date_year = stripslashes($_POST['requested_date_year']);
                	$requested_time_hour = stripslashes($_POST['requested_time_hour']);
                	$requested_time_minute = stripslashes($_POST['requested_time_minute']);
                	$time_am_pm = stripslashes($_POST['time_am_pm']);
                	
                	$veterinarian = stripslashes($_POST['veterinarian']);
                	$clinic_name = stripslashes($_POST['clinic_name']);
                	
                	$address = stripslashes($_POST['address']);
                	$city = stripslashes($_POST['city']);
                	$state = stripslashes($_POST['state']);
                	$zip = stripslashes($_POST['zip']);
                	
                	$home_phone = stripslashes($_POST['home_phone']);
                	$work_phone = stripslashes($_POST['work_phone']);
                	$mobile_phone = stripslashes($_POST['mobile_phone']);
                	$fax = stripslashes($_POST['fax']);
                	
                	$email = stripslashes($_POST['email']);
                	
                	$not_avail_from_time_hour = stripslashes($_POST['not_avail_from_time_hour']);
                	$not_avail_from_time_minute = stripslashes($_POST['not_avail_from_time_minute']);
                	$not_avail_from_ampm = stripslashes($_POST['not_avail_from_ampm']);
                	$not_avail_to_time_hour = stripslashes($_POST['not_avail_to_time_hour']);
                	$not_avail_to_time_minute = stripslashes($_POST['not_avail_to_time_minute']);
                	$not_avail_to_ampm = stripslashes($_POST['not_avail_to_ampm']);
                	
                	$client_name = stripslashes($_POST['client_name']);
                	$animal_name = stripslashes($_POST['animal_name']);
                	$animal_age = stripslashes($_POST['animal_age']);
                	$animal_breed = stripslashes($_POST['animal_breed']);
                	$animal_gender = stripslashes($_POST['animal_gender']);
                	$animal_intact = stripslashes($_POST['animal_intact']);
                	
                	// Message is built here
                	$message = "<div style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'>
                	
                	<img src='http://www.csuanimalcancercenter.org/assets/images/ACC_consult_hdr_v2.jpg' width='575' height='101' alt='Colorado State University Animal Cancer Center - Advancing Cancer Center' />
                	
                	<h4 style='text-decoration: underline; font-size: 18px;'>rDVM Consulting Form</h4>
                	
                	<p><strong>Assigned to:</strong> _______________________________________ <strong>Consult #:</strong> ____________</p>
                	
                	<p style='width: 575px;'><strong>Diagnosis:</strong> $diagnosis</p>
                	
                	<p style='width: 575px;'><strong>What information can we help you with?</strong> $information</p>
                	
                	<p><strong>Requested Date:</strong> $requested_date_month $requested_date_day, $requested_date_year <strong>Time:</strong> $requested_time_hour:$requested_time_minute $time_am_pm</p>
                	
                	<p><strong>Issued Date:</strong> __________________ <strong>Time:</strong> _________________ AM/PM</p>
                	
                	<p><strong>Veterinarian:</strong> $veterinarian // <strong>Clinic name:</strong> $clinic_name</p>
                	
                	<p><strong>Address:</strong> $address, $city, $state $zip</p>
                	
                	<table cellpadding='0' cellspacing='0' style='font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;'>
                		<tr>
                			<td colspan='5'><strong>Phone:</strong></td>
                		</tr>
                		<tr>
                			<td width='20'></td>
                			<td><em>(home)</em> </td>
                			<td>$home_phone</td>
                			<td>  <em>(work)</em> </td>
                			<td>$work_phone</td>
                		</tr>
                		<tr>
                			<td width='20'></td>
                			<td><em>(mobile)</em> </td>
                			<td>$mobile_phone</td>
                			<td>  <em>(fax)</em> </td>
                			<td>$fax</td>
                		</tr>
                	</table>
                	
                	<p><strong>Email:</strong> <a href='mailto:$email'>$email</a></p>
                	
                	<p>Time(s) <strong><em><u>NOT</u></em></strong> available: Time: $not_avail_to_time_hour:$not_avail_to_time_minute $not_avail_to_ampm from Time: $not_avail_from_time_hour:$not_avail_from_time_minute $not_avail_from_ampm</p>
                	
                	<p><strong>Client's name:</strong> $client_name</p>
                	
                	<p><strong>Animal's name:</strong> $animal_name // <strong>Age:</strong> $animal_age // <strong>Breed:</strong> $animal_breed</p>
                	
                	<p><strong>Sex:</strong> $animal_gender // <strong>Status:</strong> $animal_intact</p>
                	
                	<p><strong><em>Office use only:</em></strong></p>
                	
                	<img src='http://www.csuanimalcancercenter.org/assets/images/ACC_box_v1.jpg' width='575' height='226' />
                	
                	<p>Faxes to be sent: _______________ Return Date: ___________ Time: ___________ AM/PM</p>
                	
                	<p>Messages Left: ____________________________________________________________</p>
                
                	<p><strong>Please return to:</strong> <em>(email)</em> <a href='mailto:mail here'>email here</a>, or <em>(fax)</em> (970) 297-1254</p>
                	
                	<img src='http://www.csuanimalcancercenter.org/assets/images/ACC_consult_ftr_v2.jpg' width='575' height='32' alt='Copyright 2010 Animal Cancer Center - Colorado State University, 300 West Drake Road, Fort Collins, CO 80523 USA' />
                	
                	</div>";
                   
                	// End build message
                	
                	$headers = "MIME-Version: 1.0\r\n";
                	$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
                	$headers.= "From: [email protected]\r\n";
                	if (mail($to, $subject, $message, $headers)) {
                		header('Location: http://www.csuanimalcancercenter.org/consult-submission');
                	}
                	else {
                		echo "<p>The form submission has failed.</p>";
                	}
                	}
                } if($_SERVER['REQUEST_METHOD']!="POST" || count($errors) > 0){
                
                ?>
                
                	  <div style="margin: 0px 10px; width: 500px;">
                		
                		
                		<?php if(count($errors) > 0){ echo '<p style="color: red; text-align: center;">There are problems with your form submission.  See below for missing fields.</p>'; } ?>
                		
                		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="rdvm_consulting">
                		
                		<p>Diagnosis:<br />
                		  <textarea name="diagnosis" rows="3" cols="75"><?php echo $_POST['diagnosis']; ?></textarea>
                		</p>
                		<p><font color="red">*</font> What information can we help you with?:<br /><textarea name="information" rows="8" cols="75"><?php echo $_POST['information']; ?></textarea>
                		<?php if(in_array('information', $errors)){ echo '<br /><span style="color: red;">Required Field</span>'; } ?></p>
                		
                		<p><font color="red">*</font> Requested Date:
                			
                			<select name="requested_date_month">
                			<?php
                				$months = array('', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
                			
                				foreach ($months as $month) {
                					$echo_month = '<option value="' . $month . '"';
                					if($_POST['requested_date_month'] == $month){ $echo_month .= ' selected'; }
                					$echo_month .= '>' . $month . '</option>';
                					echo $echo_month;
                				}
                			?>
                			</select>
                			
                			<select name="requested_date_day">
                			<option value=''></option>
                			<?php
                				$days = range(1,31);
                			
                				foreach ($days as $day) {
                					$echo_day = '<option value="' . $day . '"';
                					if($_POST['requested_date_day'] == $day){ $echo_day .= ' selected'; }
                					$echo_day .= '>' . $day . '</option>';
                					echo $echo_day;
                				}
                			?>
                			</select>
                			
                			<select name="requested_date_year">
                			<option value=''></option>
                			<?php
                				$this_year = date('Y');
                				$num_years = 11;
                				$i = 0;
                				
                				while ($i < $num_years) {
                					$year = $this_year + $i;
                					
                					$echo_year = '<option value="' . $year . '"';
                					if($_POST['requested_date_year'] == $year){ $echo_year .= ' selected'; }
                					$echo_year .= '>' . $year . '</option>';
                					echo $echo_year;
                					
                					$i++;
                				}
                			?>
                			</select>
                            
                              <font color="red">*</font> Time:
                			
                			<select name="requested_time_hour">
                			<option value=''></option>
                			<?php
                				$hours = range(1,12);
                			
                				foreach ($hours as $hour) {
                					$echo_hour = '<option value="' . $hour . '"';
                					if($_POST['requested_time_hour'] == $hour){ $echo_hour .= ' selected'; }
                					$echo_hour .= '>' . $hour . '</option>';
                					echo $echo_hour;
                				}
                			?>
                			</select>:<select name="requested_time_minute">
                			<option value=''></option>
                			<option value='00' <?php if($_POST['requested_time_minute'] == '00'){ echo 'selected'; } ?>>00</option>
                			<option value='01' <?php if($_POST['requested_time_minute'] == '01'){ echo 'selected'; } ?>>01</option>
                			<option value='02' <?php if($_POST['requested_time_minute'] == '02'){ echo 'selected'; } ?>>02</option>
                			<option value='03' <?php if($_POST['requested_time_minute'] == '03'){ echo 'selected'; } ?>>03</option>
                			<option value='04' <?php if($_POST['requested_time_minute'] == '04'){ echo 'selected'; } ?>>04</option>
                			<option value='05' <?php if($_POST['requested_time_minute'] == '05'){ echo 'selected'; } ?>>05</option>
                			<option value='06' <?php if($_POST['requested_time_minute'] == '06'){ echo 'selected'; } ?>>06</option>
                			<option value='07' <?php if($_POST['requested_time_minute'] == '07'){ echo 'selected'; } ?>>07</option>
                			<option value='08' <?php if($_POST['requested_time_minute'] == '08'){ echo 'selected'; } ?>>08</option>
                			<option value='09' <?php if($_POST['requested_time_minute'] == '09'){ echo 'selected'; } ?>>09</option>
                			<?php
                				$minutes = range(10,59);
                			
                				foreach ($minutes as $minute) {
                					$echo_minute = '<option value="' . $minute . '"';
                					if($_POST['requested_time_minute'] == $minute){ $echo_minute .= ' selected'; }
                					$echo_minute .= '>' . $minute . '</option>';
                					echo $echo_minute;
                				}
                			?>
                			</select>
                			
                			<select name="time_am_pm">
                			<?php
                				$am_pm = array('AM', 'PM');
                			
                				foreach ($am_pm as $apm) {
                					$echo_am_pm = '<option value="' . $apm . '"';
                					if($_POST['time_am_pm'] == $apm){ $echo_am_pm .= ' selected'; }
                					$echo_am_pm .= '>' . $apm . '</option>';
                					echo $echo_am_pm;
                				}
                			?>
                			</select>
                			
                			<?php if(in_array('requested_date_day', $errors) || in_array('requested_date_month', $errors) || in_array('requested_date_year', $errors) || in_array('requested_time_hour', $errors) || in_array('requested_time_minute', $errors)){ echo ' <span style="color: red;">Required Field</span>'; } ?>
                		</p> 
                		
                		<table width="600" height="35" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td><font color="red">*</font> Veterinarian: 
                		  <input type="text" name="veterinarian" size="27" value="<?php echo $_POST['veterinarian']; ?>">  <font color="red">*</font> Clinic name: 
                		  <input type="text" name="clinic_name" size="27" value="<?php echo $_POST['clinic_name']; ?>"> 
                		  <?php if((in_array('clinic_name', $errors)) || (in_array('clinic_name', $errors))){ echo ' <span style="color: red;">Required Field</span>'; } ?></td>
                          </tr>
                        </table>
                		<p><font color="red">*</font> Address: 
                		  <input type="text" name="address" size="20" value="<?php echo $_POST['address']; ?>">
                          
                            <font color="red">*</font> City: 
                		  <input type="text" name="city" size="15" value="<?php echo $_POST['city']; ?>"></p>
                		<p> <font color="red">*</font> State: 
                		
                		  <select name="state">
                		<?php
                			$states = array('', 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming');
                		
                			foreach ($states as $state) {
                				$echo_state = '<option value="' . $state . '"';
                				if($_POST['state'] == $state){ $echo_state .= ' selected'; }
                				$echo_state .= '>' . $state . '</option>';
                				echo $echo_state;
                			}
                		?>
                		  </select>
                	
                		    <font color="red">*</font> Zip:  
                		  <input type="text" name="zip" size="5" value="<?php echo $_POST['zip']; ?>">
                		
                		 <?php if((in_array('address', $errors)) || (in_array('city', $errors)) || (in_array('state', $errors)) || (in_array('zip', $errors))){ echo ' <span style="color: red;">Required Field</span>'; } ?>
                		</p>
                <table cellpadding="0" cellspacing="0">
                			<tr>
                				<td colspan="5"><font color="red">*</font> Phone:</td>
                	  </tr>
                			<tr>
                				<td width="20"> </td>
                				<td style="font-size: 80%;" align="right"><em>(home)</em> </td>
                				<td><input type="text" name="home_phone" size="25" value="<?php echo $_POST['home_phone']; ?>"></td>
                				<td style="font-size: 80%;" align="right">  <em>(work)</em> </td>
                				<td><input type="text" name="work_phone" size="25" value="<?php echo $_POST['work_phone']; ?>"></td>
                			</tr>
                			<tr>
                				<td width="20"></td>
                				<td style="font-size: 80%;" align="right"><em>(mobile)</em> </td>
                				<td><input type="text" name="mobile_phone" size="25" value="<?php echo $_POST['mobile_phone']; ?>"></td>
                				<td style="font-size: 80%;" align="right">  <em>(fax)</em> </td>
                				<td><input type="text" name="fax" size="25" value="<?php echo $_POST['fax']; ?>"></td>
                			</tr>
                			<tr>
                				<td width="20"></td>
                				<td colspan="4"><?php if(in_array('phone', $errors)){ echo ' <span style="color: red;">At Least One Phone Number is Required</span>'; } ?></td>
                			</tr>
                		</table>
                		
                		<p><font color="red">*</font> Email: 
                		  <input type="text" name="email" size="65" value="<?php echo $_POST['email']; ?>"><?php if(in_array('email', $errors)){ echo ' <span style="color: red;">Required Field</span>'; } ?></p>
                		
                		</br>
                		<p>Time(s) <strong><em><u>NOT</u></em></strong> available: Time: 
                		
                			<select name="not_avail_to_time_hour">
                			<option value=''></option>
                			<?php
                				$thours = range(1,12);
                			
                				foreach ($thours as $thour) {
                					$echo_thour = '<option value="' . $thour . '"';
                					if($_POST['not_avail_to_time_hour'] == $thour){ $echo_thour .= ' selected'; }
                					$echo_thour .= '>' . $thour . '</option>';
                					echo $echo_thour;
                				}
                			?>
                			</select>
                			:
                			<select name="not_avail_to_time_minute">
                			<option value=''></option>
                			<option value='00' <?php if($_POST['not_avail_to_time_minute'] == '00'){ echo 'selected'; } ?>>00</option>
                			<option value='01' <?php if($_POST['not_avail_to_time_minute'] == '01'){ echo 'selected'; } ?>>01</option>
                			<option value='02' <?php if($_POST['not_avail_to_time_minute'] == '02'){ echo 'selected'; } ?>>02</option>
                			<option value='03' <?php if($_POST['not_avail_to_time_minute'] == '03'){ echo 'selected'; } ?>>03</option>
                			<option value='04' <?php if($_POST['not_avail_to_time_minute'] == '04'){ echo 'selected'; } ?>>04</option>
                			<option value='05' <?php if($_POST['not_avail_to_time_minute'] == '05'){ echo 'selected'; } ?>>05</option>
                			<option value='06' <?php if($_POST['not_avail_to_time_minute'] == '06'){ echo 'selected'; } ?>>06</option>
                			<option value='07' <?php if($_POST['not_avail_to_time_minute'] == '07'){ echo 'selected'; } ?>>07</option>
                			<option value='08' <?php if($_POST['not_avail_to_time_minute'] == '08'){ echo 'selected'; } ?>>08</option>
                			<option value='09' <?php if($_POST['not_avail_to_time_minute'] == '09'){ echo 'selected'; } ?>>09</option>
                			<?php
                				$tminutes = range(10,59);
                			
                				foreach ($tminutes as $tminute) {
                					$echo_tminute = '<option value="' . $tminute . '"';
                					if($_POST['not_avail_to_time_minute'] == $tminute){ $echo_tminute .= ' selected'; }
                					$echo_tminute .= '>' . $tminute . '</option>';
                					echo $echo_tminute;
                				}
                			?>
                			</select>
                			
                			<select name="not_avail_to_ampm">
                			<?php
                				$to_am_pm = array('AM', 'PM');
                			
                				foreach ($to_am_pm as $tapm) {
                					$echo_to_am_pm = '<option value="' . $tapm . '"';
                					if($_POST['not_avail_to_ampm'] == $apm){ $echo_to_am_pm .= ' selected'; }
                					$echo_to_am_pm .= '>' . $tapm . '</option>';
                					echo $echo_to_am_pm;
                				}
                			?>
                			</select>
                			
                			from
                			
                			<select name="not_avail_from_time_hour">
                			<option value=''></option>
                			<?php
                				$fhours = range(1,12);
                			
                				foreach ($fhours as $fhour) {
                					$echo_fhour = '<option value="' . $fhour . '"';
                					if($_POST['not_avail_from_time_hour'] == $fhour){ $echo_fhour .= ' selected'; }
                					$echo_fhour .= '>' . $fhour . '</option>';
                					echo $echo_fhour;
                				}
                			?>
                			</select>
                			:
                			<select name="not_avail_from_time_minute">
                			<option value=''></option>
                			<option value='00' <?php if($_POST['not_avail_from_time_minute'] == '00'){ echo 'selected'; } ?>>00</option>
                			<option value='01' <?php if($_POST['not_avail_from_time_minute'] == '01'){ echo 'selected'; } ?>>01</option>
                			<option value='02' <?php if($_POST['not_avail_from_time_minute'] == '02'){ echo 'selected'; } ?>>02</option>
                			<option value='03' <?php if($_POST['not_avail_from_time_minute'] == '03'){ echo 'selected'; } ?>>03</option>
                			<option value='04' <?php if($_POST['not_avail_from_time_minute'] == '04'){ echo 'selected'; } ?>>04</option>
                			<option value='05' <?php if($_POST['not_avail_from_time_minute'] == '05'){ echo 'selected'; } ?>>05</option>
                			<option value='06' <?php if($_POST['not_avail_from_time_minute'] == '06'){ echo 'selected'; } ?>>06</option>
                			<option value='07' <?php if($_POST['not_avail_from_time_minute'] == '07'){ echo 'selected'; } ?>>07</option>
                			<option value='08' <?php if($_POST['not_avail_from_time_minute'] == '08'){ echo 'selected'; } ?>>08</option>
                			<option value='09' <?php if($_POST['not_avail_from_time_minute'] == '09'){ echo 'selected'; } ?>>09</option>
                			<?php
                				$fminutes = range(10,59);
                			
                				foreach ($fminutes as $fminute) {
                					$echo_fminute = '<option value="' . $fminute . '"';
                					if($_POST['not_avail_from_time_minute'] == $fminute){ $echo_fminute .= ' selected'; }
                					$echo_fminute .= '>' . $fminute . '</option>';
                					echo $echo_fminute;
                				}
                			?>
                			</select>
                		
                			<select name="not_avail_from_ampm">
                			<?php
                				$from_am_pm = array('AM', 'PM');
                			
                				foreach ($from_am_pm as $fapm) {
                					$echo_from_am_pm = '<option value="' . $fapm . '"';
                					if($_POST['not_avail_from_ampm'] == $fapm){ $echo_from_am_pm .= ' selected'; }
                					$echo_from_am_pm .= '>' . $fapm . '</option>';
                					echo $echo_from_am_pm;
                				}
                			?>
                			</select>
                		</p>
                		<p><font color="red">*</font> Client's Name: 
                		  <input type="text" name="client_name" size="60" value="<?php echo $_POST['client_name']; ?>"><?php if(in_array('client_name', $errors)){ echo ' <span style="color: red;">Required Field</span>'; } ?></p>
                		
                		<p><font color="red">*</font> Animal's name: 
                		  <input type="text" name="animal_name" size="25" value="<?php echo $_POST['animal_name']; ?>">
                            <font color="red">*</font> Age: 
                		  <input type="text" name="animal_age" size="3" value="<?php echo $_POST['animal_age']; ?>"> </p>
                		<p><font color="red">*</font> Breed: 
                		  <input type="text" name="animal_breed" size="25" value="<?php echo $_POST['animal_breed']; ?>"> 
                		  <?php if((in_array('animal_name', $errors)) || (in_array('animal_age', $errors)) || (in_array('animal_breed', $errors))){ echo ' <span style="color: red;">Required Field</span>'; } ?>
                		</p>
                <p>
                			<font color="red">*</font> Sex:
                			
                			  <select name="animal_gender">
                			<?php
                				$an_gender = array('', 'Male', 'Female');
                			
                				foreach ($an_gender as $gen) {
                					$echo_gen = '<option value="' . $gen . '"';
                					if($_POST['animal_gender'] == $gen){ $echo_gen .= ' selected'; }
                					$echo_gen .= '>' . $gen . '</option>';
                					echo $echo_gen;
                				}
                			?>
                			</select>
                            
                              <font color="red">*</font> Status:
                		
                			  <select name="animal_intact">
                			<?php
                				$an_intact = array('', 'Castrated', 'Spayed', 'Intact');
                			
                				foreach ($an_intact as $int) {
                					$echo_int = '<option value="' . $int . '"';
                					if($_POST['animal_intact'] == $int){ $echo_int .= ' selected'; }
                					$echo_int .= '>' . $int . '</option>';
                					echo $echo_int;
                				}
                			?>
                			</select>
                			
                			<?php if((in_array('animal_gender', $errors)) || (in_array('animal_intact', $errors))){ echo ' <span style="color: red;">Required Field</span>'; } ?>
                		</p>
                <p> </p>
                <p><input type="submit" name="Submit" value="Submit"></p>
                		
                		<p class="bodytext"><font color="red">*<em> Denotes Required Field</em></font></p>
                		
                		</form>
                </div>
                <?php } ?>
                	</div>
                

                  • 16278
                  • 928 Posts
                  That will take some unpicking! No offence intended, but $_POST[’animal_breed’] is definitely "mongrel" in this case! (FrontPage meets Wordpress, decides to start a family?)

                  The core problem may be to do with
                  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="rdvm_consulting">
                  being outside the actual PHP of your snippet, hence you get /index.php, which will be doing eval() on the snippet code, as the action, instead of your desired PHP_SELF.

                  I suggest you consider rewriting from the ground up, using the standard MODx eForm snippet to drive the form, with the HTML nicely separated from the PHP in chunks. You’ll find plenty of experienced people here able and willing to help sort out any eForm problems, and it will be much easier to debug and maintain.
                  smiley KP
                    • 25607
                    • 22 Posts
                    OK, thanks for taking a peek!