0

我仍在努力解决一些事情。现在我已经得到了我想要的,但我想再添加一个方面。我有我的时事通讯表格,它会在注册时向我发送电子邮件。我想知道这是在哪个页面完成的。这是完整的代码。

   <?php
$name = "";
$email = "";
$msg_to_user = "";
if ($_POST['name'] != "") {

    include_once "connect_to_mysql.php";

    // Be sure to filter this data to deter SQL injection, filter before querying database
    $name = mysql_real_escape_string(strip_tags(trim($_POST['name'])));
    $email = mysql_real_escape_string(strip_tags(trim($_POST['email'])));

    $sql = mysql_query("SELECT * FROM newsletter WHERE email='$email'");
    $numRows = mysql_num_rows($sql);

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

    if (!$email) {

        $msg_to_user = '<div class="warning"><ul><li>Please type an email address ' . $name . '.</li></ul></div><br /><br />';

    } else if ($numRows > 0) {

        $msg_to_user = '<div class="warning"><ul><li>' . $email . ' is already in the system.</li></ul></div><br /><br />';

    } else {

        $sql_insert = mysql_query("INSERT INTO newsletter (name, email, dateTime) 
                                                    VALUES('$name','$email',now() )")  or die (mysql_error());

        $msg_to_user = '<div class="success"><ul><li>Thanks ' . $name . ', hope you find what you want!</li></ul></div><br /><br />';
        $name = "";
        $email = "";
    }
    $message = 'Name: ' . $_POST['name'] . 'Page:'.$curPageURL.', Email: ' . $_POST['email']; 
mail('newproducts@.com', 'New Newsletter Sign Up at Jewelry',  $message);
}
?>

这是我遇到问题的部分。

function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

请注意,我正在尝试将其包含在发送给我的电子邮件中,让我知道我正在注册新闻通讯。我是以错误的方式接近这个还是我走在正确的道路上?如果我离开,请告诉我任何可能有用的解决方案或提示。

**添加转储

array(35) { ["CONTENT_LENGTH"]=> string(2) "58" ["CONTENT_TYPE"]=> string(33) "application/x-www-form-urlencoded" ["DOCUMENT_ROOT"]=> string(27) "/home3/onlinfr7/public_html" ["GATEWAY_INTERFACE"]=> string(7) "CGI/1.1" ["HTTPS"]=> string(2) "on" ["HTTP_ACCEPT"]=> string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ["HTTP_ACCEPT_ENCODING"]=> string(13) "gzip, deflate" ["HTTP_ACCEPT_LANGUAGE"]=> string(14) "en-US,en;q=0.5" ["HTTP_CACHE_CONTROL"]=> string(9) "max-age=0" ["HTTP_CONNECTION"]=> string(10) "keep-alive" ["HTTP_COOKIE"]=> string(197) "PHPSESSID=05ii2k0b7preeuc01jno24cfe1; __utma=160231841.1736281531.1369590827.1369876044.1369888331.9; __utmc=160231841; __utmz=160231841.1369590827.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)" ["HTTP_HOST"]=> string(30) "www.moniquetrinidadjewelry.com" ["HTTP_REFERER"]=> string(61) "https://www.moniquetrinidadjewelry.com/bracelet/bracelets.php" ["HTTP_USER_AGENT"]=> string(72) "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0" ["PATH"]=> string(13) "/bin:/usr/bin" ["QUERY_STRING"]=> string(0) "" ["REDIRECT_STATUS"]=> string(3) "200" ["REMOTE_ADDR"]=> string(13) "72.191.32.243" ["REMOTE_PORT"]=> string(5) "64668" ["REQUEST_METHOD"]=> string(4) "POST" ["REQUEST_URI"]=> string(23) "/bracelet/bracelets.php" ["SCRIPT_FILENAME"]=> string(50) "/home3/onlinfr7/public_html/bracelet/bracelets.php" ["SCRIPT_NAME"]=> string(23) "/bracelet/bracelets.php" ["SERVER_ADDR"]=> string(13) "67.20.101.172" ["SERVER_ADMIN"]=> string(36) "webmaster@moniquetrinidadjewelry.com" ["SERVER_NAME"]=> string(30) "www.moniquetrinidadjewelry.com" ["SERVER_PORT"]=> string(3) "443" ["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1" ["SERVER_SIGNATURE"]=> string(76) "
Apache Server at www.moniquetrinidadjewelry.com Port 443
" ["SERVER_SOFTWARE"]=> string(6) "Apache" ["SSL_TLS_SNI"]=> string(30) "www.moniquetrinidadjewelry.com" ["file_gzip"]=> string(20) "/ramdisk/cpud/status" ["PHPRC"]=> string(40) "/home3/onlinfr7/public_html/:/etc/php53/" ["PHP_SELF"]=> string(23) "/bracelet/bracelets.php" ["REQUEST_TIME"]=> int(1369955110) } 
4

0 回答 0