RE: PhP and Java login trouble (can someone help a brother out whom is truely trying to understand?)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have these to independently working scripts. 1 is php, the other is
javascript. For obvious reason, to separate logins are not appropriate.
It has been recommended to make a separate function, not sure how to do
this....
Common sense says, "carry the variable from php to javascripting". I am
clueless on where to look on this common sense solution.

I am 2.5 weeks into this madness. I know when I find the solution, it will
be the one that was biting me on the nose.

I want to learn and understand this, but desperately need help from friends!

I will post the 2 complete code pages below..

Input, suggestion or solutions would truly be appreciated.

The first will be the original code that is javascripting friendly.
The second will be my own php working code.

Number one works fine for loging into a FCKEditor application, but is
failing with phpbb.

Number two works perfectly with phpbb applications and outside php pages
requiring phpbb related session controls, but fails sessions with the
javascripting based FCKEditor.

Sincerely,

Brad

#1  Working php/phpbb code:

<?php
	if(!isset($_SESSION["userid"]))
	{
?>
<form action="/phpbb/login.php" method="post" target="_top">
<table width="200" cellpadding="4" cellspacing="1" border="0"
class="forumline" align="center">
		<tr>
			<th background="images/login_top2.jpg" height="30"
class="thHead" nowrap="nowrap"></th>
		</tr>
		<tr>
			<td class="row1"><table border="0" cellpadding="3"
cellspacing="1" width="100%">
		<tr>
			<td width="11%" align="right"><div
align="left"><span class="gen">Username:</span></div></td>
		</tr>
		<tr>
			<td align="right"><input type="text" class="post"
name="username" size="25" maxlength="40" value="" /></td>
		</tr>
		<tr>
   			<td align="right"><div align="left"><span
class="gen">Password</span></div></td>
		</tr>
		<tr>
			<td align="right"><span class="gen">
<input type="password" class="post" name="password" size="25" maxlength="32"
/>
    :</span></td>
		</tr>
		<tr align="center">
			<td colspan="2"><span class="gen">Log me on
automatically: 
	<input type="checkbox" name="autologin" /></span></td>
		</tr>
		<tr align="center">
			<td colspan="2"><input type="hidden" name="redirect"
value="" /><input type="submit" name="login" class="mainoption value="Log
in" />    </td>
		</tr>
		<tr align="center">
			<td colspan="2"><span class="gensmall"><a
href="forgot_password.php" class="gensmall">I forgot my
password</a></span></td>
		</tr>
	</table>
			</td>
    </tr>
<?php
	}else{
?>
	<tr>
	  <td width="207" height="32" background="images/login_top2.jpg"
class="headerlogout" align="center">
	<table width="100%">
		<tr>
			<td width="30" height="27"></td>
			<td align="left"><a href="javascript:logout()"
class="link1">Log out</a></td>
		</tr>
	</table>
			</td>
    	</tr>
        <tr>	
			<td align="center" class="logincenterbg">
	<table width="88%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td height="10" align="left" class="bluetext"></td>
		</tr>
		<tr>
			<td align="left" class="link2">Welcome : <?php echo
$_SESSION["userid"] ?></td>
		</tr>
		<tr>
			<td height="22" align="left" class="bluetext"></td>
		</tr>
		 <tr>
			<td height="20" align="left"><a class="link1"
href="editaccount.php">Manage Account</a></td>
		</tr>
		<tr>
			<td height="20" align="left"><a class="link1"
href="editprofile.php">Manage Profile</a></td>
		</tr>
	</table>
			</td>
		</tr>
		<tr>
			<td align="left" valign="top"><img
src="images/login_bottom.jpg" width="200" height="8" alt="" /></td>
		</tr>		
	</table>
</form>
<?php
		}
?> 
	</table></td>
		</tr>
		<tr>
			<td height="5"></td>
		</tr>
        <tr>
			<td align="center" valign="top"><table width="211"
border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td><img src="images/contest_top.jpg" width="211" height="36"
alt="" /></td>
        </tr>
        <tr>
            <td><a href="contest.php"><img src="images/contest_middle.jpg"
