我正在建立一个门户网站。在这里我忘了密码页面。在这个忘记密码页面将有一个带有电子邮件ID的表单。当用户发送电子邮件并点击提交时,它将发送电子邮件。
但现在实际的问题是在我的localhost它工作正常。但是当我上传到服务器。当我打开页面忘记密码并提供电子邮件ID并单击提交时,它会显示内部服务器错误,如下图所示。
我写的代码是
<?php
ini_set('display_errors', 1);
include 'header-employer.php';
echo "In forget password page";
?>
<script type="text/javascript">
function valid_details()
{
var con1=/^[a-zA-Z0-9\_\.]+\@[a-zA-Z\.]+\.([a-z]{2,4})$/;
if(document.getElementById('email').value=="")
{
alert("Please Enter Email Id");
document.getElementById('email').focus();
return false;
}
else if(!document.getElementById('email').value.match(con1))
{
alert("Enter Valid Email Id");
document.getElementById('email').focus();
return false;
}
if(document.getElementById('pass').value=="")
{
alert("Please Enter Password");
document.getElementById('pass').focus();
return false;
}
}
</script>
<?php
if(isset($_POST['sub']) && $_POST['sub']=="Submit")
{
echo "entered into forget password";
$email=mysql_real_escape_string(trim($_POST['email']));
echo "email in forget pwd page:".$email;
$email_fetch=$con->getdata("select * from employers where email='{$email}'");
$rows=mysql_num_rows($email_fetch);
print_r($rows);
if($rows==0)
{
echo '<script> alert("Email Id Not Registered With Us.") </script>';
}
else
{
function randomcode()
{
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz0123456789";
$i = 0;
$vcode = '' ;
while($i < 7)
{
$num = mt_rand(0,61);
$tmp = substr($chars, $num, 1);
$vcode = $vcode . $tmp;
$i++;
}
return $vcode;
}
$msg=randomcode();
$secure_msg=md5($msg);
echo "update employers set pass='$secure_msg' where email='{$email}'";
$update_pass=$con->setdata("update employers set pass='$secure_msg' where email='{$email}'");
$user_subject='Your New Password';
$user_message='
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Job Portal</title>
<!-- <link rel="stylesheet" type="text/css" href="stylesheets/email.css"/> -->
</head>
<body bgcolor="#FFFFFF">
<table style="width:100%;" bgcolor="#999999">
<tr>
<td></td>
<td>
<div style="padding:15px;max-width:600px;margin:0 auto;display:block;">
<table style="width:100%;" bgcolor="#999999">
<tr>
<td style="padding:15px;"><img src="http://www.jobwhizz.com/images/logo.jpg"/></td>
</tr>
</table>
</div>
</td>
<td></td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td></td>
<td style="display:block!important;max-width:600px!important;margin:0 auto!important;clear:both!important;" bgcolor="#FFFFFF">
<div style="padding:15px;max-width:600px;margin:0 auto;display:block;">
<table style="width:100%;">
<tr>
<td>
<h3>Dear User,</h3>
<p>Your password was reset at <a style="color: #2BA6CB;" href=http://www.jobwhizz.com target=_blank>www.jobwhizz.com</a>
</p>
<p style="padding:15px;background-color:#ECF8FF;margin-bottom: 15px;">
New password is '.$msg.'
</p>
<table style="background-color:#ebebeb;font-size:18px;line-height:19px;font-family: Helvetica, Arial, sans-serif; font-weight:normal;" width="100%">
<tr>
<td>
<table align="left" style="width: 200px;float:left;">
<tr>
<td style="padding-left: 10px;">
<h5 class="">Connect with Us:</h5>
<p class=""><a href="#" style="padding: 3px 7px;font-size:12px;margin-bottom:10px;text-decoration:none;color: #FFF;font-weight:bold;display:block;text-align:center;background-color: #3B5998!important;">Facebook</a> <a href="#" style="padding: 3px 7px;font-size:12px;margin-bottom:10px;text-decoration:none;color: #FFF;font-weight:bold;display:block;text-align:center;background-color: #1daced!important;">Twitter</a> <a href="#" style="padding: 3px 7px;font-size:12px;margin-bottom:10px;text-decoration:none;color: #FFF;font-weight:bold;display:block;text-align:center;background-color: #DB4A39!important;">Google+</a></p>
</td>
</tr>
</table>
<table align="right" style="width: 300px;float:right;">
<tr>
<td>
<h5 class="">Contact Info:</h5>
<p>Phone: <strong>408.341.0600</strong><br/>
Email: support@jobwhizz.com</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</td>
<td></td>
</tr>
</table>
</body>
</html>
';
echo "sending email";
$mailto_user=mail($email, $user_subject, $user_message, $headers);
//var_dump($mailto_user);
if($mailto_user)
{
echo '<script> alert("A New Password Is Sent To Your Email Id") </script>';
//echo "<script>window.location.href = 'employer-signin.php';</script>";
header('location: employer-signin.php');
}
}
}
?>
<div class="mainwallpaper">
<div class="container">
<div class="col-md-offset-1 col-md-5"><span class="spacer100"></span>
<div class="transparent panel panel-default" >
<div class="transparent panel panel-body">
<p style="align:center;font-weight:700;">Forgot Password ?</p><hr/>
<form class="form-horizontal" method="post" action="" onsubmit="return valid_details();" autocomplete="off">
<div class="form-group">
<div class="col-sm-12">
<label for="inputPassword3" class=" control-label">Your Registered Email Id</label>
<span class="spacer10"></span>
<input type="text" class="form-control" name="email" id="email" placeholder="Registered Email Id">
<span class="spacer10"></span>
<input type="submit" class="btn btn-warning" name="sub" value="Submit">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<style>.mainwallpaper{background-image: url("http://jobwhizz.com/images/forget.jpg");
width:100%;background-size: cover;height:450px;background-position: 50% -60px;}
.layer{background-color:; width: 100%; height: 100%;}
.transparent{background:rgba(255,255,255,0.3) !important;}
</style>
<?php include 'footer.php'; ?>
任何人都可以帮助我...............
提前致谢...............!
答案 0 :(得分:1)
您可以尝试以下几件事。
error_reporting('E_ALL');
。 (更有可能的原因)因为您正在使用mail()
函数,所以可能会导致错误。检查服务器的邮件配置。更多信息:PHP's mail() function causes a 500 Internal Server Error only after a certain point in the code
将您的服务器配置与本地主机的配置进行比较。