SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Browser cuts off the code

    Hello everybody
    I am new here so please be gentle I am doing a website with login option and it all works perfectly unless I combine the php with the html on one page... When I do it, everything belowsome point in the code is just invisible but when I do it in the Dreamweaver, it all shows fine in the design mode. When I looked at the source code of the website in the browser i noticed something strange: the browser cuts off about a half of my code.
    This is the code:
    Code:
    <body>
    
    <div class="container">
    
    <div class="header">
    <img src="../social.jpg" width="145" height="56" alt="&quot;&quot;" align="right" />
    <!-- end .header --></div>
      <div class="content">
        <div style="width:940px;height:auto;-webkit-border-radius: 20px;-moz-border-radius: 20px;border-radius: 20px;border:3px solid #000000;background-color:#FFFFFF;padding:10px;">
    
    <table>
    <tr><td>
    
    
    <?php
    /**
     * User has already logged in, so display relavent links, including
     * a link to the admin center if the user is an administrator.
     */
    if($session->logged_in){
       echo "<h1>Logged In</h1>";
       echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
           ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] &nbsp;&nbsp;"
           ."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";
       if($session->isAdmin()){
          echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;";
       }
       echo "[<a href=\"process.php\">Logout</a>]";
    }
    else{
    ?>
    <?php
    
    if($form->num_errors > 0){
       echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
    }
    ?>
    
    <form action="process.php" method="post">
    <tr><td>Username:
    This is the point where the browser cuts the code off.


    Code:
    </td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
    <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
    <tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
    <font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;
    <input type="hidden" name="sublogin" value="1">
    <input type="submit" value="Login"></td></tr>
    <tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
    <tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
    </table>
    </form>
    
    <?php
    }
    
    
    echo "</td></tr><tr><td align=\"center\"><br><br>";
    echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
    echo "There are $database->num_active_users registered members and ";
    echo "$database->num_active_guests guests viewing the site.<br><br>";
    
    include("include/view_active.php");
    
    ?>
    
    
    </td></tr>
    </table>
            
            
        
          <!-- end .content --></p>
          <p>&nbsp;</p>
        </div>
      </div>
      <div class="footer"> <div class="content">
        <div style="width:960px;height:auto;-webkit-border-radius: 20px;-moz-border-radius: 20px;border-radius: 20px;border:3px solid #000000;background-color:#FFFFFF;">
          <center><p>Our partners:<br />
          
          </p></center>
          <p><center><a href="http://www.fitnessworld.dk"><img src="../fitmessworld.jpg" alt="Fitness World" width="161" height="60" border="0"/></a><a href="../www.fitness.dk"><img src="../fitnessdk.jpg" alt="fitness.dk" width="109" height="60" border="0" /></a><img src="../stadium.jpg" alt="stadium" width="191" height="65" /><a href="../www.sunset-boulevard.dk"><img src="../sunsetboulevard.jpg" alt="Sunset Boulevard" width="92" height="60" /></a>
          </center></p>
        </div>
        <p><!-- end .footer --></p>
      </div>
      <!-- end .container --></div>
      </div>
    </ body>

    Please guys, help me out because I'm really desperate at this point... Thank you in advance.

  2. #2
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Use error_reporting and it will show you have some issues...

  3. #3
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, but how to do it correctly? I see there are a lot of ways and every website tells something different. I haven't done error_reporting before so please tell me how should it look like and what should show up and where when I do it correctly.

  4. #4
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    http://www.php.net/manual/en/functio...-reporting.php

    This is an example using your code from above:
    Code PHP:
    <?php error_reporting(E_ALL); ?>
    <body>
        <div class="container">

    Which showed me some notices, but gave me a fatal error:

    Code:
    <b>Fatal error</b>:  Call to a member function value() on a non-object in <b>Untitled.php</b> on line <b>45</b><br />
    Added indents to see the error clearer
    Code PHP:
    <tr>
    	<td>Username:</td>
    	<td>
    /* Line 45  */	<input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>">
    	</td>
    	<td><? echo $form->error("user"); ?></td>
    </tr>

    Of course I am going by the code given, which doesn't show an include or require until include("include/view_active.php"); or any other code that is above the <body> tag.

  5. #5
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suspect that below that point you have used PHP short tags, is that the reason? Try using PHP full tag <?PHP.... ?> instead of <?.....?>. As suggested above, use always error reporting ON and all on top of the page.
    PHP Code:
    error_reporting(E_ALL);
    ini_set('display_errors'1);
    // php codes go here.... 
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •