2010-10-28 98 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连接是否打开?

但是,请确保将来提供更多信息。