Jump to content

immanuelx2

Members
  • Posts

    96
  • Joined

  • Last visited

    Never

Posts posted by immanuelx2

  1. 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

  2. I feel that the nav right is a bit off. Maybe it's the border on the left side that seems very incomplete. Or maybe because it's too close to the white div at the left.

     

    The copyright at the bottom seems a little empty if you know what i mean.

     

    Now for some more technical stuff.

    1. Put script tags at the bottom of the document.

    2. Don't use inline CSS. Put them in the CSS file.

    3. Change URLs like http://www.theguiltygeek.com/?article=1033 to http://www.theguiltygeek.com/article/1033 or something like that.

     

    thanks for the tips. What do you mean by the nav right is a bit off? Could you post a screenshot?

    Also, as far as changing the URLs, how could i make them the way you suggested by using $_GET variables in php?

     

    Again thanks for the critique.

  3. I understand the easy way to fetch an array is to use a while loop ex:

     

    while ($row = mysql_fetch_array($query))

     

    However, if I want to use that same array more than once, I should dump it into a separate array like so (correct?):

     

    $tables = array(); 
    $query = mysql_query("...") or die(mysql_error());
        
    while ($row = mysql_fetch_array($query)) 
    $tables[] = $row[0];

     

    That works, however, later down the line when I use the foreach ($tables as $key => $value) loop to populate a select form element, it only uses it's numerical index instead of the index assigned by the query. My question is, how do I maintain the index from the query? (for example $row['id'] or $row['name'] instead of $row[0])

     

    Thanks in advance

  4. I am dealing with 3 tables: users, clubs, and users_clubs

     

    Basically, users_clubs is the linking table (because the multiplicity is many to many both ways)

     

    users:

    id username
    ===========
    1  Jack

     

    clubs:

    id clubname
    ===========
    1  Cool Club
    2  Sweet Club

     

    users_clubs:

    user_id club_id
    ===============
    1       1
    1       2

     

    So my question is, how can i set up the MySQL query to retrieve all of the names of the Clubs that user id 1 is associated with? I came up with this so far but it's no worky :(

     

    SELECT clubs.name
    FROM clubs
    WHERE users_clubs.user_id = $userid AND clubs.id = users_clubs.club_id

     

    I have a feeling I need to use a LEFT or RIGHT join somewhere but I am not sure how to do that.

     

    Thanks in advance and +Reps to all who help!

  5. Hi, im trying to get my pagination links to show up organized like so:

     

    PREV              1 2 3                NEXT

     

    with the PREV floated left and the NEXT floated right, while the 1 2 3 are text-align: center'd... How should I go about it?

     

    This is what I have come up with and it did not work:

     

    .left {float:left;}
    .right {float:right;}
    .center {text-align:center;}
    
    <p class="left">PREV</p>
    <p class="center">1 2 3</p>
    <p class="right">NEXT</p>

     

    any help is appreciated!

  6. I have a mysql database with a user id, email, password all that junk stored...

     

    If a user logs in, currently I have their userid stored as a cookie... I realize this is not safe because anyone can manually add a cookie of someone's user id..

     

    So my question is, should i add a field to the database called "id_hash" or w/e and store the cookie as an md5('userid')? And then just compare that value with the database value stored?

     

    Or is there a better way of storing cookies for user logins..? I currently am not using sessions either and wondering if thats a problem or not...

  7. why does this not work....

     

    setcookie('id', '', time()-60*60*24*2);
    unset($_COOKIE['id']);
    
    echo '<meta http-equiv="refresh" content="5; url='.$_POST['redirect'].'">';
    require 'header.php';
    echo 'You are now logged out! Redirecting...';
    

     

    everything displays correctly but.. that damn cookie is still there

  8. Sometimes the header tag does not run well with sessions and cookies try this instead:

     

    logout.php
    <?php
    setcookie('id', '', time()-60*60*24*2);
    unset($_COOKIE['id']);
    
    echo '<script type=text/javascript>location.href="' . $_POST['redirect'] . '";</script>';
    //header("Location: ".$_POST['redirect']);
    exit;
    ?>
    

     

    boo why don't they fix that? that Jscript creates a back button circle :(

  9. weird, it worked the first time, but now it still doesn't log me out...

     

    login.php:
    <?php
    setcookie('id', $userinfo['id'], time()+60*60*24*31*3 , '/');
    header("Location: " . $_POST['redirect']);
    ?>
    
    logout.php
    <?php
    setcookie('id', '', time()-60*60*24*2);
    unset($_COOKIE['id']);
    
    header("Location: ".$_POST['redirect']);
    exit;
    ?>
    

  10. Hey guys, I have a login.php page that checks the database vs the post data of the login form, and logs the user in. If successful, I want the page to redirect to the previous page ($redirect I have set to $_SERVER['REQUEST_URI'] from the previous page..) anyway... How can i have my page redirect after 5 seconds? The following code  does not work:

     

    //header...
    setcookie("id", $userinfo['id'] , time()+60*60*24*31*3 , "/");
    $delay = 5;
    sleep($delay);
    echo "Redirecting in <b>".$delay."</b> seconds";
    header("Location: " . $_POST['redirect']);
    

     

    Warning: Cannot modify header information - headers already sent by (output started at header.php:7) in login.php on line 17

    Redirecting in 5 seconds

    Warning: Cannot modify header information - headers already sent by (output started at header.php:7) in login.php on line 21

     

    Is there a way I can achieve this redirect after the </head> tag is closed?

  11. echo '<a href="?';
    if ($_GET['sort']) echo 'sort='.$sort.'&';
    if ($_GET['flow']) echo 'flow='.$flow.'&';
    if ($_GET['game_id']) echo 'game_id='.$_GET['game_id'].'&';
    if ($_GET['server_id']) echo 'server_id='.$_GET['server_id'].'&';
    echo 'page='.$pagenext.'">NEXT»</a>';
    

     

    Is there an easier way to construct a link while keeping all the set $_GET values?

  12. $count_query = mysql_query('SELECT COUNT(*) FROM table');
    $getcount = mysql_fetch_row($count_query);
    $count = $getcount['0'];
    
    vs.
    
    $count_query = mysql_query('SELECT * FROM table');
    $count = mysql_num_rows($count_query);
    

    and...

    $query = mysql_query('SELECT * FROM table');
    if (!$query) die(mysql_error());
    
    vs.
    
    $query = mysql_query('SELECT * FROM table') or die(mysql_error());
    

     

    any differences between those scenarios?

×
×
  • 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.