I need help in mail form

Discussion in 'PHP' started by luckmann, Jun 18, 2010.

  1. #1
    Here is my form but i have one small problem... :(
    when it sends information it doesn't include the drop down menu selected option.

    <div class="form">
        <form action="contact.php" method="post" id="contactform">
            Choose Category<br />
    		<ol>
              <li><select name="select" style="width: 257px">
    			<option selected="selected">Computing/Tech</option>
    			<option>Life/Home</option>
    			<option>Education/Career</option>
    			<option>Entertainment</option>
    			<option>Shopping</option>
    			<option>Finance</option>
    			<option>Travel</option>
    			<option>Health</option>
    			<option>Money Making Opportunities</option>
    			<option>Social/Blogs</option>
    			<option>Personal</option>
    			<option>Miscellaneous</option>
    			</select>
              </li>
            	<li></li>
    			<li><label for="email">Your email <span class="red">*</span></label>
    			<input id="email" name="email" class="text" /> </li>
    			<li><label for="company">URL *</label>
    			<input id="company" name="url" class="text" value="http://" />
    			</li>
    			<li><label for="subject">Logo URL *</label>
    			<input id="subject" name="logo" class="text" value="http://" />
    			</li>
    			<li><label for="message">Description<span class="red"> *</span></label>
    			<textarea id="message" name="message" rows="6" cols="50"></textarea>
    			</li>
    			<li class="buttons">
    			<input type="image" name="imageField" id="imageField" src="images/send.gif" class="send" />
    			<div class="clr">
    			</div>
    			</li>
            </ol>
          </form>
    
    Code (markup):
    And here is the contact.php

    <?php
    
    if(!$_POST) exit;
    
    $email = $_POST['email'];
    
    
    //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
    	$error.="Invalid email address entered";
    	$errors=1;
    }
    if($errors==1) echo $error;
    else{
    	$values = array ('select','email','url','logo','message');
    	$required = array('select','email','url','logo','message');
    	 
    	$your_email = "sales@link-r.us";
    	$email_subject = "New Message: ".$_POST['subject'];
    	$email_content = "New Message:\n";
    	
    	foreach($values as $key => $value){
    	  if(in_array($value,$required)){
    		if ($key != 'logo' && $key != 'url') {
    		  if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
    		}
    		$email_content .= $value.': '.$_POST[$value]."\n";
    	  }
    	}
    	 
    	if(@mail($your_email,$email_subject,$email_content)) {
    		echo 'Message sent!'; 
    	} else {
    		echo 'ERROR!';
    	}
    }
    ?>
    Code (markup):
    this is the sample of what i get when someone submits the form

    new message:
    select:
    email: ********@yahoo.com
    company: http://********.com
    subject: http://*******.com
    message: yahoo.com
     
    luckmann, Jun 18, 2010 IP
  2. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #2
    Hmmm

    the option should look like
    <option>Life/Home</option>

    <option value='life'>Life/Home</option>
    Likewise include the values to all :)
     
    roopajyothi, Jun 18, 2010 IP
  3. luckmann

    luckmann Peon

    Messages:
    272
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks but i didn't work :(

    still not sending values and i get this error:

    PLEASE FILL IN REQUIRED FIELDS
     
    luckmann, Jun 18, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    I don't understand where the script it is!
    I need to see he demo else

    Better get some one for that if you like :)
     
    roopajyothi, Jun 18, 2010 IP