2013-05-06 77 views
-2

這是我的代碼。點擊按鈕轉到「playlist.php」文件後,變量不會像在「post」命令中一樣繼續。幫幫我?POST不通過變量

編輯:這是發送變量的文檔中的代碼。

if(empty($name) || empty($email)){ 
     echo '<h1>Please fill out all fields.</h1>'; 

    }else{ 

     $dup = mysql_query("SELECT name FROM sets WHERE name='".$_POST['name']."'"); 
     if(mysql_num_rows($dup) >0){ 
      echo '<h1>Username Already Used.</h1>'; 
     } 
     else{ 

      $sql = mysql_query("INSERT INTO sets VALUES ('','$name','$email')");  
      if($sql){ 

       $to = $email; 
       $email_subject = "You've created a playlist!"; 
       $email_body = "Thanks for signing up! ". 
       " Here are the details you used to sign up with:\n Name: $name \n Email: $email"; 

       $headers = "From: [email protected]"; 
       $headers .= "Reply-To: [email protected]"; 

       mail($to,$email_subject,$email_body,$headers); 

       echo '<form action="playlist.php" method="post"> 
        <input type="hidden" name="name" value="<?php echo $name; ?>"> 
        <p class="text-center"><button type="submit" class="btn btn-primary btn-large">Visit my Playlist!</button></p> 
       </form>'; 

      } 
      else{ 
       echo '<h1>Error in Registration.</h1>'; 
      } 
     } 
    } 
+0

你是不是檢查'$ _ POST [「名」]'任何地方 – 2013-05-06 22:17:53

+0

這是發送的變量,而不是接收變量一個文件。 – user2348706 2013-05-06 22:19:38

+1

那麼''發送'是什麼意思?只有郵件正在發送此代碼 – 2013-05-06 22:21:56

回答

2

至少有一個錯誤,我可以在你的代碼看到的是這一行:

echo '<form action="playlist.php" method="post"> 
        <input type="hidden" name="name" value="<?php echo $name; ?>"> 
        <p class="text-center"><button type="submit" class="btn btn-primary btn-large">Visit my Playlist!</button></p> 
       </form>'; 

你不能有字符串文字的echo聲明內的<?php echo $name; ?>。 使用這個代替:

echo '<form action="playlist.php" method="post"> 
        <input type="hidden" name="name" value="' . $name . '"> 
        <p class="text-center"><button type="submit" class="btn btn-primary btn-large">Visit my Playlist!</button></p> 
       </form>';