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 = "[email protected]";

$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
https://forums.phpfreaks.com/topic/230124-php-subscription-form-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.