Code working on local host but giving http 500 error on remote host

This code is working on local host but giving http 500 error on remote server:

[php]<?php
require_once ‘Connections/dbconnect.php’;
require_once ‘PHPMailer/class.phpmailer.php’;
if ( isset($_POST[‘btn-signup’]) ) {
$error = false;
// clean user inputs to prevent sql injections
$name = trim($_POST[‘name’]);
$name = strip_tags($name);
$name = htmlspecialchars($name);

	$log_name = trim($_POST['log_name']);
	$log_name = strip_tags($log_name);
	$log_name = htmlspecialchars($log_name);
	
	$regno = trim($_POST['regno']);
	//$regno = strip_tags($regno);
			
	$regdate = $_POST['regdate'];
	//$regdate = date('d m, Y', strtotime($regdate));
	//$regdate = strip_tags($regdate);
	
	$email = trim($_POST['email']);
	$email = strip_tags($email);
	$email = htmlspecialchars($email);
	
	$mob = trim($_POST['mob']);
	$mob = strip_tags($mob);
	$mob = htmlspecialchars($mob);
	
	$pass = trim($_POST['pass']);
	$pass = strip_tags($pass);
	$pass = htmlspecialchars($pass);
	
	$state = trim($_POST['state']);
	
	
	$dist = trim($_POST['dist']);
	
	
	
	
	// basic name validation
	if (empty($name)) {
		$error = true;
		$nameError = "Please enter your full name.";
	} else if (strlen($name) < 3) {
		$error = true;
		$nameError = "Name must have atleat 3 characters.";
	} else if (!preg_match("/^[a-zA-Z ]+$/",$name)) {
		$error = true;
		$nameError = "Name must contain alphabets and space.";
	}
	if (empty($log_name)) {
		$error = true;
		$usernameError = "Please enter your user name.";
	} else if (strlen($log_name) < 5) {
		$error = true;
		$usernameError = "Name must have atleat 5 characters.";
	} else if (!preg_match("/^[a-zA-Z0-9 ]/",$log_name)) {
		$error = true;
		$usernameError = "User Name must contain alphabets.";
	}	
	
	if (!empty($log_name)) {
		$query = "SELECT LoginName FROM adv_reg WHERE LoginName='$log_name'";
		$result = mysql_query($query);
		$count = mysql_num_rows($result);
		if($count!=0){
			$error = true;
			$usernameError = "Provided User Name is already in use.";
		}	
	}
	
	
	
	//basic email validation
	if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) {
		$error = true;
		$emailError = "Please enter valid email address.";
	} else {
		// check email exist or not
		$query = "SELECT UserEmail FROM adv_reg WHERE UserEmail='$email'";
		$result = mysql_query($query);
		$count = mysql_num_rows($result);
		if($count!=0){
			$error = true;
			$emailError = "Provided Email is already in use.";
		}
	}
	
	if (empty($mob)) {
		$error = true;
		$mobError = "Please enter your Mobile Number.";
	} else if (strlen($mob) < 10 or strlen($mob) > 10) {
		$error = true;
		$mobError = "Name must have 10 characters.";
	} else if (!preg_match("/^[0-9 ]/",$mob)) {
		$error = true;
		$usernameError = "Mobile Number must contain 10 Digits.";
	}	
	
	if (!empty($mob)) {
		$query = "SELECT Mobile FROM adv_reg WHERE Mobile='$mob'";
		$result = mysql_query($query);
		$count = mysql_num_rows($result);
		if($count!=0){
			$error = true;
			$mobError = "Provided Mobile Number is already in use.";
		}	
	}
	
	// password validation
	if (empty($pass)){
		$error = true;
		$passError = "Please enter password.";
	} else if(strlen($pass) < 6 or strlen($pass) > 15) {
		$error = true;
		$passError = "Password must have 6-15 characters.";
	}

	
	//password encrypt using SHA256();
	$pass = hash('sha256', $pass);
	
	

	
	
	// if there's no error, continue to signup  
	if(!$error ) {
		
		mysql_query( "INSERT INTO XXXX(Name, LoginName,RegNo, RegDate,UserEmail, Mobile,UserPass, State, District,ValidUpto) VALUES('$name', '$log_name', '$regno', '$regdate','$email','$mob', '$pass', '$state', '$dist', DATE_ADD(CURDATE(),INTERVAL 6 Month))");
		mysql_insert_id();
		$current_id =mysql_insert_id();
		$_SESSION['current_id'] =mysql_insert_id();
		/*if ($res) {
			$errTyp = "success";
			$errMSG = "Successfully Registered, Open e-mail and click the link to activate your account";
			$current_id =mysql_insert_id();  // it is wrong id is not being get, itis always 1  $db_handle->insertQuery($query);
		} */
			if(!empty($current_id)) {
			
			$_SERVER['HTTP_HOST'] ="XXXXX.co.in/";  
			$actual_link = "http://$_SERVER[HTTP_HOST]"."activate.php?UserEmail='$email'& UserPass='$pass'"; 
			// http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.' 

		$mail  = new PHPMailer();

$body  = "Mail From XXXX. Click the following link to activate your account <br/> <a href='" . $actual_link . "'>"  . $actual_link . "</a>";
			//$mailHeaders = "From: Admin\r\n";	//file_get_contents('contents.html');

//$body = preg_replace(’/[]/’,’’,$body);

$mail->IsSMTP();
// telling the class to use SMTP
$mail->Host = “smtpauth.XXXX.com”; //“smtp1.site.com;smtp2.site.com”;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPKeepAlive = false; // SMTP connection will not close after each email sent
//$mail->Host = “smtpauth.XXXXX.com”; // sets the SMTP server
$mail->Port = 25; // set the SMTP port for the GMAIL server 465, 587
$mail->SMTPSecure = ‘’;

$mail->Username = ‘info@XXXX’; // SMTP account username
$mail->Password = ‘XXXXX’; // SMTP account password
$mail->SetFrom = ‘[email protected]’;
$mail->AddReplyTo = ‘info@XXXXX’;
$mail->Subject = “User Authentication”;
$mail->AltBody = “To view the message, please use an HTML compatible email viewer!”; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress($_POST[“email”], $_POST[“name”]);
// $mail->AddStringAttachment($row[“photo”], “YourPhoto.jpg”);

if(!$mail->Send()) {
echo “Mailer Error (” . str_replace("@", “@”, $_POST[“email”]) . ‘) ’ . $mail->ErrorInfo . ‘
’;
echo “Your record is not saved, try again!”;
mysql_query( "DELETE FROM adv_reg WHERE LoginId=’$current_id’");
} else {
echo "

Message sent to :

" . $_POST[“name”]. ’ (’ . str_replace("@", “@”, $_POST[“email”]) . ')

Visit your Mail to Activate Your Account


';
}
// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}
else { echo “Something gone wrong, Try again”;
}
	}
	
}

