I've just finished the form for e-mail with auto fill subject after choose one in dropdown menu.
But I seriously don't know how to redirect it to send to my E-mail
could someone help me out?

Thanks! ^^

E-mail = holmiboii@infernixe.com


Website: http://www.infernixe.com/main/contact.php

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
	<center>	<div>
									<label for="name"><strong><h1>Name:</h1></strong></label><br />
<br />

									<input type="text" size="40" name="contactname" id="contactname" value="" class="required" />
		</div></center><br />

		<center><div>
									<label for="phone"><strong><h1>Company:</h1></strong></label><br />
<br />

									<input type="text" size="30" name="company" id="company" value="" class="required" />
		</div></center><br />

							<center>	<div>
									<label for="phone"><strong><h1>Phone:</h1></strong></label><br />
<br />

									<input type="text" size="30" name="phone" id="phone" value="" class="required" />
								</div></center><br />

		<center><div>
									<label for="email"><strong><h1>Email:</h1></strong></label><br /><br />


									<input type="text" size="30" name="email" id="email" value="" class="required email" />
		</div></center>
<br />

								
		<center><div>
									<label for="subject"><strong><h1>Subject:</h1></strong></label><br />
<br />

									<select name="subject" id="subject" style="width:150px;" tabindex="1">
									  <option value="" selected="selected" class="required"> - Choose -</option>
										<option value="Question" class="required">Question</option>							
										<option value="Feedback" class="required">Feedback</option>
										<option value="Job Application" class="required">Job application</option>
										<option value="Advertisment" class="required">Advertisment</option>
										<option value="Website" class="required">Website</option>
										<option value="Other" class="required">Other</option>
									</select>
		</div> </center>

								<br />



								
						<center>		<div>
									<label for="message"><strong><h1>Message:</h1></strong></label><br />
<br />

									<textarea rows="6" cols="
                                    40" name="message" id="message" class="required"></textarea>
		</div> </center>

				<center>				<input class="button"type="submit" value="Send" name="submit" />

	  <input class="button" type="reset" name="button2" id="button2" value="Reset" />
	  </form>

Use the following code to send mail

<?php
	extract($_POST);
	
	if($submit)
	{
		$fromemail= "info@infernixe.com";
		$headers = "MIME-Version: 1.0\r\n";
		$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
		$headers .= "From: $fromemail \r\n"; 
		$mailto = "admin@infernixe.com";
		$subject= "Your Subject";
		$message = '<center> <div>
		<label for="name"><strong><h1>Name:</h1></strong></label><br />
		<br />
		 
		'.$contactname.'
		</div></center><br />
		 
		<center><div>
		<label for="phone"><strong><h1>Company:</h1></strong></label><br />
		<br />
		 
		'.$company.'
		</div></center><br />
		 
		<center> <div>
		<label for="phone"><strong><h1>Phone:</h1></strong></label><br />
		<br />
		 
		'.$phone.'
		</div></center><br />
		 
		<center><div>
		<label for="email"><strong><h1>Email:</h1></strong></label><br /><br />
		 
		 
		'.$email.'
		</div></center>
		<br />
		 
		 
		<center><div>
		<label for="subject"><strong><h1>Subject:</h1></strong></label><br />
		<br />
		 
		'.$subject.'
		</div> </center>
		 
		<br />
		 
		 
		 
		 
		<center> <div>
		<label for="message"><strong><h1>Message:</h1></strong></label><br />
		<br />
		 
		'.$message.'
		</div> </center>';
		
		/*echo $mailto; 
		echo '<br>';
		echo $subject;
		echo '<br>';
		echo $message;
		exit;*/
		$mail=mail($mailto,$subject,$message,$headers);
		if($mail)
		{
			$msg.="<br>Password has been Sent to your mail!";
		}
	}
		
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>


    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" id="contactform">
    <center> <div>
    <label for="name"><strong><h1>Name:</h1></strong></label><br />
    <br />
     
    <input type="text" size="40" name="contactname" id="contactname" value="" class="required" />
    </div></center><br />
     
    <center><div>
    <label for="phone"><strong><h1>Company:</h1></strong></label><br />
    <br />
     
    <input type="text" size="30" name="company" id="company" value="" class="required" />
    </div></center><br />
     
    <center> <div>
    <label for="phone"><strong><h1>Phone:</h1></strong></label><br />
    <br />
     
    <input type="text" size="30" name="phone" id="phone" value="" class="required" />
    </div></center><br />
     
    <center><div>
    <label for="email"><strong><h1>Email:</h1></strong></label><br /><br />
     
     
    <input type="text" size="30" name="email" id="email" value="" class="required email" />
    </div></center>
    <br />
     
     
    <center><div>
    <label for="subject"><strong><h1>Subject:</h1></strong></label><br />
    <br />
     
    <select name="subject" id="subject" style="width:150px;" tabindex="1">
    <option value="" selected="selected" class="required"> - Choose -</option>
    <option value="Question" class="required">Question</option>
    <option value="Feedback" class="required">Feedback</option>
    <option value="Job Application" class="required">Job application</option>
    <option value="Advertisment" class="required">Advertisment</option>
    <option value="Website" class="required">Website</option>
    <option value="Other" class="required">Other</option>
    </select>
    </div> </center>
     
    <br />
     
     
     
     
    <center> <div>
    <label for="message"><strong><h1>Message:</h1></strong></label><br />
    <br />
     
    <textarea rows="6" cols="
    40" name="message" id="message" class="required"></textarea>
    </div> </center>
     
    <center> <input class="button" type="submit" value="Send" name="submit" />
     
    <input class="button" type="reset" name="button2" id="button2" value="Reset" />
    </form>


</body>
</html>
commented: Thanks a lot! +0

You don't really need the action on the form since it defaults to itself anyway. Re-direct usually means something specific and that isn't what you need to do for this.

Before it displays the form, your program needs to check the post variables ($_POST) to see if something was posted (you could check the submit button variable). If you have posted data then it needs to build the variables for the email and then send it using the mail statement. I use a library that makes it easy, especially when you start using features like attachments. You can get more info on it here.

Thanks a lot from both! Helped me out a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.