php login script not fully working

Discussion in 'PHP' started by caligrafx, Jul 29, 2010.

  1. #1
    I have this login script that works in the back end "admin" but the login.php and the register.php files both come up blank. Could someone please look at this and help me in the right direction to get this working?

    Thanks,
    Adam

    https://p11.secure.hostingprod.com/@racefandiecast.com/ssl/sclogin/login.php

    <?
    require_once('includes/libraries.php');
    /* start the session */
    //session_start();
    header("Cache-control: private"); // IE 6 Fix
    if(stristr($yahoo_store_shell, '@SCLOGIN@')){
    	$da=new DataAccess($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS,$MYSQL_DB);
    	$itemDao=& new ItemDao($da);
    	
    	$url = HOSTING_PATH.$_SERVER['PHP_SELF'];
    	if (stristr($url,"?")) {
    		$urllen = strpos($url,"?");
    		$url = substr($url, 0, $urllen);
    	}
    	
    	echo $login_top;
    	
    	$resetemail = '';
    	if (isset($_GET['em'])) {
    		$resetemail = base64_decode($_GET['em']);
    	}
    	
    	$forgetpw = '';
    	if (isset($_GET['forgetpw'])) {
    		$forgetpw = $_GET['forgetpw'];
    	}
    	echo '<div class="acctHeader">';
    	if(isset($_SESSION["user"])){
    	?>
    	<h1 class="login-h1">My Account</h1>
    	<?
    	}else{
    	?>
    	<h1 class="login-h1">Login</h1>
    	<?
    	}
    	if (!empty($_SESSION['returnLink']) and isset($_SESSION["user"])) {
    		echo '<div class="continueShoppingLink">';
    		if (stristr($_SESSION['returnLink'], 'order.store.yahoo')) {
    			echo '<a href="'. $_SESSION['returnLink'] . '"><img src="'.$continue_checkout_image.'" /></a>';
    		}else{
    			echo '<a href="'.$store_absolute_path. $_SESSION['returnLink'] . '">Continue Shopping</a>';
    		}
    		echo '</div>';
    	}
    	echo "<br clear=\"all\"/></div><div id=\"loginalert\"";
    	if (!$loginerror) {
    		echo " style=\"display:none; visibility:hidden;\"";
    	}
    	echo ">$loginerror</div>";
    	?>
    	<div id="accountinfo">
    	  <table width="100%">
    	    <tr align="left" valign="top">
    	      <?
    	if(isset($_SESSION["user"])){
    		$userObj = $_SESSION["user"];
    	?>
    	<td>
    		<table width="100%">
    			<tr>
    				<td class="light-gray-border" style="padding:5px 0 5px 10px;">
    					<div><b>Name:</b> <?=$userObj['shipFirstName']?> <?=$userObj['shipLastName']?></div>
    					<div><b>E-mail:</b> <?=$userObj['email']?></div>
    					<div><b>Password:</b> Not shown for security reasons</div>
    				</td>
    			</tr>
    			<tr>
    				<td align="left" style="padding-top: 10px">
    					<table width="100%">
    						<tr>
    							<td width="50%" class="light-gray-border">
    								<div class="light-gray-bgcolor">
    									<h2 class="login-h2">Shipping address:</h2>
    								</div>
    								<table style="margin: 10px">
    									<tr>
    										<td>
    											<div><b><?=$userObj['shipFirstName']?> <?=$userObj['shipLastName']?></b></div>
    											<div><?=$userObj['shipAddress1']?></div>
    											<div><?=$userObj['shipAddress2']?></div>
    											<div><?=$userObj['shipCity']?>, <?=$userObj['shipState']?> <?=$userObj['shipZip']?>
    											<div>&nbsp;</div>
    											<div><?=$userObj['shipCountry']?></div>
    											<div><b>Phone:</b> <?=$userObj['shipPhone']?></div>
    										</td>
    									</tr>
    								</table>
    							</td>
    							<td width="1">
    								<img src="<?=$spacer_image?>" width="10" height="1" />
    							</td>
    							<td width="50%" class="light-gray-border">
    								<div class="light-gray-bgcolor">
    									<h2 class="login-h2">Billing address</h2>
    								</div>
    								<table style="margin: 10px">
    									<tr>
    										<td>
    											<div><b><?=$userObj['billFirstName']?> <?=$userObj['billLastName']?></b></div>
    											<div><?=$userObj['billAddress1']?></div>
    											<div><?=$userObj['billAddress2']?></div>
    											<div><?=$userObj['billCity']?>, <?=$userObj['billState']?> <?=$userObj['billZip']?>
    											<div>&nbsp;</div>
    											<div><?=$userObj['billCountry']?></div>
    											<div><b>Phone:</b> <?=$userObj['billPhone']?></div>
    										</td>
    									</tr>
    								</table>
    							</td>
    						</tr>
    					</table>
    				</td>
    			</tr>
    		</table>
    	</td>
    	<?
    	}else{
    	?>
    	<td width="50%" class="form-separator">
    	        <form name="register" method="post" action="<?=$webhosting_dispatcher?>">
    	        <input type="hidden" name="scl_targeturi" value="<?= $webhosting_login ?>" />
    			<input type="hidden" name="scl_erroruri" value="<?= $webhosting_login ?>" />
    	          <table cellpadding="3" cellspacing="3">
    	            <tr>
    	              <td><h2 class="login-h2">Yes, retrieve My Account information</h2></td>
    	            </tr>
    	            <tr>
    	              <td style="padding-bottom: 5px;">If you've shopped with us before,<br /> 
    	              please enter your email address<br /> and password.</td>
    	            </tr>
    	            <?if ($forgetpw != '1') {?>
    	            <tr>
    	              <td class="login-form-tdcells"> Email:<br />
    	                <input size="25" type="text" name="emailAddress" <?=($resetemail) ? "value=\"$resetemail\" " : ""?>/>
    	              </td>
    	            </tr>
    	            <tr>
    	              <td class="login-form-tdcells"> Password:<br />
    	                <input size="25" type="password" name="password" />
    	              </td>
    	            </tr>
    	            <tr>
    	              <td class="login-form-tdcells small-gray-link"><a title="Forgot your password?" href="<?=$webhosting_login?>?forgetpw=1">Forgot your password?</a></td>
    	            </tr>
    	            <tr>
    	              <td><input type="image" src="<?=$signin_image?>" title="Sign In" alt="Sign In" />
    	              <input type="hidden" name="scl_action" value="login" />
    	              </td>
    	            </tr>
    	            <?}else{?>
    	            <tr>
    	              <td>
    			          <input type="hidden" name="scl_action" value="resetPassword" />
    			          <table cellpadding="3" cellspacing="3">
    			            <tr>
    			              <td class="login-form-tdcells">Forgot your password?<br />
    			                Email:<br />
    			                <input type="text" name="resetpw" size="25" />
    			                <br />
    			              </td>
    			            </tr>
    			            <tr>
    			              <td align="right">
    			              <input type="submit" value="Submit" /><br /><br />
    			              <a  title="Back to login" href="<?=$webhosting_login?>" class="accountlinks">&laquo;&nbsp;Back to login</a>
    			              </td>
    			            </tr>
    			          </table>
    			       </td>
    	            </tr>
    	            <?}?>
    	          </table>
    	        </form>
    	      </td>
    	      <td width="50%"><table border="0" cellspacing="3" cellpadding="3" width="80%">
    	        <tr>
    	          <td><h2 class="login-h2">I am a new customer.</h2>
    	          </td>
    	        </tr>
    	        <tr>
    	          <td>By creating an account you will be able to
    	            shop faster, save items, create a wish list, 
    	            create a registry, and keep track of the orders 
    	            you have previously made.<br />
    	        <br />
    	        <a title="REGISTER NOW" href="<?=$webhosting_register?>" class="accountlinks">REGISTER NOW</a></td>
    	        </tr>
    	      </table></td>
    	      <?
    	}
    	?>
    	    </tr>
    	  </table>
    	  <?
    	if(isset($_SESSION["user"])){
    	?>
    	  <div style="padding:10px;" align="center"> <a href="<?=$webhosting_register?>"><img src="<?=$changeinfo_image?>" border="0" title="change my information" /></a>
    	  <?
    	  if ($hasWishlist) {
    	  	?>
    	  	&nbsp;<a href="<?=$wishlist_store_url?>"><img src="<?=$wishlist_view?>" border="0" title="view my wishlist" /></a>
    	  	<?php
    	  }
    	  ?>
    	  </div>
    	  <?php
    	}
    	?>
    	</div>
    	<?
    	if ($hasOrderHistory) {
    		include('orderhistory/orderhistoryInc.php');
    	}
    	if ($hasGiftReminder) {
    		include('giftreminder/giftRemindersInc.php');
    	}
    	echo $login_bottom;
    }else{
    	echo $yahoo_store_shell;
    }
    ?>
    Code (markup):

     
    caligrafx, Jul 29, 2010 IP
  2. MakZF

    MakZF Well-Known Member

    Messages:
    390
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #2
    Try starting the PHP codes off with <?php instead of <?
     
    MakZF, Jul 29, 2010 IP
  3. caligrafx

    caligrafx Active Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    83
    #3
    That does the same exact thing.
     
    caligrafx, Jul 29, 2010 IP
  4. MakZF

    MakZF Well-Known Member

    Messages:
    390
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    140
    #4
    Not in newer versions of PHP afaik. Did you try it?
     
    MakZF, Jul 29, 2010 IP
  5. caligrafx

    caligrafx Active Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    83
    #5
    caligrafx, Jul 29, 2010 IP
  6. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #6
    I just skimmed through your code, but it's hard to tell with just this source alone. Try to add echo statements on each if condition and see if it actually goes in. I'm not sure what $yahoo_store_shell contains. =/
     
    Rainulf, Jul 29, 2010 IP
  7. caligrafx

    caligrafx Active Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    83
    #7
    The $yahoo_store_shell contains all of the database call ups and such. Would you be willing to look at the files for me via ftp! I will pm you the username and password if you want!

    Thanks,
    Adam
     
    caligrafx, Jul 30, 2010 IP
  8. pmwow

    pmwow Member

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #8
    Add session_start() function to top line.
     
    pmwow, Aug 2, 2010 IP
  9. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #9
    try uncommenting session_start() here:
    <?
    require_once('includes/libraries.php');
    /* start the session */
    //session_start();

    to like this:
    <?
    require_once('includes/libraries.php');
    /* start the session */
    session_start();
     
    arpit13, Aug 2, 2010 IP
  10. caligrafx

    caligrafx Active Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    83
    #10

    After I removed the to "//" as you suggested, I still have no luck!

    Here is what it looks like;

    <?php
    require_once('includes/libraries.php');
    /* start the session */
    session_start();
    header("Cache-control: private"); // IE 6 Fix
    if(stristr($yahoo_store_shell, '@SCLOGIN@')){
    	$da=new DataAccess($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS,$MYSQL_DB);
    	$itemDao=& new ItemDao($da);
    	
    	$url = HOSTING_PATH.$_SERVER['PHP_SELF'];
    	if (stristr($url,"?")) {
    		$urllen = strpos($url,"?");
    		$url = substr($url, 0, $urllen);
    	}
    	
    	echo $login_top;
    	
    	$resetemail = '';
    	if (isset($_GET['em'])) {
    		$resetemail = base64_decode($_GET['em']);
    	}
    	
    	$forgetpw = '';
    	if (isset($_GET['forgetpw'])) {
    		$forgetpw = $_GET['forgetpw'];
    	}
    	echo '<div class="acctHeader">';
    	if(isset($_SESSION["user"])){
    	?>
    	<h1 class="login-h1">My Account</h1>
    	<?
    	}else{
    	?>
    	<h1 class="login-h1">Login</h1>
    	<?
    	}
    	if (!empty($_SESSION['returnLink']) and isset($_SESSION["user"])) {
    		echo '<div class="continueShoppingLink">';
    		if (stristr($_SESSION['returnLink'], 'order.store.yahoo')) {
    			echo '<a href="'. $_SESSION['returnLink'] . '"><img src="'.$continue_checkout_image.'" /></a>';
    		}else{
    			echo '<a href="'.$store_absolute_path. $_SESSION['returnLink'] . '">Continue Shopping</a>';
    		}
    		echo '</div>';
    	}
    	echo "<br clear=\"all\"/></div><div id=\"loginalert\"";
    	if (!$loginerror) {
    		echo " style=\"display:none; visibility:hidden;\"";
    	}
    	echo ">$loginerror</div>";
    	?>
    	<div id="accountinfo">
    	  <table width="100%">
    	    <tr align="left" valign="top">
    	      <?
    	if(isset($_SESSION["user"])){
    		$userObj = $_SESSION["user"];
    	?>
    	<td>
    		<table width="100%">
    			<tr>
    				<td class="light-gray-border" style="padding:5px 0 5px 10px;">
    					<div><b>Name:</b> <?=$userObj['shipFirstName']?> <?=$userObj['shipLastName']?></div>
    					<div><b>E-mail:</b> <?=$userObj['email']?></div>
    					<div><b>Password:</b> Not shown for security reasons</div>
    				</td>
    			</tr>
    			<tr>
    				<td align="left" style="padding-top: 10px">
    					<table width="100%">
    						<tr>
    							<td width="50%" class="light-gray-border">
    								<div class="light-gray-bgcolor">
    									<h2 class="login-h2">Shipping address:</h2>
    								</div>
    								<table style="margin: 10px">
    									<tr>
    										<td>
    											<div><b><?=$userObj['shipFirstName']?> <?=$userObj['shipLastName']?></b></div>
    											<div><?=$userObj['shipAddress1']?></div>
    											<div><?=$userObj['shipAddress2']?></div>
    											<div><?=$userObj['shipCity']?>, <?=$userObj['shipState']?> <?=$userObj['shipZip']?>
    											<div>&nbsp;</div>
    											<div><?=$userObj['shipCountry']?></div>
    											<div><b>Phone:</b> <?=$userObj['shipPhone']?></div>
    										</td>
    									</tr>
    								</table>
    							</td>
    							<td width="1">
    								<img src="<?=$spacer_image?>" width="10" height="1" />
    							</td>
    							<td width="50%" class="light-gray-border">
    								<div class="light-gray-bgcolor">
    									<h2 class="login-h2">Billing address</h2>
    								</div>
    								<table style="margin: 10px">
    									<tr>
    										<td>
    											<div><b><?=$userObj['billFirstName']?> <?=$userObj['billLastName']?></b></div>
    											<div><?=$userObj['billAddress1']?></div>
    											<div><?=$userObj['billAddress2']?></div>
    											<div><?=$userObj['billCity']?>, <?=$userObj['billState']?> <?=$userObj['billZip']?>
    											<div>&nbsp;</div>
    											<div><?=$userObj['billCountry']?></div>
    											<div><b>Phone:</b> <?=$userObj['billPhone']?></div>
    										</td>
    									</tr>
    								</table>
    							</td>
    						</tr>
    					</table>
    				</td>
    			</tr>
    		</table>
    	</td>
    	<?
    	}else{
    	?>
    	<td width="50%" class="form-separator">
    	        <form name="register" method="post" action="<?=$webhosting_dispatcher?>">
    	        <input type="hidden" name="scl_targeturi" value="<?= $webhosting_login ?>" />
    			<input type="hidden" name="scl_erroruri" value="<?= $webhosting_login ?>" />
    	          <table cellpadding="3" cellspacing="3">
    	            <tr>
    	              <td><h2 class="login-h2">Yes, retrieve My Account information</h2></td>
    	            </tr>
    	            <tr>
    	              <td style="padding-bottom: 5px;">If you've shopped with us before,<br /> 
    	              please enter your email address<br /> and password.</td>
    	            </tr>
    	            <?if ($forgetpw != '1') {?>
    	            <tr>
    	              <td class="login-form-tdcells"> Email:<br />
    	                <input size="25" type="text" name="emailAddress" <?=($resetemail) ? "value=\"$resetemail\" " : ""?>/>
    	              </td>
    	            </tr>
    	            <tr>
    	              <td class="login-form-tdcells"> Password:<br />
    	                <input size="25" type="password" name="password" />
    	              </td>
    	            </tr>
    	            <tr>
    	              <td class="login-form-tdcells small-gray-link"><a title="Forgot your password?" href="<?=$webhosting_login?>?forgetpw=1">Forgot your password?</a></td>
    	            </tr>
    	            <tr>
    	              <td><input type="image" src="<?=$signin_image?>" title="Sign In" alt="Sign In" />
    	              <input type="hidden" name="scl_action" value="login" />
    	              </td>
    	            </tr>
    	            <?}else{?>
    	            <tr>
    	              <td>
    			          <input type="hidden" name="scl_action" value="resetPassword" />
    			          <table cellpadding="3" cellspacing="3">
    			            <tr>
    			              <td class="login-form-tdcells">Forgot your password?<br />
    			                Email:<br />
    			                <input type="text" name="resetpw" size="25" />
    			                <br />
    			              </td>
    			            </tr>
    			            <tr>
    			              <td align="right">
    			              <input type="submit" value="Submit" /><br /><br />
    			              <a  title="Back to login" href="<?=$webhosting_login?>" class="accountlinks">&laquo;&nbsp;Back to login</a>
    			              </td>
    			            </tr>
    			          </table>
    			       </td>
    	            </tr>
    	            <?}?>
    	          </table>
    	        </form>
    	      </td>
    	      <td width="50%"><table border="0" cellspacing="3" cellpadding="3" width="80%">
    	        <tr>
    	          <td><h2 class="login-h2">I am a new customer.</h2>
    	          </td>
    	        </tr>
    	        <tr>
    	          <td>By creating an account you will be able to
    	            shop faster, save items, create a wish list, 
    	            create a registry, and keep track of the orders 
    	            you have previously made.<br />
    	        <br />
    	        <a title="REGISTER NOW" href="<?=$webhosting_register?>" class="accountlinks">REGISTER NOW</a></td>
    	        </tr>
    	      </table></td>
    	      <?
    	}
    	?>
    	    </tr>
    	  </table>
    	  <?
    	if(isset($_SESSION["user"])){
    	?>
    	  <div style="padding:10px;" align="center"> <a href="<?=$webhosting_register?>"><img src="<?=$changeinfo_image?>" border="0" title="change my information" /></a>
    	  <?
    	  if ($hasWishlist) {
    	  	?>
    	  	&nbsp;<a href="<?=$wishlist_store_url?>"><img src="<?=$wishlist_view?>" border="0" title="view my wishlist" /></a>
    	  	<?php
    	  }
    	  ?>
    	  </div>
    	  <?php
    	}
    	?>
    	</div>
    	<?
    	if ($hasOrderHistory) {
    		include('orderhistory/orderhistoryInc.php');
    	}
    	if ($hasGiftReminder) {
    		include('giftreminder/giftRemindersInc.php');
    	}
    	echo $login_bottom;
    }else{
    	echo $yahoo_store_shell;
    }
    ?>
    Code (markup):
     
    caligrafx, Aug 2, 2010 IP
  11. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #11
    maybe the header coding i.e:
    header("Cache-control: private");
    should go at the top after <?php

    but i am not sure if it will work.

    maybe u can do this-
    
    $da=new DataAccess($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS,$MYSQL_DB);
    
    PHP:
    turn that to:
    
    mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
    mysql_select_db($MYSQL_DB);
    
    PHP:
     
    arpit13, Aug 3, 2010 IP
  12. caligrafx

    caligrafx Active Member

    Messages:
    137
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    83
    #12
    I had no luck with changing this!

    Would anyone be willing to look at this via ftp and see if they could find a problem with the script? I will send the username and password via pm.

    Thanks,
    Adam
     
    caligrafx, Aug 6, 2010 IP