2010-10-28 101 views
0

下面是代碼PHP - 網站無法顯示

<? 
include('config.php'); 

// table name 
$tbl_name=temp_members_db; 

// Random confirmation code 
$confirm_code=md5(uniqid(rand())); 

// values sent from form 
$name=$_POST['name']; 
$email=$_POST['email']; 
$country=$_POST['country']; 

// Insert data into database 
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')"; 
$result=mysql_query($sql); 

// if suceesfully inserted data into database, send confirmation link to email 
if($result){ 
    // ---------------- SEND MAIL FORM ---------------- 

    // send e-mail to ... 
    $to=$email; 

    // Your subject 
    $subject="Your confirmation link here"; 

    // From 
    $header="from: your name <your email>"; 

    // Your message 
    $message="Your Comfirmation link \r\n"; 
    $message.="Click on this link to activate your account \r\n"; 
    $message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; 

    // send email 
    $sentmail = mail($to,$subject,$message,$header); 
} 

// if not found 
else { 
    echo "Not found your email in our database"; 
} 

// if your email succesfully sent 
if($sentmail){ 
    echo "Your Confirmation link Has Been Sent To Your Email Address."; 
} 
else { 
    echo "Cannot send Confirmation link to your e-mail address"; 
} 

?> 
+1

在源代碼/ apache日誌中是否收到任何錯誤消息?儘可能準確地描述你的問題。 – greg0ire 2010-10-28 09:23:47

+1

究竟是什麼問題?也許你需要使用完整的PHP標籤'<?php'而不是'<?' – Harmen 2010-10-28 09:24:06

+0

網站上沒有顯示任何內容 – ABC 2010-10-28 09:25:15

回答

0

在你行$tbl_name=temp_members_db; - ?是temp_members_db定義(在config.php恆定通過define('temp_members_db','some_value')或者是它應該是一個字符串?或者它是一個變量名,這可能是你忽略了一個問題...

0

這些行添加到您的代碼的頂部:

ini_set('diplay_errors', 'on'); 
error_reporting(-1); 

你會看到什麼都沒有顯示的原因。

此外,添加echo mysql_error()看到有關查詢錯誤信息:

$result=mysql_query($sql); 
echo mysql_error(); 

temp_members_db恆定?如果不是,包裝成語錄:

'temp_members_db' 
0

確保使用全<?php代碼,並啓用錯誤報告。一旦啓用,看看它說什麼。由於config.php中沒有指示什麼,所以上面的代碼可能會有幾個問題:

  1. 什麼是$tbl_name=temp_members_db;?我想它應該是$tbl_name = 'temp_members_db';
  2. 是否設置了$_POST值?
  3. SQL連接是否打開?

但是,請確保將來提供更多信息。