Jump to content

Recommended Posts

Hi,

 

I have a script that checks to see if someone is logged in or not and then gives one of two possible outcomes if they are or if they are not.

The script is,

 

<?php
if(isset($_COOKIE['loggedin']))
{
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
  <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
      <td><label>
        <input type=\"text\" name=\"one\" id=\"one\" disabled=\"disabled\" value=\"<?php print $_COOKIE['loggedin']; ?>\" />
      </label></td>
    </tr>
  </table>
</form>";
}
else
{
echo "You are not logged in";
}
?>

 

But the problem is that I keep getting this error,

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Inetpub\vhosts\mymymy.com\httpdocs\test_form_check_2.php on line 8

 

I think its because of the second bit of php in the code on line 8 but I don't know how to solve it, can anyone help?

 

Any help is much appreciated,

 

Thanks

Colin

Link to comment
https://forums.phpfreaks.com/topic/85528-solved-help-with-cookies/
Share on other sites

Try this

 

<?php
if(isset($_COOKIE['loggedin']))
{
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
 <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
   <tr>
     <td><label>
       <input type=\"text\" name=\"one\" id=\"one\" disabled=\"disabled\" value=\"$_COOKIE['loggedin']\" />
     </label></td>
   </tr>
 </table>
</form>";
}
else
{
echo "You are not logged in";
}
?>

Hi,

Thanks for the reply, I tried the changes but I'm still getting the same error,

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Inetpub\vhosts\mymymy.com\httpdocs\test_form_check_2.php on line 8

 

Any other ideas?

 

Thanks for the help,

 

Colin

hi,

 

I changed the code to this in the hope that it would work,

 

<?php
if(isset($_COOKIE['loggedin']))
{
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
  <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
      <td><label>
        <input type=\"text\" name=\"one\" id=\"one\" disabled=\"disabled\" value="$_COOKIE['loggedin']" />
      </label></td>
    </tr>
  </table>
</form>";
}
else
{
echo "You are not logged in";
}
?>

 

but I now get the error,

 

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in D:\Inetpub\vhosts\mymymy.com\httpdocs\test_form_check_2.php on line 8

 

Can anyone help?

 

Thanks,

Colin

 

<?php
if(isset($_COOKIE['loggedin']))
{
echo "<form id='form1' name='form1' method='post' action=''>
  <table width='100%' border='0' cellspacing='0' cellpadding='0'>
    <tr>
      <td><label>
        <input type='text' name='one' id='one' value='{$_COOKIE['loggedin']}' disabled />
      </label></td>
    </tr>
  </table>
</form>";
}
else
{
echo "You are not logged in";
}
?>

 

When in doubt, cheat a little.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.