Jump to content


Photo

Quick question. Strange problem?


  • Please log in to reply
1 reply to this topic

#1 spires

spires
  • Members
  • PipPipPip
  • Advanced Member
  • 492 posts

Posted 30 October 2006 - 05:54 PM

Hi,

I have built a loging system, This works fine.
You type in your details, Which POSTs the values back to the same page, checks to see if there in the database, then it registers the sessions and (using a header) sends you to the next page.

However, if i do any php selecting from the database below the form, the sessions DO NOT register.

Has anyone ever seen this before?
If so, why does it do this?

Here is an example of what i mean.
The top section pulls the info out of the database.
This only works if its above the form.
If i use it below the form (Where the variables are) It dont work.
<?php
$cstyle_query = mysql_query("SELECT * FROM choosen_style") or die (mysql_error());
$cstyle_row = mysql_fetch_array($cstyle_query);
$cstyle_id = $cstyle_row['csty_id'];

$style_query = mysql_query("SELECT * FROM styles WHERE sty_id='$cstyle_id'") or die (mysql_error());
$style_row = mysql_fetch_array($style_query);
$style_id = $style_row['sty_id'];
$foot = $style_row['foot'];
$pole2 = $style_row['pole2'];
?>

<form name="form2" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
 	      <div align="center"> <br>
 	        <br>
 	        <br>
 	        <table width="185" height="102" border="0" cellspacing="0" cellpadding="0" background="JPGS/tags/members.jpg">
	       <tr>
           <td valign="middle">
	       <center>
	        <table width="95%" border="0" cellspacing="0" cellpadding="0" bgcolor="#e5eaee">
               <tr>
               <td colspan="3">
		    <div align="center" class="layerText">MEMBERS AREA</div>
		    </td>
               </tr>
               <tr>
               <td class="small2">
		    &nbsp;&nbsp;Login:
		    </td>
               <td colspan="2">
		    <div align="left">
               <input name="username" type="text" size="14" id="username" value="<?php $_POST['username']; ?>">
               </div></td>
               </tr>
               <tr>
               <td class="small2">
		    &nbsp;&nbsp;Password:
		    </td>
               <td colspan="2">
		    <div align="left">
               <input name="password" type="password" size="14" id="password" value="<?php $_POST['password']; ?>">
               </div></td>
               </tr>
               <tr>
               <td colspan="3">
			      
		    <table border="0" cellspacing="0" cellpadding="0">
		    <tr>
		    <td width="112"><a href="forgot_your_password.php" class="link">Forgot your password?</a>
		    </td>
		    <td width="64" valign="middle">
				      
		    <input name="submit_butt" type="submit" value="Submit">
		    </td>
		    </tr>
		    </table>
			      
		    </td>
                </tr>
            </table>
	       </center>
	       </td>
   	       </tr>
 	       </table> 
 	       </div>
		 </form>

            <td height="21" colspan="5" background="JPGS/top_navi/<?php echo $pole2; ?>">
		 </td>
		 </tr>
		 <tr>
		 <td height="30" colspan="5" background="JPGS/footers/<?php echo $foot; ?>">
			
		 <table width="100%" cellspacing="5">
		 <tr>
		 <td width="10">&nbsp;</td>
		 <td>
		 <span class="white">Copyright &copy; 2006 eventindustires.com All Right Reserved.</span>
		 </td>
		 <td align="right">
		 <div align="right"><a href="terms.php" class="white_link">Terms of use</a> <span class="white">- <a href="mailto:info@eventindustries.com" class="white_link">Contact us</a></span> </div>
		  </td>
		  <td width="10">&nbsp;</td>
		  </tr>
		  </table>
		  </td>
		  </tr>
		  <tr>
		  <td width="22" height="27"></td>
		  <td width="363">
		  <p><span class="error">
			 Created by Spires1</span><br>
		  <a href="http://www.spires1.com" target="_blank" class="link">web and graphic design</a></p>
		  </td>
		  <td width="316"></td>
		  <td width="22"></td>

Thanks for any advice.

How to make over $600 a day from AdSense? Discover EXACTLY how he does it in these videos:
http://www.adsense-online.com

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 01 November 2006 - 11:35 AM

It should be fine, so what error occurs when you try this?

<form name="form2" method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
 <div align="center">
  <br>
  <br>
  <br>
  <table width="185" height="102" border="0" cellspacing="0" cellpadding="0" background="JPGS/tags/members.jpg">
   <tr>
    <td valign="middle">
     <center>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" bgcolor="#e5eaee">
       <tr>
        <td colspan="3">
         <div align="center" class="layerText">MEMBERS AREA</div>
        </td>
       </tr>
       <tr>
        <td class="small2">
         &nbsp;&nbsp;Login:
        </td>
        <td colspan="2">
         <div align="left">
          <input name="username" type="text" size="14" id="username" value="<?php $_POST['username']; ?>">
         </div>
        </td>
       </tr>
       <tr>
        <td class="small2">
         &nbsp;&nbsp;Password:
        </td>
        <td colspan="2">
         <div align="left">
          <input name="password" type="password" size="14" id="password" value="<?php $_POST['password']; ?>">
         </div>
        </td>
       </tr>
       <tr>
        <td colspan="3">
         <table border="0" cellspacing="0" cellpadding="0">
          <tr>
           <td width="112"><a href="forgot_your_password.php" class="link">Forgot your password?</a>
           </td>
           <td width="64" valign="middle">
            <input name="submit_butt" type="submit" value="Submit">
           </td>
          </tr>
         </table>
        </td>
       </tr>
      </table>
     </center>
    </td>
   </tr>
  </table> 
 </div>
</form>

<?php
$cstyle_query = mysql_query("SELECT * FROM choosen_style") or die (mysql_error());
$cstyle_row = mysql_fetch_array($cstyle_query);
$cstyle_id = $cstyle_row['csty_id'];

$style_query = mysql_query("SELECT * FROM styles WHERE sty_id='$cstyle_id'") or die (mysql_error());
$style_row = mysql_fetch_array($style_query);
$style_id = $style_row['sty_id'];
$foot = $style_row['foot'];
$pole2 = $style_row['pole2'];
?>

 <td height="21" colspan="5" background="JPGS/top_navi/<?php echo $pole2; ?>">
 </td>
</tr>
<tr>
 <td height="30" colspan="5" background="JPGS/footers/<?php echo $foot; ?>">
  <table width="100%" cellspacing="5">
   <tr>
    <td width="10">&nbsp;
    </td>
    <td>
     <span class="white">Copyright &copy; 2006 eventindustires.com All Right Reserved.</span>
    </td>
    <td align="right">
     <div align="right"><a href="terms.php" class="white_link">Terms of use</a> <span class="white">- <a href="mailto:info@eventindustries.com" class="white_link">Contact us</a></span> </div>
    </td>
    <td width="10">&nbsp;</td>
   </tr>
  </table>
 </td>
</tr>
<tr>
 <td width="22" height="27">
 </td>
 <td width="363">
  <p><span class="error">Created by Spires1</span><br><a href="http://www.spires1.com" target="_blank" class="link">web and graphic design</a>
  </p>
 </td>
 <td width="316"></td>
 <td width="22"></td>

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users