What is wrong with my code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dantheman
Forum Newbie
Posts: 3
Joined: Wed May 02, 2007 1:07 pm

What is wrong with my code?

Post by dantheman »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]


I created a from that submits via email. It works fine but not all of the form elements get sent.
The following elements do not get sent: name, address, address2, HomePhone, BusinessPhone, and Besttimetocontact.
City, state, zip, email, and message do get sent.
Any ideas?

Here is the code (just the php and form parts)

Code: Select all

<?php  if($_POST['submit']) 
{
/*Here we are going to declare the variables*/
$name = $_POST['Name'];
$Address = $_POST['Address'];
$Address2 = $_POST['Address'];
$City = $_POST['City'];
$State = $_POST['State'];
$Zip = $_POST['Zip'];
$HomePhone = $_POST['Home Phone'];
$BusinessPhone = $_POST['Business Phone'];
$Email = $_POST['E-mail'];
$Message = $_POST['Message'];
$Besttimetocontact = $_POST['Best time to contact'];
//Save visitor name and entered message into one variable:
$formcontent="VISITOR NAME: $name\n\nFEEDBACK: $Name \n$Address \n$Address2 \n$city \n$state \n$zip \n$HomePhone \n$BusinessPhone \n$email \n$message \n$besttimetocontact";
$recipient = "danielmdifranco@yahoo.com";
$subject = "Contact Form";
$mailheader = "From: $email\r\n";
$mailheader .= "Reply-To: $email\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
if(mail($recipient, $subject, $formcontent, $mailheader))
  {
     echo "Thank You!";
  }
else
  {
     echo "error, email not sent.";
  }
}  
?>  		
						
						
						
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <table width="100%" border="0" cellspacing="2" cellpadding="0">
    <tr>
      <td width="150" align='right'>Name:</td>
      <td><input name="name" type="text" id="name" tabindex="1" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>Address:</td>

      <td><input name="address" type="text" id="address" tabindex="2" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>Address2:</td>
      <td><input name="address2" type="text" id="address2" tabindex="3" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>City:</td>

      <td><input name="city" type="text" id="city" tabindex="4" size="50" maxlength="50" /></td>
    </tr>
    <tr>
      <td width="150" align='right'>State:</td>
      <td>
	  
<select name="state" class="quote" style='width: 45px' tabindex="5">
  <option value="AL">AL</option>
  <option value="AK">AK</option>

  <option value="AZ">AZ</option>
  <option value="AR" selected="selected">AR</option>
  <option value="CA">CA</option>
  <option value="CT">CT</option>  
  <option value="DE">DE</option>
  <option value="DC">DC</option>

  <option value="FL">FL</option>  
  <option value="GA">GA</option>
  <option value="HI">HI</option>
  <option value="ID">ID</option>
  <option value="IL">IL</option>
  <option value="IN">IN</option>

  <option value="IA">IA</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="NE">NE</option>
  <option value="NV">NV</option>
  <option value="NH">NH</option>
  <option value="NJ">NJ</option>  
  <option value="NM">NM</option>
  <option value="NY">NY</option>

  <option value="NC">NC</option>
  <option value="ND">ND</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="VT">VT</option>
  <option value="VA">VA</option>
  <option value="WA">WA</option>
  <option value="WI">WI</option>
  <option value="WY">WY</option>
</select>	  
	  
	  </td>

    </tr>
    <tr>
      <td width="150" align='right'>Zip:</td>
      <td><input name="zip" type="text" id="zip" size="5" maxlength="5" tableindex='6'/></td>
    </tr>
    <tr>
      <td width="150">&nbsp;</td>
      <td>&nbsp;</td>

    </tr>
    <tr>
      <td width="150" align='right'>Home Phone:</td>
      <td>
        <input name="HomePhone" type="text" id="HomePhone" tabindex="7" size="15" maxlength="15" />
       </td>
    </tr>

    <tr>
      <td width="150" align='right'>Business Phone:</td>
      <td>
        <input name="BusinessPhone" type="text" id="BusinessPhone" size="15" maxlength="15" />
        
        </td>
    </tr>
    <tr>

      <td width="150">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="150" align='right'>E-Mail:</td>
      <td><input name="email" type="text" id="email" size="50" maxlength="50" /></td>
    </tr>
    <tr>

      <td width="150">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td width="150" align='right' valign='top'>Message:</td>
      <td><textarea name="message" cols="45" rows="10" id="message"></textarea></td>
    </tr>
    <tr>

      <td width="150">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
        <tr>
      <td width="150">&nbsp;</td>
          </tr>
    <tr>
      <td width="150" align='right'>Best time to contact: </td>
      <td><select name="time">
	  <option selected="selected">Choose</option>
	  	<optgroup label='--------'>

        <option value="8-12">8am-12pm</option>
        <option value="12-4">12pm-4pm</option>
        <option value="4-8">4pm-8pm</option>
		</optgroup>
      </select>
      </td>
    </tr>

    <tr>
      <td width="150">&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table><br />
  <input type="submit" name="submit" value="Submit" />
  

      
   </form>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post by arturm »

Just a little help for you

Code: Select all

$a = '1';
$A = '2';

echo "a is :".$a."<br>";
echo "A is :".$A."<br>";
I hope you see the problem in your code
dantheman
Forum Newbie
Posts: 3
Joined: Wed May 02, 2007 1:07 pm

Post by dantheman »

Not really. I am a total noob to php. I took a free script off a website and modified the elements to match my form, but I still do not understand php syntax very well. Although I am frantically learning how. :lol:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Case sensitivity. Any more detail and we would be doing the work for you.

Hint: Are you sending vars named 'var' or named 'Var'?
dantheman
Forum Newbie
Posts: 3
Joined: Wed May 02, 2007 1:07 pm

Post by dantheman »

I gotcha, I can't believe it was something so easy.

Thanks
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

It usually is.
Post Reply