Hi, guys. I've got a simple registration form that is submitting new user's contact information into a MySQL database. However, now when the form is submitted, I need the data to be sent in an email to the site's admin.

Anybody know a good resource for this?

Thanks!

Tom Tolleson

try this code:

//OPTIONS 
$sendTo = 'email@ofadmin.com'; //address to end form contants to
$subject = 'Enter you subject here'; //subject of the e-mail

//mail headers     
$MAIL_HEADER  = ("From: no-reply@yourdomain.com\n");
$MAIL_HEADER .= ("Reply-To: no-reply@yourdomain.com\n");
$MAIL_HEADER .= ("Content-Type: text/html; charset=us-ascii\n");
$MAIL_HEADER .= ("MIME-Version: 1.0\n\n");

//setup message content 
$mailContent = 'Enter you data here'; //this is where you add your data to be sent as the message it can be formated in html if you wish
  //$mailContent .= 'second line of data'; ///you can add a line to the data here if you want
    
    try { //try sending the e-mail
    mail( $sendTo, $subject, $mailContent, $MAIL_HEADER );
    //print('Thank you, your message has been sent.');  //if you want a message after email sent
    exit;
    } catch (Exception $e) { //send failed let's throw something
    echo 'Caught exception: ',  $e->getMessage(), "\n";
    exit;
  }

hope this helps!

yes,put the above code after your insert query....

This is assuming of course, you're guarding against SQL injections, before you send all this stuff...

Hi, guys. I've got a simple registration form that is submitting new user's contact information into a MySQL database. However, now when the form is submitted, I need the data to be sent in an email to the site's admin.

Anybody know a good resource for this?

Thanks!

Tom Tolleson

PHP PAGE

<?
$artwork =@addslashes($_POST['service']);
$company=$_POST['company'];
$city=$_POST['city'];
$state=$_POST['state'];
$country=$_POST['country'];
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$domain=$_POST['domain'];
$existing=$_POST['existing'];
$others=$_POST['others'];
$search=$_POST['search1'];

$artwork=(!empty($_POST['service'])? array_map('stripslashes',$_POST['service']) : ''); 
 echo $mail_body='<style type=text/css><!--td {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;}--></style>
<table width="50%"  border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#E7E7E7">
  <tr>
    <td><table width="100%"  border="0" align="center" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF">
        <input type="hidden" name="contact" value="ok">
        <tr>
          <td colspan="3" align="center" height=35><strong>Contact Details</strong></td>
        </tr>
        <tr>
          <td width="34%">Company</td>
          <td width="3%">:</td>
          <td width="63%">'.$company.'</td>
        </tr><tr>
          <td width="34%">City</td>
          <td width="3%">:</td>
          <td width="63%">'.$city.'</td>
        </tr>
		<tr>
          <td width="34%">state</td>
          <td width="3%">:</td>
          <td width="63%">'.$state.'</td>
        </tr>
		<tr>
          <td width="34%">Country</td>
          <td width="3%">:</td>
          <td width="63%">'.$country.'</td>
        </tr>
		<tr>
          <td width="34%">Name</td>
          <td width="3%">:</td>
          <td width="63%">'.$name.'</td>
        </tr>
        <tr>
          <td>email </td>
          <td>:</td>
          <td>'.$email.'</td>
        </tr>
        <tr>
          <td>phone </td>
          <td>:</td>
          <td>'.$phone.'</td>
        </tr>
		 <tr>
          <td>Domain </td>
          <td>:</td>
          <td>'.$domain.'</td>
        </tr>
		 <tr>
          <td>Existing </td>
          <td>:</td>
          <td>'.$existing.'</td>
        </tr>
		 <tr>
          <td>Services </td>
          <td>:</td>
          <td>
		 
		  '.(is_array($artwork)? implode(",",$artwork) : '').'

		  
		  </td>
        </tr>
				
		
		<tr>
          <td>Other Requirements </td>
          <td>:</td>
          <td>'.$others.'</td>
        </tr>
        <tr>
          <td>Search Engine </td>
          <td>:</td>
          <td>'.$search.'</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
    </table></td>
  </tr>
