Jump to content

PHP Subscription Form Problem?


Recommended Posts

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.