?>

[/php]

[php]

Login & Registration System .DarkBlue { color: #0000A0; } darkblue { color: #0000A0; }
toplogo

Advocate's Cause List (Case Diary)

<div id="login-form">
<form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off">

	<div class="col-md-12">
    
    	<div class="form-group">
        <div > <table width="468" align="center">
About Us
What For
How Works
Screen Shots
User Guide
        	<h2 class="">Advocate Sign Up</h2>
        </div>
    
    	<div class="form-group">
        	
        </div>
        
        <?php
		if ( isset($errMSG) ) {
			
			?>
			<div class="form-group">
        	<div class="alert alert-<?php echo ($errTyp=="success") ? "success" : $errTyp; ?>">
			<span class="glyphicon glyphicon-info-sign"></span> <?php echo $errMSG; ?>
            </div>
        	</div>
            <?php
		}
		?>
        
        <div class="form-group">
        	<div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
    Full Name:     	<input type="text" name="name" class="form-control" placeholder="Enter Full Name" maxlength="50" value="<?php echo $name ?>" />
            </div>
            <span class="text-danger"><?php echo $nameError; ?></span>
        </div>
        
         <div class="form-group">
        	<div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
        	Login Name : <input type="text" name="log_name" class="form-control" placeholder="Enter User Name Upto 20 Characters" maxlength="20" value="<?php echo $log_name; ?>" />
            </div>
            <span class="text-danger"><?php echo $log_nameError; ?></span>
        </div>
        
         <div class="form-group">
        	<div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-registration-mark"></span></span>
       Bar Regn. No. : 	<input type="text" name="regno" class="form-control" placeholder="Enter Registration Number Upto 30 Characters" maxlength="30" value="<?php echo $regno; ?>" />
            </div>
            <span class="text-danger"><?php echo $regnoError; ?></span>
        </div>
        
 <div class="form-group">
        	<div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>               
         Regn. Date :  
        <input type="date" required  placeholder ="Be careful in Date Format" class="form-control" name="regdate" id="datepicker" />
        <!-- pattern ="^(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$"  -->
            </div>
            <span class="text-danger"><?php echo $regdateError; ?></span>
      </div>  
     
         <div class="form-group">
        	<div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
     E-Mail :   	<input type="email" name="email" class="form-control" placeholder="Enter Your Email" maxlength="40" value="<?php echo $email; ?>" />
            </div>
            <span class="text-danger"><?php echo $emailError; ?></span>
        </div>
        
        <div class="form-group">
        	<div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
       Mob. No. : 	<input type="tel" name="mob" class="form-control" placeholder="Enter Your Mobile No" maxlength="10" value="<?php echo $mob; ?>" />
            </div>
            <span class="text-danger"><?php echo $mobError; ?></span>
        </div>
        
        <div class="form-group">
        	<div class="input-group">
            <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
   PassWord :     	<input type="password" name="pass" class="form-control" placeholder="Enter Password 6-15" maxlength="15" />
            </div>
            <span class="text-danger"><?php echo $passError; ?></span>
        </div>

Select State :

Select State <?php $sql=mysql_query("SELECT StSl, StName FROM statelist ORDER BY StName");

while($rs=mysql_fetch_array($sql)){
echo ‘’.$rs[‘StName’]. ‘’;
}
?>


<?php echo $stateError; ?>

Select District:

Select District
<?php echo $stateError; ?>

Terms and Conditions

Privacy Policy

After Registration, Access to Advocates is Given for a Trial Period of Six (6) months.  After that one has to purchase package to continue to utilize the services.

To Know more Click Here

        <div class="form-group">
        	<button type="submit" class="btn btn-block btn-primary" name="btn-signup">
        	<h4>Sign Up</h4>
        	</button>
        	<h6>&nbsp;</h6>
        </div>
        
        <div class="form-group">
        	<hr />
        </div>
        
        <div class="form-group">
        	<h3><a href="index.php">Sign in Here...</a></h3>
        </div>
    
    </div>

</form>
[/php]

You are most likely getting a fatal runtime error (due to the obsolete mysql extension.) You need to have php’s error_reporting set to E_ALL and temporarily set display_errors to ON or make sure that log_errors is ON and then check your web server error log for any php related errors.

Sponsor our Newsletter | Privacy Policy | Terms of Service