No die() errors produced on localhost

I am developing a registration page for my site. The form does fiel validation (username, email, etc.) when I test the form on my true hosting server (godaddy.com) everything is fine, I recieve error messages as expected when the form validation finds an error.

However, when I try to test on my local machine (laptop running Apache 2.2 and PHP5), on submit of the form I get no error messages from the validation and nothing happens. It just acts as if I refreshed the page.

I have the report errors variable in php.ini set to 2039.

I guess at the top of the page I would use error_reporting(“E_ALL”); and see if you get anything.

I, tried that and no errors were produced at all. I don’t know if the code below will help but here it is. Also, as I said the site/code works fine when I test on my actual hosting account just not on my local machine.

[php]<?php
error_reporting(‘E_ALL’);
require_once($_SERVER[‘DOCUMENT_ROOT’].’/crl/db_connect.php’);
require_once($_SERVER[‘DOCUMENT_ROOT’].’/crl/global.php’);
require_once($_SERVER[‘DOCUMENT_ROOT’].’/crl/template.php’);
require_once($_SERVER[‘DOCUMENT_ROOT’].’/crl/inc/dropdown.php’);

//SEE IF ALREADY LOGGED IN
if($_SESSION[‘logged_in’] == 1)
{
//REDIRECT TO HOMEPAGE
header(‘Location: http://’ . $_SERVER[‘HTTP_HOST’] . ‘’);
} else {

//////////////////////////////////////////////////////////////////////////////////
// FORM VALIDATION
/////////////////////////////////////////////////////////////////////////////////
if(isset($HTTP_POST_VARS[‘submit’]))
{
//BEGIN CHECKING USERNAME…
if(!$_POST[‘username’]) {
die(‘Alert: username field was blank.’);
}

//array of invalid characters
$junk = array(’.’, ‘,’, ‘/’, ‘`’, ‘;’, ‘[’ , ‘]’, ‘-’,’*’,
‘&’, ‘^’, ‘%’, ‘$’, ‘@’, ‘!’, ‘~’, ‘+’, ‘(’, ‘)’,
‘|’, ‘{’, ‘}’, ‘<’, ‘>’, ‘?’, ‘:’, ‘"’, ‘=’);

//starting length of username
$len = strlen($_POST[‘username’]);

//replace invalid characters
$_POST[‘username’] = str_replace($junk, ‘’, $_POST[‘username’]);
$test = $_POST[‘username’];

//if lenghts are different ($len smaller), invalid characters found, so prompt error.
if(strlen($test) != $len) {
die(‘Username Error: Username contained invalid characters. You can only use A-Z, 0-9 and the underscore (_).’);
}

//Check if username already exists…
$q2 = mysql_query(“SELECT * FROM hgl_members WHERE username = '”.$_POST[‘username’]."’") or die(mysql_error());
$q3 = mysql_fetch_object($q2);

if($q3->username == $_POST['username']) {
die('Sorry, but the username "'.$q3->username.'" is taken, please choose another.');

}

if(strlen($_POST[‘username’]) < 6 ) {
die(‘Error: Your user name is too short. Must be 6 or more characters in length.’);
}

//Check if email address already exists…
$q2 = mysql_query(“SELECT * FROM hgl_members WHERE user_email = '”.$_POST[‘email’]."’") or die(mysql_error());
$q3 = mysql_fetch_object($q2);

if($q3->user_email == $_POST['email']) {
die('Sorry, but the email address "'.$q3->user_email.'" is already associated with another user.');

}

//PASSWORD

if(!$_POST[‘password’]) {
die(‘Error: Password field was blank’);
}
if(!$_POST[‘verify_password’]) {
die(‘Error: Verify Password field was blank.’);
}
if($_POST[‘password’] != $_POST[‘verify_password’]) {
die(‘Error: The passwords do not match.’);
}
if(strlen($_POST[‘password’]) < 6 ) {
die(‘Error: Your password is too short. Must be 6 or more characters in length.’);
}

//CHECK TERMS OF USE, AGE, GENDER
if (!$_POST[‘terms’]) {
die(‘Error: You must agree to our website terms of use before you can register.’);
}
if(!$_POST[‘gender’]) {
die(‘Error: Gender is blank.’);
}
if(!$_POST[‘age’]) {
die(‘Error: Age is blank.’);
}

/CHECK REQUIRED FIELDS FOR HOST ACCOUNT/
if($_POST[‘regtype_group’] == ‘host’) {
$member_type = “H”;

if(!$_POST['fname']) {
	die('Error: First Name is blank.');
}
if(!$_POST['lname']) {
	die('Error: Last Name is blank.');
}
if(!$_POST['city']) {
	die('Error: City is blank.');
}
if(!$_POST['region']) {
	die('Error: Region is blank.');
}
if(!$_POST['postal_code'] && $_POST['country'] == 'US') {
	die('Error: Postal code is blank.');
} else {
	if (strlen($_POST['postal_code'])!=5) {
		die('Error: Postal code must be 5 characters long.');
	}
	if (!eregi("[0-9]", $_POST['postal_code'])) //Check if the ZIP code contains only numbers
	{ die('Error: Postal code contains invalid characters.'); }
}
if(!$_POST['country']) {
	die('Error: Country is blank.');
}			

} else { $member_type = “U”; }

//ADD NEW MEMBER
$akey = md5(uniqid(rand(), true));
$insert =“INSERT INTO hgl_members (username, user_password, user_email, member_type, active,
fname, lname, street1, street2, city, region,
postal_code, country, phone1, phone2, gender,
age) VALUES
(’”.$_POST[‘username’]."’, ‘".md5($_POST[‘password’])."’, ‘".$_POST[‘email’]."’,
‘$member_type’, ‘$akey’, ‘".$_POST[‘fname’]."’, ‘".$_POST[‘lname’]."’,
‘".$_POST[‘street1’]."’, ‘".$_POST[‘street2’]."’, ‘".$_POST[‘city’]."’,
‘".$_POST[‘region’]."’, ‘".$_POST[‘postal_code’]."’, ‘".$_POST[‘country’]."’,
‘".$_POST[‘phone1’]."’, ‘".$_POST[‘phone2’]."’, ‘".$_POST[‘gender’]."’,
‘".$_POST[‘age’]."’)";

$insert2 = mysql_query($insert) or die(mysql_error());

//echo(‘Registration Successful, Welcome new member! You can now login to your new account.’);

// Send the E-Mail
$body = “Thank you for registering at the User Registration site. To activate your account, please click on this link:nn”;
$body .= “http://$home/activate.php?x=” . mysql_insert_id() . “&y=$akey”;

mail($_POST[‘email’], ‘Registration Confirmation’, $body, $webmaster);

// Show thank you message
echo ‘

Thank You!

You have been registered, an activation request has been sent to ‘.$_POST[‘email’].’. Please check your e-mail to activate your account.’;

} else {
echo $html_head;
echo $html_header_panel;
?>

<?php echo $html_stats; echo $html_a_panel_start; if(isset($_SESSION['username'])) { echo 'You are logged in as ' .$_SESSION['username']. '.'; } else { echo ' Login '; } echo $html_a_panel_end_r; ?>
<?php echo $html_logo_menu; echo $html_main_content; ?>
User Registration

*Bold text denotes a required field.


Registration Type:
User Host

User Name:

(minimum 6 characters.)

E-mail:
Password

(minimum 6 characters)

Verify Password:
First Name:
Last Name:
Address:
Address 2:
City:
State/Region:
Postal Code:
Country: <?php drop_down('country', 'description', 'hgl_country', 'country'); ?>
Phone:
Mobile:
Gender: --- Male Female
Age:
Terms:

(Please read and agree to terms of use.)

<?php echo $html_footer; } //end not logged in } //end submit not pressed ?>[/php]

[size=99px]**MOD EDIT - ADDED PHP TAGS FOR BETTER READABILTY[/size]

A bit of a nobrainer, but does it show the html header/footer? Those are echoed by the script, and pretty much indicate whether or not the PHP is actually executed (I presume it is though).

Yes, the header and footer are displayed. PHP is working, I’m just not receiving any expected erorrs when I hit submit. When I test with my online host, if I do not enter a user-name, etc. and hit submit, I get the expected “please enter a user name” error. However on my localhost nothing at all happens, it looks as if my screen was just refreshed.

If it works fine on one machine but not on the other, then the problem is in the configuration most probably (unless you have a caching problem somewhere). Check out php.ini, config files of the server software, perhaps log files, etc.

I know it’s a php.ini setting but not sure which one.

[snip]

Mod Edit: We do not appreciate such long lists.

I snipped your posting. It’s not our task to search for differences.
Have you tried replacing your php.ini file with your host’s?

Sponsor our Newsletter | Privacy Policy | Terms of Service