php重定向

时间:2009-12-10 06:12:23

标签: php mysql

我的php脚本正在使用localhost,但在线上传后,它显示的是空白页。

php安装在localhost版本5.2.6上 php安装在生产环境版本5.1.4

<?php 
define('INCLUDE_CHECK',true);
require 'connect.php';
session_start();                        
php require 'function.php';    
?>

<html>
<head>
</head>
<body>
session_name('smsapp');
session_start(); 
$fname = mysql_real_escape_string($_POST['fname']);
$name = mysql_real_escape_string($_POST['name']);
$email =mysql_real_escape_string($_POST['email']);
$phone = mysql_real_escape_string($_POST['phone']);
$pass = substr(md5($_SERVER['REMOTE_ADDR'].microtime().rand(1,100000)),0,6);
$str = "INSERT INTO members(fname, name, pass, phone, email, regIP, dt, level)
        VALUES(
               '".$fname."',
               '".$name."',
               '".md5($pass)."',
               '".$phone."',
               '".$email."',
               '".$_SERVER['REMOTE_ADDR']."',
                  1,
                  NOW()
    )" ;
mysql_query($str);

if(mysql_affected_rows($link) == 1 && 
  ($_SESSION['security_code'] == $_POST['security_code']))
{
    echo "Password will be sent to you by sms.";
    $url = "http://sms.kohlihosting.com/sendsmsv2.asp?
            user=username&
            password=12345&
            sender=kohli&
            text=Your+password" . $pass . "&
            PhoneNumber=".$phone;

    $homepage = file_get_contents($url) ;   
}
else if(!($_SESSION['security_code'] == $_POST['security_code']))
{
    echo "Please Input correct letters ";
}
else
{
    echo "Not registered";
}
?>

这是在localhost上工作但不在线的代码。

2 个答案:

答案 0 :(得分:1)

另一种可能性是,服务器中的php.ini禁用了show-warnings。并且由于某种原因您无法连接到数据库,并且不会显示警告/错误。

在您的连接代码中,您可以尝试使用connect() or die('something')语句。这样,如果它无法连接,您会看到一条错误消息。

即使不是这种情况,你应该看看是否由于php.ini中的设置而生成并且没有显示警告/错误消息,你可能需要暂时更改它。

答案 1 :(得分:0)

我的猜测是,当您使用file_get_contents

时,您的主机不允许访问网址(出于安全考虑)

如果您有权限,可以在php.ini中打开网址:

allow_url_fopen = On