width="211" height="169" border="0" alt="" /></a></td>
        </tr>
	</table></td>
		</tr>
		<tr>
        	<td height="5"></td>
		</tr>
      <tr>
			<td align="center" valign="top"><table width="211"
border="0" cellspacing="0" cellpadding="0">
      <tr>
            <td><img src="images/review_head.jpg" width="211" height="36"
alt="" /></td>
      </tr>
      <tr>
            <td height="89" align="center" class="reviewbg"><table
width="85%" border="0" cellspacing="0" cellpadding="0">
      <tr>
            <td width="112" height="46" align="left" valign="middle"
class="bluetext2">Read about any beauty product...</td>
            <td width="67" rowspan="2" align="right">&nbsp;</td>
      </tr>
      <tr>
            <td align="right" valign="middle" ><a
href="/rating/index.php"><img border="0" src="images/go_btn2.jpg" width="56"
height="21" alt="" /></a></td>
       </tr>
</table></td>
       </tr>
</table></td>
		</tr>
		<tr>
        	<td height="5"></td>
		</tr>
      <tr>
			<td align="center" valign="top"><table width="210"
border="0" cellspacing="0" cellpadding="0">
      <tr>
            <td><img src="images/photos_top.jpg" width="210" height="39"
alt="" /></td>
      </tr>
      <tr>
            <td align="center" class="photobg"><table width="85%" border="0"
cellspacing="0" cellpadding="0">
      <tr>
            <td height="46" align="left" valign="middle"
class="bluetext2">Add photos to our gallery...</td>
            <td width="83" rowspan="2" align="right"><img
src="images/photo1.jpg" width="83" height="81" alt="" /></td>
      </tr>
      <tr>
            <td align="center" valign="middle" ><a
href="photopost2/index.php"><img src="images/more_btn.jpg" width="59"
height="22" alt=""  border="0" /></a></td>
      </tr>
</table></td>
      </tr>
      <tr>
			<td align="left" valign="top"><img
src="images/photos_bottom.jpg" width="210" height="12"  alt="" /></td>
      </tr>
</table></td>
      </tr>
</table>


#2 Working javascripting, but fails php/phpbb:

	<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><img src="images/right_img.jpg" width="221" height="68" alt=""
/></td>
      </tr>
      <tr>
        <td align="center"><table width="207" border="0" cellspacing="0"
cellpadding="0">
          
            <?php
				if(!isset($_SESSION["userid"]))
				{
				?>
					<tr>
            			<td><img src="images/login_top.jpg"
width="207" height="32" alt="" /></td>
          			</tr>
          			<tr>	
						<td align="center"
class="logincenterbg">
							<form
name="frmlogin" method="post" onsubmit="return validatelogin()">
								<input
type="hidden" name="login" value="">
								<table
width="88%" border="0" cellspacing="0" cellpadding="0">
								  <tr>
									<td
height="22" align="left" class="bluetext">Username : </td>
								  </tr>
								  <tr>
									<td
align="left"><input name="txtusername" type="text" size="25"
class="textfield" /></td>
								  </tr>
								  <tr>
									<td
height="22" align="left" class="bluetext">Password : </td>
								  </tr>
								  <tr>
									<td
align="left"><input name="txtpwd" type="password" size="25"
class="textfield"  /></td>
								  </tr>
								  <tr>
									<td
height="5"></td>
								  </tr>
								  <tr>
									<td
height="25" align="left" valign="top">
	
<input type="image" src="images/login_btn.jpg" title="Login" name="login">
									<a
href="register.php"><img src="images/new_user_btn.jpg" border="0"></a>

	
</td>
								  </tr>
								  <tr>
									<td
height="25" align="left">
									<a
href="forgot_password.php" class="link4">Forgot Password</a>
	
</td>
								  </tr>
								</table>
							</form>
						</td>
					</tr>
					<tr>
						<td align="left"
valign="top"><img src="images/login_bottom.jpg" width="207" height="8"
alt="" /></td>
					  </tr>
				<?php
				}
				else
				{
				?>
					<tr>
            			<td width="207" height="32"
background="images/login_top2.jpg" class="headerlogout" align="center">
						<table width="100%">
							<tr>
								<td
width="30"></td>
								<td
align="left"><a href="javascript:logout()" class="link1">Log out</a></td>
							</tr>
						</table>
</td>
          			</tr>
          			<tr>	
						<td align="center"
class="logincenterbg">
							<table width="88%"
border="0" cellspacing="0" cellpadding="0">
								  <tr>
									<td
height="10" align="left" class="bluetext"></td>
								  </tr>
								  <tr>
									<td
align="left" class="link2">Welcome : <?php echo $_SESSION["userid"] ?></td>
								  </tr>
								  <tr>
									<td
height="22" align="left" class="bluetext"></td>
								  </tr>
								  <tr>
									<td
height="20" align="left"><a class="link1" href="editaccount.php">Manage
Account</a></td>
								  </tr>
								  <tr>
									<td
height="20" align="left"><a class="link1" href="editprofile.php">Manage
Profile</a></td>
								  </tr>
								</table>
</td>
					</tr>
					<tr>
						<td align="left"
valign="top"><img src="images/login_bottom.jpg" width="207" height="8"
alt="" /></td>
					  </tr>
				<?php
				}
				?>         
        </table></td>
      </tr>
      <tr>
        <td height="5"></td>
      </tr>
      
      <tr>
        <td align="center" valign="top"><table width="211" border="0"
cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/contest_top.jpg" width="211" height="36"
alt="" /></td>
          </tr>
          <tr>
            <td><a href="contest.php"><img src="images/contest_middle.jpg"
width="211" height="169" border="0" alt="" /></a></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="5"></td>
      </tr>
      <tr>
        <td align="center" valign="top"><table width="211" border="0"
cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/review_head.jpg" width="211" height="36"
alt="" /></td>
          </tr>
          <tr>
            <td height="89" align="center" class="reviewbg"><table
width="85%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="112" height="46" align="left" valign="middle"
class="bluetext2">Read about any beauty product...</td>
                  <td width="67" rowspan="2" align="right">&nbsp;</td>
                </tr>
                <tr>
                  <td align="right" valign="middle" ><a
href="/rating/index.php"><img border="0" src="images/go_btn2.jpg" width="56"
height="21" alt="" /></a></td>
                </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="5"></td>
      </tr>
      <tr>
        <td align="center" valign="top"><table width="210" border="0"
cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/photos_top.jpg" width="210" height="39"
alt="" /></td>
          </tr>
          <tr>
            <td align="center" class="photobg"><table width="85%" border="0"
cellspacing="0" cellpadding="0">
                <tr>
                  <td height="46" align="left" valign="middle"
class="bluetext2">Add photos to our gallery...</td>
                  <td width="83" rowspan="2" align="right"><img
src="images/photo1.jpg" width="83" height="81" alt="" /></td>
                </tr>
                <tr>
                  <td align="center" valign="middle" ><a
href="photopost2/index.php"><img src="images/more_btn.jpg" width="59"
height="22" alt=""  border="0" /></a></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td align="left" valign="top"><img
src="images/photos_bottom.jpg" width="210" height="12"  alt="" /></td>
          </tr>
        </table></td>
      </tr>
    </table>
<script language="javascript">
	function validatelogin()
	{
		if(document.frmlogin.txtusername.value=="")
		{
			alert("Please Enter Username.");
			document.frmlogin.txtusername.focus();
			return false;
		}
		if(document.frmlogin.txtpwd.value=="")
		{
			alert("Please Enter Password.");
			document.frmlogin.txtpwd.focus();
			return false;
		}
		document.frmlogin.login.value="Success";
		document.frmlogin.action="operation.php?mode=login";
		return true;
	}
	function logout()
	{
		if(window.confirm("Are you sure you want to log out."))
		{
			window.location.href="operation.php?mode=logout";
		}
	}
</script>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux