freelancewebdesigner Posted March 9, 2011 Share Posted March 9, 2011 I am new to PHP. I have just developed a contact us form successfully in PHP. So when some fill it the information will e-mail to me automatically. Know I need to suscription form, When someone fill the subscription form then his all information goes to my email address and as well as when he select a specific country from a drop down list the information will e-mail to that country customer,because every country has a different e-mail address. Know i need a code for that can any body plz help me. I am placing HTML and PHP Code. HTML CODE: <form action="contact.php" method="post"> <ul> <li><label>Name: </label> <input id="name" name="name" class="text" /> </li> <li><label>E-mail: </label> <input id="email" name="email" class="text" /> </li> <li><label>Subject: </label> <input id="subject" name="subject" class="text" /> </li> <li> <label> <select name="select" id="select"> <option>Germany</option> <option>United States of America</option> <option>Canada</option> <option>England</option> </select> </label> </li> <li><label>Comments: </label> <textarea id="message" name="message" rows="6" cols="50"></textarea> </li> <li class="buttons"> <input type="image" name="imageField1" id="imageField1" src="images/send.gif" /> </li> </ul> </form> PHP CODE <?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 ('name','email','message'); $required = array('name','email','message'); $your_email = "kuhashmi@gmail.com"; $email_subject = "New Message: ".$_POST['subject']; $email_content = "new message:\n"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'subject' && $key != 'company') { 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!'; } } ?> PLZZZZ Help me i need it urgently. I will be thankful to you if you provide me the cide. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.