cs1h Posted January 11, 2008 Share Posted January 11, 2008 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 Quote Link to comment Share on other sites More sharing options...
revraz Posted January 11, 2008 Share Posted January 11, 2008 You are starting PHP again, in your echo statement, which is already PHP. Quote Link to comment Share on other sites More sharing options...
adam291086 Posted January 11, 2008 Share Posted January 11, 2008 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"; } ?> Quote Link to comment Share on other sites More sharing options...
cs1h Posted January 11, 2008 Author Share Posted January 11, 2008 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 Quote Link to comment Share on other sites More sharing options...
cs1h Posted January 11, 2008 Author Share Posted January 11, 2008 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 Quote Link to comment Share on other sites More sharing options...
twostars Posted January 11, 2008 Share Posted January 11, 2008 <?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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.