view parameters

sidewalk 06 Dec, 2007
Hi Guys - Great component here!!!!

my client wants the link to the form to be viewable by everyone - but then if you are not logged in he wants the "you must log in..." message. I see no place to set it up this way - can you tell me if it's possible.

When I set the menu item - of course I have the option to make the menu link visible only to "Registered" - but no - that would be toooo easy - he wants the menu item always visible - but if not logged in, you can't use the form.

Thanks for your help! :side:
GreyHead 06 Dec, 2007
Hi sidewalk,

I guess that one way would be to make the form html conditional. In pseudo-code, have the form html like this:
<?php
if ( not-logged in ) {
  echo "Please register";
} else {
  echo form code;
}
?>
Bob
sidewalk 06 Dec, 2007
Hi Bob!

thanks for that - it worked as far as no form appears (yay) but the message "please login..." doesn't appear - it's just blank

any thoughts?:silly:
GreyHead 07 Dec, 2007
Hi sidewalk,

What code have you put in there? Mine was just a sketchy pseudo-code as I've been very busy this afternoon. I'd need to lookup how to check if a user is logged in.

Bob
sidewalk 07 Dec, 2007
Ahhh, well i just copied and pasted what you had there. When you have a moment will you give me the right code - I'm semi code illiterate😉
GreyHead 07 Dec, 2007
Hi sidewalk,

Ok here's a fuller version:
<?php
global $my;
if ( !$my->id ) {
  echo "Please register to access this form.";
} else {
  // paste your form code here
}
Bob
sidewalk 07 Dec, 2007
Hi Bob = thanks for helping me out. I tried it - if I just paste what you have here - when not logged in I can see the "Please register to access this form." so far so good.

But then I pasted my form code in and tested it - when not logged in I get a blank page instead of "Please register to access this form."

Here's my code - am I doing something wrong? Is it the table maybe?

 <?php
global $my;
if ( !$my->id ) {
  echo "Please register to access this form.";
} else {
 <table width="53%" border="0">
  <tr>
    <td><p><strong><font size="+1">Nominate a Colleague</font></strong></p>
      <p>Nominate a colleague to Hamilton's Who's Who online registry using the 
        form below. </p>
     </td>
  </tr>
</table> 
<table BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="500" class="bodytext" >
  <tr VALIGN="top" ALIGN="left"> 
    <td height="30"><font color="#FF0000">* = required</font> </td>
  </tr>
  <tr VALIGN="top" ALIGN="left" height="30"> 
    <td> <P align=right><font size="2" color=red>*</font><font size="2">First 
        Name :     </font></P></td>
    <td><font size="2"> 
      <input NAME="txtFirstName" SIZE="30" MAXLENGTH ="50"  style="WIDTH: 203px; HEIGHT: 22px"  
											 class="RequiredTextBox" VALUE="" >
      </font></td>
  </tr>
  <tr VALIGN="top" ALIGN="left"  height="30"> 
    <td > <P align=right><font size="2">  </font><font size="2" color=red>*</font><font size="2">Last 
        Name :     </font></P></td>
    <td><font size="2"> 
      <input NAME="txtLastName" SIZE="30" MAXLENGTH ="50"  style="WIDTH: 203px; HEIGHT: 22px"   
											class="RequiredTextBox" VALUE="" >
      </font><font size="2" color=red>*</font></td>
  </tr>
  <tr VALIGN="top" ALIGN="left"  height="30" > 
    <td > <P align=right><font size="2">Business Phone # :     </font></P></td>
    <td ><font size="2"> 
      <input NAME="txtBusinessPhone" SIZE="25" MAXLENGTH ="25" VALUE="" >
       Ext.  
      <input NAME="txtBusinessPhoneExt" SIZE="5" MAXLENGTH ="8"   VALUE="" >
      </font></td>
  </tr>
  <tr VALIGN="top" ALIGN="left"  height="30" > 
    <td > <P align=right><font size="2">Home Phone # :     </font></P></td>
    <td ><font size="2"> 
      <input NAME="txtHomePhone" SIZE="25" MAXLENGTH ="25" VALUE="" >
      </font></td>
  </tr>
  <tr VALIGN="top" ALIGN="left"  height="30"> 
    <td> <P align=right><font size="2" color=red>*</font><font size="2">E-mail 
        Address :     </font></P></td>
    <td ><font size="2"> 
      <input NAME="txtEmail" MAXLENGTH="100"  style="LEFT: -1px; WIDTH: 203px; TOP: 1px; HEIGHT: 22px" 
											class="RequiredTextBox" VALUE="" >
      </font></td>
  </tr>
  <tr VALIGN="top" ALIGN="left"  height="30" > 
    <td > <P align=right><font size="2">Profession</font><font size="2"> :     </font></P></td>
    <td ><font size="2"> 
      <input NAME="profession" MAXLENGTH="255"  style="WIDTH: 203px; HEIGHT: 22px"   VALUE="" >
      </font></td>
  </tr>
  <tr  ALIGN="left"  height="30"> 
    <td ALIGN="right" >     </td>
    <td ><input type="submit" name="Submit" value="Submit"></td>
  </tr>
  <tr height="20"> 
    <td ALIGN="center" > </td>
    <td> </td>
  </tr>
</table>
}
GreyHead 07 Dec, 2007
Hi sidewalk,

Sorry, it's one of those days . . . my bad.
 <?php
global $my;
if ( !$my->id ) {
  echo "Please register to access this form.";
} else {
?>
  // paste your form code here
<?php
}
I left out the <?php and ?> tags from around your form code.

Bob<br><br>Post edited by: GreyHead, at: 2007/12/06 21:51
sidewalk 07 Dec, 2007
thanks bob - you are a god!
GreyHead 07 Dec, 2007
Hi sidewalk,

:) . . . today the god of small typos, tomorrow who knows!

Bob
This topic is locked and no more replies can be posted.