2012-04-20 38 views
0

メールが生成されて1つのファイルに送信され、そのメールのリンクが確認ページにリンクし、を作った。問題は、私は単純なprint文だけを使用していても、何も確認ページから何も得ていないことです。私はそれを把握しようとしているが、役に立たないし、エラー報告も空白に戻っている。ここでは二つのファイルで:確認リンクが送信されても​​確認リンクが送信されないPHPメールが送信される

email.php(完全に動作します)

<?php 

$link= mysql_connect(...............); //Establish connection to the MySQL server 

if (!$link) { 
die('Could not connect: ' . mysql_error()); 
} 

mysql_select_db(.....); 

$confirm = md5(uniqid(rand())); 
$position = $_POST['position']; 
$team_name = $_POST['team_name']; 
$zip_code = $_POST['zip_code']; 
$userId = $_POST['userId']; 

$s=mysql_query("SELECT Coach, TeamId FROM TEAM WHERE TEAM.Name = '$team_name' AND TEAM.Zip  ='$zip_code'") OR die ("Error 1"); //Get result from query 

while($row=mysql_fetch_assoc($s)) 
{ 
$coachId = $row['Coach']; 
$teamId = $row['TeamId']; 
} 

$l=mysql_query("SELECT Name, Email FROM USER WHERE USER.UserId = '$userId'") OR die ("Error 3");  //Get result from query 

while($row = mysql_fetch_assoc($l)) 
{ 
$user_name = $row['Name']; 
$user_email = $row['Email']; 
} 

$q=mysql_query("SELECT Name, Email FROM USER WHERE USER.UserId = '$coachId'") OR die ("Error 4"); //Get result from query 

while($coach=mysql_fetch_assoc($q)) 
{ 
$to = $coach['Email']; 
$name = $user_name; 
$subject = "Scoutlet $position Request for The $team_name"; 

if($position == "Head Coach") 
{ 
    $message = "$name has requested to become the Head Coach for the $team_name."; 
    $message .= "\n\nClick on the following link to give $name permission to be the Head Coach of the $team_name (Located in the ZIP code $zip_code).\n\n"; 
    $message .="<a href=\"http://web.***.***/~***/confirmation.php?key=$confirm\">Click Here to make $name the Head Coach</a>"; 
} 
else 
{ 
    $message = "$name has requested to become a Score Keeper for the $team_name."; 
    $message .= "\n\nClick on the following link to give $name permission to be a Score Keeper for the $team_name (Located in the ZIP code $zip_code).\n\n"; 
    $message.="http://web.***.***/~***/confirmation.php?key=$confirm"; // way to prevent no spam, dont use txt 

} 

$headers = "From: ***"; 
$headers .= 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$sent = mail($to, $subject, $message, $headers) ; 

if($sent) 
{ 
    print "sent"; 
} 
else 
{ 
    print "fail"; 
} 
} 
$sql=mysql_query("INSERT INTO CONFIRMATION(ConfirmationNumber, UserId, Email, TeamId, TeamName, Position)VALUES('$confirm', '$userId','$user_email','$teamId', '$team_name', '$position')") OR die ("Error 2"); //Get result from query 

mysql_close(); 
?> 

confirmation.php

<? 
    ini_set('display_errors',1); 
error_reporting(E_ALL); 
$confirm = $_GET['key']; 

$link= mysql_connect(***********); //Establish connection to the MySQL server 

if (!$link) 
{ 
    die('Could not connect: ' . mysql_error()); 
} 
echo "connect4e"; 

mysql_select_db(**********); 

$sql1=mysql_query("SELECT * FROM CONFIRMATION WHERE ConfirmationNumber ='$confirm'") OR die ("Fail 1"); 

    while($row=mysql_fetch_assoc($sql1)) 
    { 
     $userId= $row['UserId']; 
     $user_email = $row['Email']; 
     $teamId = $row['TeamId']; 
     $team_name = $row['TeamName']; 
     $position= $row['Position']; 
    } 

    $sql2= mysql_query("INSERT INTO USER (Role) VALUES ('$position') WHERE UserId ='$userId'") OR die ("Fail 2"); 

    if($position =="Head Coach") 
    { 
     $sql3= mysql_query("INSERT INTO TEAM (Coach) VALUES ('$userId') WHERE TeamId ='$teamId'") OR die ("Fail 3a"); 
    } 
    else 
    { // do a check earlier on to see if the user is already a score keeper for that team 
     $sql3= mysql_query("INSERT INTO SCOREKEEPS_FOR (ScoreKeeper, Team) VALUES ('$userId', '$teamId')") OR die ("Fail 3b"); 
    } 

    $to= $user_email;   
    $subject="Welcome to Our Site"; 
    $headers = "From: ******"; 
    $message="Congratulations, you have been confirmed as a $position for The $team_name."; 

    $sent = mail($to,$subject,$message,$header); 
    if(sent) 
    { 
     $sql4=mysql_query("DELETE FROM CONFIRMATION WHERE ConfirmationNumber = '$confirm'") OR die ("Fail 5"); 
    } 
    else 
    { 
     print "fail"; 
    } 

?> 

私はすでに、ちょうどエラーチェックしようとする時間のトンを殺しましたうまくいけば目が早くそれを解決するのに役立ちますので、無駄でした。どんな助けや提案も素晴らしいでしょう。事前のおかげで

+0

確認ファイルに$ sql1をダンプしようとしましたが、文がDBから戻ってきているかどうか確認しましたか? – Rooster

+0

@ JohnB yea私は、それが何であっても空白だった。ちょうど1分前に誰かが投稿して、短いタグ<? confirmatonの開始時に問題があったし、私のエラー報告が機能し始めたので変更した後、私はここからうまくいくと思います。高速応答ありがとう! – user1070764

答えて

1

は、開始タグ

<?php 

代わりの

<? 

http://us2.php.net/manual/en/language.basic-syntax.phptags.php

PHPも短いタグを可能にして、サーバーが唯一のPHPを実行することができた(ですshort_open_tag phで有効になっている場合にのみ利用可能であるため、推奨しません。 PHPが--enable-short-tagsオプションで設定されているかどうかを確認してください。

+0

私は – squarephoenix

+1

をチェックしました。理由はわかりません。なぜならPHPがPHP開始タグを修正するまで働いていなかったからです。 –

+0

"あなたのPHPはあなたはPHPの開始タグを修正するまで働いていた "と彼は言ったのですか?私はあなたが良い参照と良い点を持っていたので-1を取り去ったが、 – squarephoenix

-1

あなたのconfirmation.phpには、短い公開タグを使用しています<? ... ?>。あなたのPHPショートタグが有効になっていることを確認するか、単に<?php ... ?>を代わりに使用してください。

関連する問題