My form was working fine in the past, and now it is not. I'm not sure why. I've been through the code several times and have yet to find anything. The form posts with the general error that is in the code. So, something is breaking, but I'm not sure what.

Form code:

<form action="contact_process.php" method="post" name="contact">
	<table width="95%" border="0" align="center" cellpadding="2" cellspacing="2">
      <tr>
        <td width="14%" class="text"><strong>Name:</strong></td>
        <td colspan="3"><label>
          <input name="name" type="text" id="name" />
        </label></td>
      </tr>
      <tr>
        <td class="text"><strong>Email Address: </strong></td>
        <td colspan="3" class="text"><strong>
          <label>
          <input name="email" type="text" id="email" />
            </label>
        </strong></td>
      </tr>
      <tr>
        <td class="text"><strong>City:</strong></td>
        <td width="25%" class="text"><strong>
          <label>
          <input name="city" type="text" id="city" />
            </label>
        </strong></td>
        <td width="6%" class="text"><strong>State:</strong></td>
        <td width="55%" class="text"><strong>
          <select name="state" size="1">
                  <option value="AK" selected="selected">AK</option>
                  <option value="AL">AL</option>
                  <option value="AR">AR</option>
                  <option value="AZ">AZ</option>
                  <option value="CA">CA</option>
                  <option value="CO">CO</option>
                  <option value="CT">CT</option>
                  <option value="DC">DC</option>
                  <option value="DE">DE</option>
                  <option value="FL">FL</option>
                  <option value="GA">GA</option>
                  <option value="HI">HI</option>
                  <option value="IA">IA</option>
                  <option value="ID">ID</option>
                  <option value="IL">IL</option>
                  <option value="IN">IN</option>
                  <option value="KS">KS</option>
                  <option value="KY">KY</option>
                  <option value="LA">LA</option>
                  <option value="MA">MA</option>
                  <option value="MD">MD</option>
                  <option value="ME">ME</option>
                  <option value="MI">MI</option>
                  <option value="MN">MN</option>
                  <option value="MO">MO</option>
                  <option value="MS">MS</option>
                  <option value="MT">MT</option>
                  <option value="NC">NC</option>
                  <option value="ND">ND</option>
                  <option value="NE">NE</option>
                  <option value="NH">NH</option>
                  <option value="NJ">NJ</option>
                  <option value="NM">NM</option>
                  <option value="NV">NV</option>
                  <option value="NY">NY</option>
                  <option value="OH">OH</option>
                  <option value="OK">OK</option>
                  <option value="OR">OR</option>
                  <option value="PA">PA</option>
                  <option value="RI">RI</option>
                  <option value="SC">SC</option>
                  <option value="SD">SD</option>
                  <option value="TN">TN</option>
                  <option value="TX">TX</option>
                  <option value="UT">UT</option>
                  <option value="VA">VA</option>
                  <option value="VT">VT</option>
                  <option value="WA">WA</option>
                  <option value="WI">WI</option>
                  <option value="WV">WV</option>
                  <option value="WY">WY</option>
          </select>
        </strong></td>
      </tr>
      <tr>
        <td class="text"><strong>Phone:</strong></td>
        <td colspan="3" class="text"><strong>
          <label>
          <input name="phone" type="text" id="phone" />
            </label>
        </strong></td>
      </tr>
      <tr>
        <td colspan="4" class="text"><strong>Current Occupation or Business: 
            <input name="occupation" type="text" id="occupation" />
        </strong></td>
        </tr>
      
      <tr>
        <td colspan="4" class="text"><strong>Primary Reason You Are Searching for a Business Opportunity:
            <label>
            <select name="reason" id="reason">
              <option value="Select One" selected="selected">Select One</option>
              <option value="Self Employment">Self Employment</option>
              <option value="Additional Part Time Income">Additional Part Time Income</option>
              <option value="Career Change">Career Change</option>
              <option value="Added Profit Center">Added Profit Center</option>
              <option value="Other">Other</option>
            </select>
            </label>
        </strong></td>
        </tr>

      <tr>
        <td colspan="4" class="text"><strong>Level of Interest in the Caddy Card:          
            <select name="interest" id="interest">
              <option value="High" selected="selected">High</option>
              <option value="Medium">Medium</option>
              <option value="Low">Low</option>
            </select>
        </strong></td>
        </tr>
      
      <tr>
        <td colspan="4" class="text"><strong>Timeframe to Start a Business:          
            <select name="timeframe" id="timeframe">
              <option value="ASAP" selected="selected">ASAP</option>
              <option value="1-3 Months">1-3 Months</option>
              <option value="3-6 Months">3-6 Months</option>
              <option value="6-12 Months">6-12 Months</option>
              <option value="12 + Months">12 + Months</option>
            </select>
        </strong></td>
        </tr>
      <tr>
        <td colspan="4" class="text"><strong>
          <label>Questions/Comments:</label>
        </strong></td>
        </tr>
      <tr>
        <td colspan="4"><label>
          <textarea name="comments" cols="60" rows="10" id="comments"></textarea>
        </label></td>
        </tr>
      <tr>
        <td colspan="4"><label>
          <input type="submit" name="Submit" value="Submit" />
          <input type="reset" name="Submit2" value="Reset" />
          <span class="text">All Fields Required. </span></label></td>
        </tr>
    </table>   
	</form>

