如何让以下网址显示1周而不是1周

时间:2019-01-30 10:36:18

标签: php html mysql session

我有以下代码,对于我的最后一个变量$ duration,它应该说1周,但我认为它只显示1。以下代码是否可以工作?我正在尝试将以下链接发送到激活页面,但是在激活页面上,它没有显示$ duration变量显示1周,而是显示为1。我认为这不正确,我认为应该有工作了。

<?php
include_once __DIR__.'/header2.php';
if(!isset($_SESSION['u_uid'])) {
    echo "<meta http-equiv='refresh' content='0;url=index.php?level1promo_competitions_winner=notlogin'>"; 
    exit();
} else {
    if($_SESSION['u_permission'] == 0) {
        echo "<meta http-equiv='refresh' content='0;url=header2.php?level1promo_competitions_winner=nopermission'>"; 
       exit();
    } else {
        if(!isset($_POST['submit'])) {
            echo "<meta http-equiv='refresh' content='0;url=header2.php?level1promo_competitions_winner=error'>"; 
            exit();
        } else {
        include_once __DIR__.'/includes/dbh.php';
        $levelpromo_competitions_winner_form = strip_tags($_POST['levelpromo_competitions_winner_form']);

        if ($levelpromo_competitions_winner_form == $levelpromo_competitions_winner_form) {


    $limit = 1;
    $sql = "SELECT * FROM level1promo_participants WHERE entry_id = ? ORDER BY RAND() LIMIT ?;";

     $stmt = mysqli_stmt_init($conn);
    if(!mysqli_stmt_prepare($stmt, $sql)) {
           echo "SQL error";
        } else {
          mysqli_stmt_bind_param($stmt, "si", $levelpromo_competitions_winner_form, $limit);
          mysqli_stmt_execute($stmt);
          $result = mysqli_stmt_get_result($stmt);
          $resultCheck = mysqli_num_rows($result);


          if($resultCheck < 1) {
              echo '<div class="nolevel1promo_competitions_winner">There are no Level 1 Promo Competition\'s Winner yet for that entry id</div>';
              exit();
          } else {
                $row = mysqli_fetch_assoc($result);
                $useruid = $row['user_uid'];
                $email = $row['user_email'];
                $duration = $row['duration'];




                $sql2 = "INSERT INTO level1promo_winner (entry_id, duration, user_uid, user_email) VALUES (?,?,?,?);";

                 $stmt = mysqli_stmt_init($conn);
                if (!mysqli_stmt_prepare($stmt, $sql2)) {
                         echo "SQL statement failed";

                      } else {
                           //Bind parameters to the placeholder
                        mysqli_stmt_bind_param($stmt, "ssss", $levelpromo_competitions_winner_form, $duration, $useruid, $email);
                        mysqli_stmt_execute($stmt);

                        $subscriptionplan = 'Level 1';
                        $level1promocode = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
                        $level1promocode = str_shuffle($level1promocode);
                        $level1promocode = substr($level1promocode, 0, 10);

                        $sql3 = "UPDATE memberships
                                 SET subscriptionplan = ?, token = ?
                                 WHERE user_uid = ? AND user_email = ? AND subscriptionplan IS NULL    
                                ;";

                        $stmt = mysqli_stmt_init($conn);
                        if (!mysqli_stmt_prepare($stmt, $sql3)) {
                         echo "SQL statement failed";

                      } else {
                           //Bind parameters to the placeholder
                        mysqli_stmt_bind_param($stmt, "ssss", $subscriptionplan, $level1promocode, $_SESSION['u_uid'], $_SESSION['u_email']);
                        mysqli_stmt_execute($stmt);


                        $stmt = mysqli_stmt_init($conn);
                        $sql4 = "SELECT * FROM level1promo_winner WHERE entry_id = ?;";

                        if (!mysqli_stmt_prepare($stmt, $sql4)) {
                         echo "SQL statement failed";

                      } else {
                           //Bind parameters to the placeholder
                        mysqli_stmt_bind_param($stmt, "s", $levelpromo_competitions_winner_form);
                        mysqli_stmt_execute($stmt);
                        $result = mysqli_stmt_get_result($stmt);
                        $row = mysqli_fetch_assoc($result);

                        $to = $_SESSION['u_email'];

                                                                      //sender
                                                                      $from = 'pianocourse101@hotmail.com';
                                                                      $fromName = 'PianoCourse101';

                                                                      //email subject
                                                                      $subject = 'Congratulation Level 1 Promo Winner!'; 

                                                                      //attachment file path
                                                                      $file = "codexworld.pdf";



                                                                      //email body content
                                                                      $htmlContent = "<h1>Congratulation Level 1 Promo Winner!</h1>
                                                                       <p>Dear ".$_SESSION['u_first']." ".$_SESSION['u_last'].", <br />Thank you for applying for the Level 1 Promo Competition with the following entry_id: ".$row['entry_id']." with PianoCourse101! You are receiving this e-mail because you or someone else claiming to be you has applied for the Level 1 Promo Competition. \n\n You must activate your Level 1 Promo Code by clicking on the link below: \n\n <a href=https://www.pianocourse101.com/includes/activatelevel1promo.php?email=".htmlspecialchars($to)."&activatetoken=".htmlspecialchars($level1promocode)."&duration=".htmlspecialchars($duration).">Click here to activate your Level 1 Promo Code.</a>\n\nAlternatively, you can use the following token to manually activate your Level 3 Yearly Membership Plan by clicking on the 'Activate Membership\s Section:' \n\nToken:.$level1promocode;
                                                                      </p>";

                                                                      //header for sender info
                                                                      $headers = "From: $fromName"." <".$from.">";

                                                                      //boundary 
                                                                      $semi_rand = md5(time()); 
                                                                      $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 

                                                                      //headers for attachment 
                                                                      $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; 

                                                                      //multipart boundary 
                                                                      $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" .
                                                                      "Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n"; 

                                                                      //preparing attachment
                                                                      if(!empty($file) > 0){
                                                                          if(is_file($file)){
                                                                              $message .= "--{$mime_boundary}\n";
                                                                              $fp =    @fopen($file,"rb");
                                                                              $data =  @fread($fp,filesize($file));

                                                                              @fclose($fp);
                                                                              $data = chunk_split(base64_encode($data));
                                                                              $message .= "Content-Type: application/octet-stream; name=\"".basename($file)."\"\n" . 
                                                                              "Content-Description: ".basename($file)."\n" .
                                                                              "Content-Disposition: attachment;\n" . " filename=\"".basename($file)."\"; size=".filesize($file).";\n" . 
                                                                              "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
                                                                          }
                                                                      }
                                                                      $message .= "--{$mime_boundary}--";
                                                                      $returnpath = "-f" . $from;

                                                                      //send email
                                                                      $mail = mail($to, $subject, $message, $headers, $returnpath); 

                                                                      //email sending status
                                                                      echo $mail?"<h1>Mail sent.</h1>":"<h1>Mail sending failed.</h1>";


                      echo $duration;

当我在邮件功能中回显$ duration时,它仅显示为1.。

0 个答案:

没有答案