forum.coppermine-gallery.net

Support => Older/other versions => cpg1.3.x Support => Topic started by: Justttt on May 07, 2006, 03:37:33 pm

Title: Code Help Please.
Post by: Justttt on May 07, 2006, 03:37:33 pm
hey i have tried to create this code but i get unexpected errors and dont no what am doing wrong could i have a little help pleaseee...

Code: [Select]
<!--loginbox //-->
<?

 if (USER_NAME == Anonymous) {
   print <<< EOT
  ?>     
<TR>
          <TD>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD class=infoBoxHeading height=14><IMG height=14 alt=""
                  src="default_files/corner_right_left.gif" width=11
border=0></TD>
                <TD class=infoBoxHeading width="100%" height=14>Login Here</TD>
                <TD class=infoBoxHeading noWrap height=14><IMG height=14
                  alt="" src="default_files/pixel_trans.gif" width=11
                border=0></TD></TR></TBODY></TABLE>
            <TABLE class=infoBox cellSpacing=0 cellPadding=1 width="100%"
            border=0>
              <TBODY>
              <TR>
                <TD>
                  <TABLE class=infoBoxContents cellSpacing=0 cellPadding=3
                  width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD><IMG height=1 alt=""
                        src="default_files/pixel_trans.gif" width="100%"
                        border=0></TD></TR>
                    <TR>
                      <TD class=boxText align=middle>
 
              <form action="../album/login.php?referer=$referer " method="post" name="loginbox" id="cpgform">
<!-- Start standard table -->
<table  width="16%" cellpadding="0" cellspacing="1" class="maintable">
        <tr>
                <td class="tableh1" colspan="2">User Name </td>
        </tr>
                 
                 
                  <tr>
                        <td class="tableb" width="40%"><input type="text" class="textinput" name="username" style="width: 100%" tabindex="1" /></td>
                  <tr>
                    <td colspan="2" align="center" class="tableb"><div align="left">Password <br>
                      <input type="password" class="textinput" name="password" style="width: 100%" tabindex="2" />
                      Remember me
                      <input name="remember_me" type="checkbox" class="checkbox" value="1" tabindex="3" />                   
                      </div></td>
                  </tr>
</table>

  <INPUT title=" Login "
                              type=image alt=Login
                              src="default_files/button_login.gif" border=0>
</form>
 
                        <br>
                        <table align="center" width="89%" cellspacing="1" cellpadding="0" class="maintable">
       </TABLE></TD></TR>
                    <TR>
                      <TD><IMG height=1 alt=""
                        src="default_files/pixel_trans.gif" width="100%"
                        border=0></TD></TR></TABLE></TD></TR></TABLE></TD></TR>
<? EOT;

} else {
?>

<TR>
          <TD>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD class=infoBoxHeading height=14><IMG height=14 alt=""
                  src="default_files/corner_right_left.gif" width=11
border=0></TD>
                <TD class=infoBoxHeading width="100%" height=14>Welcome</TD>
                <TD class=infoBoxHeading noWrap height=14><IMG height=14
                  alt="" src="default_files/pixel_trans.gif" width=11
                border=0></TD></TR></TBODY></TABLE>
            <TABLE class=infoBox cellSpacing=0 cellPadding=1 width="100%"
            border=0>
              <TBODY>
              <TR>
                <TD>
                  <TABLE class=infoBoxContents cellSpacing=0 cellPadding=3
                  width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD><IMG height=1 alt=""
                        src="default_files/pixel_trans.gif" width="100%"
                        border=0></TD></TR>
                    <TR>
                      <TD class=boxText align=middle>
 
              <br>
 
                        <table align="center" width="89%" cellspacing="1" cellpadding="0" class="maintable">
       </TABLE></TD></TR>
                    <TR>
                      <TD><IMG height=1 alt=""
                        src="default_files/pixel_trans.gif" width="100%"
                        border=0></TD></TR></TABLE></TD></TR></TABLE></TD></TR>
 
   

<? } ?>
<!-- loginbox_eof //-->
Title: Re: Code Help Please.
Post by: Joachim Müller on May 07, 2006, 04:04:05 pm
1) Don't use short tags like <? , but long ones like <?php
2) Either use the heredoc syntax or end php, but not both nor a mixture

You code should look like this:
Code: [Select]
<?php
if (USER_NAME == '') {
   print <<< EOT
<table>
  <tr>
    <td>foo</td>
  </tr>
</table>
EOT;
}
?>
or like this
Code: [Select]
<?php
if (USER_NAME == '') {
?>

<table>
  <tr>
    <td>foo</td>
  </tr>
</table>
<?php
}
?>
However, the constant USER_NAME will probably not be "Anonymous", and checking for strings must be done by putting the content into quotes. Checking for a user not being logged in works differently. This is very basic PHP, you should do some reading - http://www.php.net/manual/en/
There are postings that describe what you need to do to display a login form for visitors who aren't logged in.
Title: Re: Code Help Please.
Post by: Justttt on May 07, 2006, 04:40:44 pm
Thanks Problem Solved ;)