PHP code:

<?php
			$to = 'name@email.com';
			$subject = 'Caddy Card Biz Website Message';
			$headers = 'From: contact@caddycardbiz.com';
			
			
			// Validate name and combat magic quotes
			if (!empty($_REQUEST['name'])) {
				$name = stripslashes($_REQUEST['name']);
			} else {
				$name = NULL;
				echo '<p class=blkheader>You forgot to enter your name!</p>';
			}
			
			// Validate email and combat magic quotes
			if (!empty($_REQUEST['email'])) {
				$email = $_REQUEST['email'];
			} else {
				$email = NULL;
				echo '<p class=blkheader>You forgot to enter your email address!</p>';
			}	
			
			// Validate city and combat magic quotes
			if (!empty($_REQUEST['city'])) {
				$city = stripslashes($_REQUEST['city']);
			} else {
				$city = NULL;
				echo '<p class=blkheader>You forgot to enter your city!</p>';
			}
			
			// Validate phone and combat magic quotes
			if (!empty($_REQUEST['phone'])) {
				$phone = stripslashes($_REQUEST['phone']);
			} else {
				$phone = NULL;
				echo '<p class=blkheader>You forgot to enter your phone!</p>';
			}
			
			// Validate occupation and combat magic quotes
			if (!empty($_REQUEST['occupation'])) {
				$occupation = stripslashes($_REQUEST['occupation']);
			} else {
				$occupation = NULL;
				echo '<p class=blkheader>You forgot to enter your occupation or business!</p>';
			}
			
			// Validate reason and combat magic quotes
			if (!empty($_REQUEST['reason'])) {
				$reason = stripslashes($_REQUEST['reason']);
			} else {
				$reason = NULL;
				echo '<p class=blkheader>You forgot to enter the primary reason you are searching for a business opportunity!</p>';
			}
			
			// Validate comments and combat magic quotes
			if (!empty($_REQUEST['comments'])) {
				$comments = stripslashes($_REQUEST['comments']);
			} else {
				$comments = NULL;
				echo '<p class=blkheader>You forgot to enter your comments!</p>';
			}
			
			// If everything is okay, send the message
			if ($name && $email && $city && $state && $phone && $occupation && $reason && $interest && $timeframe && $comments)
			{
				echo "<br><p class='blackheader'>Thank you for your interest in our Caddy Card distributorship opportunity. Someone will be in contact with you shortly.<br>";
			} else { // One	 form element was not filled out properly.
				echo "<p class='blackheader'>Please go back and fill out the form again.</p>";
			}
			
			{
				$body = "The following has been submitted from the Caddy Card Biz website:\nName: $name\nEmail: $email\nCity: $city\nState: $state\nPhone: $phone\nOccupation: $occupation\nReason: $reason\nInterest: $interest\nTimeframe: $timeframe\nQuestions/Comments: $comments";
				mail ($to, $subject, $body, $headers);
			}
			?>

Recommended Answers

All 3 Replies

Looks like you don't have a conditional to trigger the mail to be sent. Try replacing the last 24 lines of contact_process.php with this:

// If everything is okay, send the message
			if ($name && $email && $city && $state && $phone && $occupation && $reason && $interest && $timeframe && $comments)
			{
				echo "<br><p class='blackheader'>Thank you for your interest in our Caddy Card distributorship opportunity. Someone will be in contact with you shortly.<br>";
			$body = "The following has been submitted from the Caddy Card Biz website:\nName: $name\nEmail: $email\nCity: $city\nState: $state\nPhone: $phone\nOccupation: $occupation\nReason: $reason\nInterest: $interest\nTimeframe: $timeframe\nQuestions/Comments: $comments";
				mail ($to, $subject, $body, $headers);
			} else { // One	 form element was not filled out properly.
				echo "<p class='blackheader'>Please go back and fill out the form again.</p>";
			}
			?>

Thanks, I'll give that a try.

Rock and roll, that worked. Thanks, pal.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.