</table>';
exit;
	
	//echo $mail_body;exit;	
	$mailto = 'yourmailid' ;	

	$mailheader  = 'MIME-Version: 1.0' . "\r\n";
	$mailheader .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";	
	$mailheader.=" From: ".$_POST['email']."\r\n";
	//$mailheader .= 'BCc: 'ex@ex.com'  '. "\r\n";
		@mail($mailto,'Contact Us Details',$mail_body,$mailheader);		
	echo '<script language="javascript">window.location.href="thanku.html";</script>';	


?>
<HTML>
<HEAD>
<title></title>

<meta name="keywords" content="">





<script language="JavaScript" type="text/JavaScript" src="website_design_javascript.js"></script>
<link href="website_development_stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.noborder{font-size:18px;font-family:Verdana, Arial, Helvetica, sans-serif;border-bottom: #ffffff 0px solid;border-top: #ffffff 1px solid;border-left: #ffffff 1px solid;border-right: #ffffff 0px solid;COLOR: #000000}
.style21 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style25 {font-size: 12px}
.style27 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
.style28 {color: #000000}
.style29 {font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;}
.style30 {color: #FF0000}
-->
</style>
</HEAD>
<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 onLoad="MM_preloadImages('../images/mid-links-over_02.gif','../images/mid-links-over_03.gif','../images/mid-links-over_04.gif','../images/mid-links-over_05.gif')">
<TABLE WIDTH=775 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
  <TR>
   
    <TD width="760" align="left" valign="top" bgcolor="#FFFFFF"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
        
        <tr>
          <td align="left" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
             
              <td width="577" align="left" valign="top">                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    
                    <tr>
                      
                    <tr>
                            <td align="left" valign="top">
<SCRIPT>//global variable for error flag
var errfound = false;
//function to validate by length
function ValidLength(item, len) {
   return (item.length >= len);
}
//function to validate an email address
function ValidEmail(item) {
   if (!ValidLength(item, 5)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   
   return true;
}
// display an error alert
function error(elem, text) {
// abort if we already found an error
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
   errfound = true;
}
// main validation function
function Validate() {
   errfound = false;
   if (!ValidLength(document.form.company.value,1))
      error(document.form.company,"Enter Your Company Name");
	if (!ValidLength(document.form.city.value,1))
      error(document.form.city,"Enter Your City Name");
	  if (!ValidLength(document.form.state.value,1))
      error(document.form.state, "Enter Your State Name");
	  if (!ValidLength(document.form.country.value,1))
      error(document.form.country, "Enter Your Country Name");
	  if (!ValidLength(document.form.name.value,1))
      error(document.form.name, "Enter Your Name");
	  
	   if (!ValidEmail(document.form.email.value,1))
      error(document.form.email,"Enter Your Email Id");
      if (!ValidLength(document.form.phone.value,1))
      error(document.form.phone,"Enter Your Phone Number");
	 
	   if (!ValidLength(document.form.search1.value,1))
      error(document.form.search1,"Enter Search engine Name");
	 
	  return !errfound; /* true if there are no errors */
}</SCRIPT> <SCRIPT language="javascript">
function Only_Num(id) {
	if(isNaN(document.getElementById(id).value)) {
		alert("Please Enter Numbers Only (0-9)..");
		document.getElementById(id).select();
		document.getElementById(id).value=""
		document.getElementById(id).focus();
	}
	return;
}
</SCRIPT>                           <form name="form" action="requsetsubmit.php" method="post">
                                <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
                                  <tr>
                                    <td><table width="100%" border="0" cellspacing="0" cellpadding="5">
                                        <tr>
                                          <td width="33%" class="style10 style21 style25">Company Name <font color="#FF0000">*</font></td>
                                          <td width="3%" class="style10 style21 style25">:</td>
                                          <td width="64%"><input name="company" type="text" class="style29" id="company" size="25" maxlength="75"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">City<font color="#FF0000">*</font></td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="city" type="text" id="city" size="20" maxlength="50"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">State / Province<font color="#FF0000">*</font> </td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="state" type="text" id="state" size="20" maxlength="50"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Country <font color="#FF0000">*</font></td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="country" type="text" id="country" size="15" maxlength="50"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Your Name <font color="#FF0000">*</font></td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="name" type="text" id="name" size="25" maxlength="75"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">E-Mail <font color="#FF0000">*</font></td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="email" type="text" id="email" size="30" maxlength="75"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Phone<font color="#FF0000">*</font></td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="phone" type="text" id="phone" size="15" maxlength="50"onChange="Javascript:LA()"  onKeyUp="Only_Num(this.id)"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Domain Name Required ...?</td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><span class="style27">
                                            <input name="radiobutton" type="radio" class="style7" value="Yes" checked>
                                            <span class="style28">Yes</span></span>
                                            <span class="style27">
                                            <input name="radiobutton" type="radio" class="style7" value="No">
                                            <span class="style28">No</span></span></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">if Yes provide Domain Name</td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="domain" type="text" id="domain" size="30" maxlength="100"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">If No Give us Existing Web Site Name </td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="existing" type="text" id="existing" size="30" maxlength="100"></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Looking for the following Services</td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><span class="style27">
                                           <input name="service[]" type="checkbox" class="style7" value="Design New Site">
                                            Design New Site<br>
                                            <input name="service[]" type="checkbox" class="style7" value="Re-Design Existing Site">
                                            Re-Design Existing Site<br>
                                            <input name="service[]" type="checkbox" class="style7" value="Search Engine Registration">
                                            Search Engine Registration<br>
                                            <input name="service[]" type="checkbox" class="style7" value="Payment Gateway Solutions">
                                            Payment Gateway Solutions</span></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Are you Looking for Hosting Space</td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><span class="style27">
                                            <input name="radiobutton1" type="radio" class="style7" value="Yes" checked>
                                            Yes</span>
                                            <span class="style27">
                                            <input name="radiobutton1" type="radio" class="style7" value="No">
                                            No</span></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Other Requirements</td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><textarea name="others" cols="30" rows="4" wrap="VIRTUAL" class="style7 style21 style25" id="others"></textarea></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">In which Search Engine you found us..? <font color="#FF0000">*</font></td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><span class="style27">
                                            <input name="search1" type="text" class="style7" id="search" size="20" maxlength="100">
                                            (Ex:Google,Yahoo..etc)</span></td>
                                        </tr>
                                        <tr>
                                          <td class="style10 style21 style25">Which keyword you searched for..?</td>
                                          <td class="style10 style21 style25">:</td>
                                          <td><input name="keyword" type="text" id="keyword" size="35" maxlength="100">                                          </td>
                                        </tr>
                                        <tr align="center">
                                          <td colspan="3"><br>
                                            <input name="Submit" type="submit" class="style7" onClick="return Validate()" value="Submit">
&nbsp;&nbsp;&nbsp;
                <input name="Submit2" type="reset" class="style7" value="Reset"></td>
                                        </tr>
                                    </table></td>
                                  </tr>
                                </table>
                            </form></td>
                    </tr>
                      </table></td>
              </tr>
                </table></td>
        </tr>
          </table></td>
  </tr>
        
    </table></TD>
    <TD background="../images/back_03.gif"><IMG SRC="../images/back_03.gif" WIDTH=2 HEIGHT=45 ALT=""></TD>
  </TR>
</TABLE>
<script language="javascript">
var randomnumber=Math.floor(Math.random()*99999);
document.form1.rndnumber.value='9BNPL'+randomnumber
</script>
</BODY>
</HTML>

Hi frnd.... i dont know how it is useful to u..
it is also registration for based on our requirement...than just u have to do some changes what ur requirement.....

That's a really big help! Thanks guys, it works great!