<?php

//productname email

 

 

if( isset($_GET['mail']) )
{ 
  $email = $_GET['mail'];    
}
else
{
  print_r("没有输入邮箱!");
  exit;
}

if( isset($_GET['name']) )
{ 
  $product = $_GET['name'];    
}
else
{
  print_r("没有输入系统!");
  exit;
}

 function validateEmail($email)
   {
     //create the e-mail validation regular expression
     $regexp="^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,6})$";
     if(eregi($regexp,$email)) 
     { 
       return 1;
     }
     else
     {
       return 0; 
     }
   }

if (!validateEmail($email))
{
  if($product=="Dingyue")
  {
  echo "<script>alert('Not valid email address,please check and retry!'); history.back();</script>"; 
 
 
  }
 exit;
}

//连接MySQL
$conn = @mysql_connect("localhost", "gili0512", "nIJ9qatVBLKS");

if($conn == FALSE)
{	
  print_r("连接失败!");
  exit;
}

//选择数据库
mysql_select_db("gili0512_livecheck");

 
//执行SQL
$result = @mysql_query("INSERT INTO gsgiveawayinfo(id,Email,Product) VALUES (0,'$email','$product')");
			
 
 

//关闭连接
mysql_close();



 if($product=="Dingyue")
 {
  echo "<script>alert('You have successfully subscribed to our newsletter!');history.back();</script>"; 
  
  exit;
 }

?> 
