Jump to content

Recommended Posts

Once submitted, this form only 'checks' each required field via PHP in FireFox and Chrome, but when run in IE, it seems like the page just refreshes without giving warnings like "Email Address required!". 

 

Shouldn't be anything wrong with the header.inc.php and footer.inc.php because those work in all other pages.

 

Here is the code:

 

<?

session_start();

require 'functions.inc.php';
require 'header.inc.php';

dbconnect();


if (!isset($_POST['state']))
{
?>

<form id="joinform" action="join.php" method="post" style="padding: 25px;">Select your state: 
<select name="state" class="input">
<option value="AL" disabled="disabled">Alabama</option>
<option value="AK" disabled="disabled">Alaska</option>
<option value="AZ" disabled="disabled">Arizona</option>
<option value="AR" disabled="disabled">Arkansas</option>
<option value="CA" disabled="disabled">California</option>
<option value="CO" disabled="disabled">Colorado</option>
<option value="CT" disabled="disabled">Connecticut</option>
<option value="DE" disabled="disabled">Delaware</option>
<option value="DC" disabled="disabled">Dist of Columbia</option>
<option value="FL" disabled="disabled">Florida</option>
<option value="GA" selected="selected">Georgia</option>
<option value="HI" disabled="disabled">Hawaii</option>
<option value="ID" disabled="disabled">Idaho</option>
<option value="IL" disabled="disabled">Illinois</option>
<option value="IN" disabled="disabled">Indiana</option>
<option value="IA" disabled="disabled">Iowa</option>
<option value="KS" disabled="disabled">Kansas</option>
<option value="KY" disabled="disabled">Kentucky</option>
<option value="LA" disabled="disabled">Louisiana</option>
<option value="ME" disabled="disabled">Maine</option>
<option value="MD" disabled="disabled">Maryland</option>
<option value="MA" disabled="disabled">Massachusetts</option>
<option value="MI" disabled="disabled">Michigan</option>
<option value="MN" disabled="disabled">Minnesota</option>
<option value="MS" disabled="disabled">Mississippi</option>
<option value="MO" disabled="disabled">Missouri</option>
<option value="MT" disabled="disabled">Montana</option>
<option value="NE" disabled="disabled">Nebraska</option>
<option value="NV" disabled="disabled">Nevada</option>
<option value="NH" disabled="disabled">New Hampshire</option>
<option value="NJ" disabled="disabled">New Jersey</option>
<option value="NM" disabled="disabled">New Mexico</option>
<option value="NY" disabled="disabled">New York</option>
<option value="NC" disabled="disabled">North Carolina</option>
<option value="ND" disabled="disabled">North Dakota</option>
<option value="OH" disabled="disabled">Ohio</option>
<option value="OK" disabled="disabled">Oklahoma</option>
<option value="OR" disabled="disabled">Oregon</option>
<option value="PA" disabled="disabled">Pennsylvania</option>
<option value="RI" disabled="disabled">Rhode Island</option>
<option value="SC" disabled="disabled">South Carolina</option>
<option value="SD" disabled="disabled">South Dakota</option>
<option value="TN" disabled="disabled">Tennessee</option>
<option value="TX" disabled="disabled">Texas</option>
<option value="UT" disabled="disabled">Utah</option>
<option value="VT" disabled="disabled">Vermont</option>
<option value="VA" disabled="disabled">Virginia</option>
<option value="WA" disabled="disabled">Washington</option>
<option value="WV" disabled="disabled">West Virginia</option>
<option value="WI" disabled="disabled">Wisconsin</option>
<option value="WY" disabled="disabled">Wyoming</option>
</select>

<input type="submit" name="submitstate" value="Continue »" />
</form>

<?

}
elseif (isset($_POST['state']))
{
$showform = true;
if ($_POST['submit'])
{		
	if ($_POST['email'] == '') { $noemail = true; $errors = true; }
	elseif (!check_email($_POST['email'])) { $bademail = true; $errors = true; }
	elseif ($_POST['email'] != $_POST['email2']) { $emailmismatch = true; $errors = true; }
	else {
		$check_query = mysql_query("SELECT * FROM members WHERE email = '{$_POST['email']}'") or die(mysql_error());
		if (mysql_num_rows($check_query) > 0) { $emailexists = true; $errors = true; }
	}

	if ($_POST['password'] == '') { $nopassword = true; $errors = true; }
	elseif (strlen($_POST['password']) <  { $shortpass = true; $errors = true; }
	elseif ($_POST['password'] != $_POST['password2']) { $passwordmismatch = true; $errors = true; }

	if ($_POST['firstname'] == '') { $nofirstname = true; $errors = true; }
	if ($_POST['lastname'] == '') { $nolastname = true; $errors = true; }

	if ($_POST['gender'] == '') { $nogender = true; $errors = true; }

	if (($_POST['birthday_month'] == '') || ($_POST['birthday_day'] == '') || ($_POST['birthday_year'] == '')) { $nobirthdate = true; $errors = true; }

	if ($_POST['address1'] == '') { $noaddress = true; $errors = true; }
	if ($_POST['city'] == '') { $nocity = true; $errors = true; }
	if ($_POST['state'] == '') { $nostate = true; $errors = true; }
	if ($_POST['zip'] == '') { $nozip = true; $errors = true; }
	if ($_POST['county'] == '') { $nocounty = true; $errors = true; }

	if ($_POST['phone'] == '') { $nophone = true; $errors = true; }
	elseif ((!is_numeric(str_replace("-","",$_POST['phone']))) || (strlen($_POST['phone']) < 10)) { $invalidphone = true; $errors = true; }

	if (($_POST['alt_phone'] != '') && ((!is_numeric(str_replace("-","",$_POST['alt_phone']))) || (strlen($_POST['alt_phone']) < 10))) { $invalidaltphone = true; $errors = true; }

	if (($_POST['alt_email'] != '') && (!check_email($_POST['alt_email']))) { $invalidaltemail = true; $errors = true; }

	if ($errors == false) {

		if ($_POST['address2'] == '') $address2 = 'NULL';
		else $address2 = "'".$_POST['address2']."'";

		if ($_POST['alt_phone'] == '') $alt_phone = 'NULL';
		else $alt_phone = "'".str_replace("-","",$_POST['alt_phone'])."'";

		if ($_POST['alt_email'] == '') $alt_email = 'NULL';
		else $alt_email = "'".$_POST['alt_email']."'";

		$password = md5($_POST['password']);
		$state = strtolower($_POST['state']);
		$phone = "'".str_replace("-","",$_POST['phone'])."'";

		if (strlen($_POST['birthday_day']) == 1) $birthday_day = "0".$_POST['birthday_day'];
		else $birthday_day = $_POST['birthday_day'];

		$insert_query = mysql_query("INSERT INTO members VALUES('', '{$_POST['email']}', '{$password}', '{$_POST['firstname']}', '{$_POST['lastname']}', {$_POST['gender']}, '{$_POST['birthday_month']}', '{$birthday_day}', '{$_POST['birthday_year']}', '{$_POST['address1']}', {$address2}, '{$_POST['city']}', '{$state}', {$_POST['zip']}, {$_POST['county']}, {$phone}, {$alt_phone}, {$alt_email}, '0', NULL)") or die(mysql_error());
		if ($insert_query) echo success("You have been successfully registered! You may now log in.");

		$showform = false;
	}
	else $showform = true;

}
if ($showform == true) {

?>

<form id="joinform" action="join.php" method="post">
<table border="0" width="100%">
<tr><td colspan="2"><h1>Login Information</h1></td></tr>
<tr><td align="right" width="33%">E-mail Address:</td><td align="left"><input class="input" type="text" name="email" <? if (isset($_POST['email'])) echo 'value="'.$_POST['email'].'"'; ?> /> <img src="images/asterisk.png" /></td></tr>
<? if ($noemail) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Email Address is Required</td></tr>'; ?>
<? if ($bademail) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Email Addresses is not Valid</td></tr>'; ?>
<? if ($emailexists) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Email Addresses is already Registered</td></tr>'; ?>
<tr><td align="right" width="33%">E-mail Address (Again):</td><td align="left"><input class="input" type="text" name="email2" <? if (isset($_POST['email2'])) echo 'value="'.$_POST['email2'].'"'; ?> /> <img src="images/asterisk.png" /></td></tr>
<? if ($emailmismatch) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Email Addresses do not Match</td></tr>'; ?>
<tr><td align="right" width="33%">Password:</td><td align="left"><input class="input" type="password" name="password" /> <img src="images/asterisk.png" /></td></tr>
<? if ($nopassword) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Password is Required</td></tr>'; ?>
<? if ($shortpass) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Password Should be at Least 8 Characters</td></tr>'; ?>
<tr><td align="right" width="33%">Password (Again):</td><td align="left"><input class="input" type="password" name="password2" /> <img src="images/asterisk.png" /></td></tr>
<? if ($passwordmismatch) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Passwords do not Match</td></tr>'; ?>
<tr><td colspan="2"><h1>Personal Information</h1></td></tr>
<tr><td align="right" width="33%">First Name:</td><td align="left"><input class="input" type="text" name="firstname" <? if (isset($_POST['firstname'])) echo 'value="'.$_POST['firstname'].'"'; ?> /> <img src="images/asterisk.png" /></td></tr>
<? if ($nofirstname) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">First Name is Required</td></tr>'; ?>
<tr><td align="right" width="33%">Last Name:</td><td align="left"><input class="input" type="text" name="lastname" <? if (isset($_POST['lastname'])) echo 'value="'.$_POST['lastname'].'"'; ?> /> <img src="images/asterisk.png" /></td></tr>
<? if ($nolastname) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Last Name is Required</td></tr>'; ?>
<tr><td align="right" width="33%">Gender:</td><td align="left"><select class="input" name="gender"><option value=""></option><option value="0"<? if ($_POST['gender'] == "0") echo ' selected="selected"';?>>Male</option><option value="1"<? if ($_POST['gender'] == "1") echo ' selected="selected"';?>>Female</option></select> <img src="images/asterisk.png" /></td></tr>
<? if ($nogender) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Gender is Required</td></tr>'; ?>
<tr><td align="right" width="33%">Birthdate (Month, Day, Year):</td><td align="left">
<select name="birthday_month" class="input" style="width: 100px;">
<option value=""></option>
<option value="01"<? if ($_POST['birthday_month'] == '01') echo ' selected="selected"'; ?>>January</option>
<option value="02"<? if ($_POST['birthday_month'] == '02') echo ' selected="selected"'; ?>>February</option>
<option value="03"<? if ($_POST['birthday_month'] == '03') echo ' selected="selected"'; ?>>March</option>
<option value="04"<? if ($_POST['birthday_month'] == '04') echo ' selected="selected"'; ?>>April</option>
<option value="05"<? if ($_POST['birthday_month'] == '05') echo ' selected="selected"'; ?>>May</option>
<option value="06"<? if ($_POST['birthday_month'] == '06') echo ' selected="selected"'; ?>>June</option>
<option value="07"<? if ($_POST['birthday_month'] == '07') echo ' selected="selected"'; ?>>July</option>
<option value="08"<? if ($_POST['birthday_month'] == '08') echo ' selected="selected"'; ?>>August</option>
<option value="09"<? if ($_POST['birthday_month'] == '09') echo ' selected="selected"'; ?>>September</option>
<option value="10"<? if ($_POST['birthday_month'] == '10') echo ' selected="selected"'; ?>>October</option>
<option value="11"<? if ($_POST['birthday_month'] == '11') echo ' selected="selected"'; ?>>November</option>
<option value="12"<? if ($_POST['birthday_month'] == '12') echo ' selected="selected"'; ?>>December</option>
</select>
<select name="birthday_day" class="input" style="width: 50px;">
<option value=""></option>
<? for ($i = 1; $i<32; $i++) {
echo '<option value='.$i;
if ($_POST['birthday_day'] == $i) echo ' selected="selected"';	
echo '>'.$i.'</option>';
}
?>
</select>
<input name="birthday_year" type="text" class="input" style="width: 45px;" maxlength="4" <? if (isset($_POST['birthday_year'])) echo 'value="'.$_POST['birthday_year'].'"'; ?>/> <img src="images/asterisk.png" />
</td></tr>
<? if ($nobirthdate) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Birthdate is Required</td></tr>'; ?>
<tr><td colspan="2"><h1>Address Information</h1></td></tr>
<tr><td align="right" width="33%">Address 1:</td><td align="left"><input class="input" type="text" name="address1" <? if (isset($_POST['address1'])) echo 'value="'.$_POST['address1'].'"'; ?>/> <img src="images/asterisk.png" /></td></tr>
<? if ($noaddress) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Address is Required</td></tr>'; ?>
<tr><td align="right" width="33%">Address 2:</td><td align="left"><input class="input" type="text" name="address2" <? if (isset($_POST['address2'])) echo 'value="'.$_POST['address2'].'"'; ?>/></td></tr>
<tr><td align="right" width="33%">City:</td><td align="left">
<select name="city" class="input"><option value=""></option>
<?

$city_query = mysql_query("SELECT id, name FROM cities WHERE state = '{$_POST['state']}'") or die(mysql_error());

while ($city = mysql_fetch_array($city_query))
{
echo '<option value="'.$city['id'].'"';
if ($_POST['city'] == $city['id']) echo ' selected="selected"';
echo '>'.$city['name'].'</option>';
}

?>
</select> <img src="images/asterisk.png" />
</td></tr>
<? if ($nocity) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">City is Required</td></tr>'; ?>
<tr><td align="right" width="33%">State:</td><td align="left">

<? if (isset($_POST['state'])) echo '<input type="hidden" name="state" value="'.$_POST['state'].'" />'; ?>

<select class="input" disabled="disabled">
<option value="AL" <? if ($_POST['state'] == 'AL') echo 'selected="selected"'; ?>>AL</option>
<option value="AK" <? if ($_POST['state'] == 'AK') echo 'selected="selected"'; ?>>AK</option>
<option value="AZ" <? if ($_POST['state'] == 'AZ') echo 'selected="selected"'; ?>>AZ</option>
<option value="AR" <? if ($_POST['state'] == 'AR') echo 'selected="selected"'; ?>>AR</option>
<option value="CA" <? if ($_POST['state'] == 'CA') echo 'selected="selected"'; ?>>CA</option>
<option value="CO" <? if ($_POST['state'] == 'CO') echo 'selected="selected"'; ?>>CO</option>
<option value="CT" <? if ($_POST['state'] == 'CT') echo 'selected="selected"'; ?>>CT</option>
<option value="DE" <? if ($_POST['state'] == 'DE') echo 'selected="selected"'; ?>>DE</option>
<option value="DC" <? if ($_POST['state'] == 'DC') echo 'selected="selected"'; ?>>DC</option>
<option value="FL" <? if ($_POST['state'] == 'FL') echo 'selected="selected"'; ?>>FL</option>
<option value="GA" <? if ($_POST['state'] == 'GA') echo 'selected="selected"'; ?>>GA</option>
<option value="HI" <? if ($_POST['state'] == 'HI') echo 'selected="selected"'; ?>>HI</option>
<option value="ID" <? if ($_POST['state'] == 'OD') echo 'selected="selected"'; ?>>ID</option>
<option value="IL" <? if ($_POST['state'] == 'IL') echo 'selected="selected"'; ?>>IL</option>
<option value="IN" <? if ($_POST['state'] == 'IN') echo 'selected="selected"'; ?>>IN</option>
<option value="IA" <? if ($_POST['state'] == 'AI') echo 'selected="selected"'; ?>>IA</option>
<option value="KS" <? if ($_POST['state'] == 'KS') echo 'selected="selected"'; ?>>KS</option>
<option value="KY" <? if ($_POST['state'] == 'KY') echo 'selected="selected"'; ?>>KY</option>
<option value="LA" <? if ($_POST['state'] == 'LA') echo 'selected="selected"'; ?>>LA</option>
<option value="ME" <? if ($_POST['state'] == 'ME') echo 'selected="selected"'; ?>>ME</option>
<option value="MD" <? if ($_POST['state'] == 'MD') echo 'selected="selected"'; ?>>MD</option>
<option value="MA" <? if ($_POST['state'] == 'MA') echo 'selected="selected"'; ?>>MA</option>
<option value="MI" <? if ($_POST['state'] == 'MI') echo 'selected="selected"'; ?>>MI</option>
<option value="MN" <? if ($_POST['state'] == 'MN') echo 'selected="selected"'; ?>>MN</option>
<option value="MS" <? if ($_POST['state'] == 'MS') echo 'selected="selected"'; ?>>MS</option>
<option value="MO" <? if ($_POST['state'] == 'MO') echo 'selected="selected"'; ?>>MO</option>
<option value="MT" <? if ($_POST['state'] == 'MT') echo 'selected="selected"'; ?>>MT</option>
<option value="NE" <? if ($_POST['state'] == 'NE') echo 'selected="selected"'; ?>>NE</option>
<option value="NV" <? if ($_POST['state'] == 'NV') echo 'selected="selected"'; ?>>NV</option>
<option value="NH" <? if ($_POST['state'] == 'NH') echo 'selected="selected"'; ?>>NH</option>
<option value="NJ" <? if ($_POST['state'] == 'NJ') echo 'selected="selected"'; ?>>NJ</option>
<option value="NM" <? if ($_POST['state'] == 'NM') echo 'selected="selected"'; ?>>NM</option>
<option value="NY" <? if ($_POST['state'] == 'NY') echo 'selected="selected"'; ?>>NY</option>
<option value="NC" <? if ($_POST['state'] == 'NC') echo 'selected="selected"'; ?>>NC</option>
<option value="ND" <? if ($_POST['state'] == 'ND') echo 'selected="selected"'; ?>>ND</option>
<option value="OH" <? if ($_POST['state'] == 'OH') echo 'selected="selected"'; ?>>OH</option>
<option value="OK" <? if ($_POST['state'] == 'OK') echo 'selected="selected"'; ?>>OK</option>
<option value="OR" <? if ($_POST['state'] == 'OR') echo 'selected="selected"'; ?>>OR</option>
<option value="PA" <? if ($_POST['state'] == 'PA') echo 'selected="selected"'; ?>>PA</option>
<option value="RI" <? if ($_POST['state'] == 'RI') echo 'selected="selected"'; ?>>RI</option>
<option value="SC" <? if ($_POST['state'] == 'SC') echo 'selected="selected"'; ?>>SC</option>
<option value="SD" <? if ($_POST['state'] == 'SD') echo 'selected="selected"'; ?>>SD</option>
<option value="TN" <? if ($_POST['state'] == 'TN') echo 'selected="selected"'; ?>>TN</option>
<option value="TX" <? if ($_POST['state'] == 'TX') echo 'selected="selected"'; ?>>TX</option>
<option value="UT" <? if ($_POST['state'] == 'UT') echo 'selected="selected"'; ?>>UT</option>
<option value="VT" <? if ($_POST['state'] == 'VT') echo 'selected="selected"'; ?>>VT</option>
<option value="VA" <? if ($_POST['state'] == 'VA') echo 'selected="selected"'; ?>>VA</option>
<option value="WA" <? if ($_POST['state'] == 'WA') echo 'selected="selected"'; ?>>WA</option>
<option value="WV" <? if ($_POST['state'] == 'WV') echo 'selected="selected"'; ?>>WV</option>
<option value="WI" <? if ($_POST['state'] == 'WI') echo 'selected="selected"'; ?>>WI</option>
<option value="WY" <? if ($_POST['state'] == 'WY') echo 'selected="selected"'; ?>>WY</option>
</select> <img src="images/asterisk.png" />


</td></tr>
<? if ($nostate) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">State is Required</td></tr>'; ?>
<tr><td align="right" width="33%">Zip:</td><td align="left"><input class="input" type="text" name="zip" <? if (isset($_POST['zip'])) echo 'value="'.$_POST['zip'].'"'; ?> /> <img src="images/asterisk.png" /></td></tr>
<? if ($nozip) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Zip Code is Required</td></tr>'; ?>

<tr><td align="right" width="33%">County:</td><td align="left">
<select name="county" class="input"><option value=""></option>
<?

$county_query = mysql_query("SELECT id, name FROM counties WHERE state = '{$_POST['state']}'") or die(mysql_error());

while ($county = mysql_fetch_array($county_query))
{
echo '<option value="'.$county['id'].'"';
if ($_POST['county'] == $county['id']) echo ' selected="selected"';
echo '>'.$county['name'].'</option>';
}

?>
</select> <img src="images/asterisk.png" />
</td></tr>
<? if ($nocounty) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">County is Required</td></tr>'; ?>
<tr><td colspan="2"><h1>Contact Information</h1></td></tr>
<tr><td align="right" width="33%">Primary Phone:</td><td align="left"><input class="input" type="text" name="phone" maxlength="12" <? if (isset($_POST['phone'])) echo 'value="'.$_POST['phone'].'"'; ?>/> <img src="images/asterisk.png" /></td></tr>
<? if ($nophone) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Primary Phone is Required</td></tr>'; ?>
<? if ($invalidphone) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Primary Phone is Invalid</td></tr>'; ?>
<tr><td align="right" width="33%">Alternate Phone:</td><td align="left"><input class="input" type="text" name="alt_phone" maxlength="12" <? if (isset($_POST['alt_phone'])) echo 'value="'.$_POST['alt_phone'].'"'; ?>/></td></tr>
<? if ($invalidaltphone) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Alternate Phone is Invalid</td></tr>'; ?>
<tr><td align="right" width="33%">Alternate Email:</td><td align="left"><input class="input" type="text" name="alt_email"  <? if (isset($_POST['alt_email'])) echo 'value="'.$_POST['alt_email'].'"'; ?>/></td></tr>
<? if ($invalidaltemail) echo '<tr><td width="33%"></td><td align="left" style="color: #ff0000;">Alternate Email is Invalid</td></tr>'; ?>
<tr><td colspan="2" align="center"><input style="margin: 10px 0px;" type="image" src="images/join.png" value="Submit" alt="Submit" name="submit"></td></tr>
</table>
</form>
<?
}
}

include 'footer.inc.php';

?>

 

Thanks in advance

Basically, take the image buttons out.

 

Do it the regular way with buttons. See if that works. If it doesn't it's something else with the script and not the image button.

 

If it works, then you have to read up on the nuances of image buttons between FF and IE.....

The HTML specification only requires that the x,y coordinates of an image as a submit button be sent. The browsers that send the value="..." parameter are doing their own thing outside of the HTML specification.

 

The problem concerns what data the submit button sends and has nothing to do with the other form elements, why did you post the following that has nothing to do with the problem -

Right now the post variables are just the form element names like $_POST['zip'] etc..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.