2013-05-06 4 views
-2

내 코드는 다음과 같습니다. "playlist.php"파일로 이동하기 위해 버튼을 클릭 한 후 변수는 "post"명령에서와 같이 옮겨지지 않습니다. 도움?POST가 변수를 전달하지 않습니다.

EDIT : 이것은 변수를 보내는 문서의 코드입니다.

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; ?>을 가질 수 없습니다 : 나는 당신의 코드에서 볼 수

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

은'어디 –

+0

이 변수가 아닌 변수를받는 일을 보내는 문서입니다. – user2348706

+1

그럼'보내기 '란 무엇을 의미합니까? 이 코드에서 메일 만 보내고 있습니다. –

답변

2

적어도 하나의 오류는이 라인입니다. 사용이 대신 : 당신은`$ _POST [ '이름'] 확인되지 않은

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>'; 
관련 문제