1

I am working a portal website. Here I have forget password page. In this forget password page will have a form with email id. When user gives his email and click on submit it will send an email.

But now actual problem is in my localhost it is working fine. But when I uploaded into the server. And when I open the page forget password and gave email id and clicked on submit then it showing internal server error as shown in the following image.

enter image description here

And the code I have written is

<?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'; ?>

Can anyone help me please...............

Thanks in advance...............!

1 Answers1

1

Here are few things you can try.

  1. Try adding error_reporting('E_ALL'); on top of the script.
  2. Check your web server's configuration (htaccess, virtualhost etc).
  3. (more likely cause) Since, you are using mail() function, it could be causing the error. Check your server's mail configuration. More info: PHP's mail() function causes a 500 Internal Server Error only after a certain point in the code

  4. Compare your server's configuration with your localhost's configuration.

Community
  • 1
  • 1
Vishwa
  • 1,525
  • 2
  • 13
  • 25