Page 1 of 1

PHP Echo

Posted: Fri Apr 13, 2007 9:58 am
by enemeth
Hi there ,

got this code here that i need to get the echo "are you sure you want to log out";

to be white !

Code: Select all

<?php
session_start();
if(!isset($_REQUEST['logmeout'])){ 
include 'headermem.php';
    echo "<center>Are you sure you want to logout?</center>"; 
    echo "<center><a href=logout.php?logmeout=true>Yes</a> | 
    <a href=javascript:history.back()>No</a>"; 
include 'footermem.php';
} else { 
    session_destroy(); 
    if(!session_is_registered('username')){ 
$msga = "You are now logged out ! Please come back soon!";
echo "<script langauge=\"javascript\">alert(\"".$msga."\");</script>"; 
    include '../index.php';
    exit();}
    } 
?>
it will not take anything that i try !

anyone can help?

Elaine

Posted: Fri Apr 13, 2007 10:02 am
by guitarlvr
have you tried:

Code: Select all

echo "<center><font color="white">Are you sure you want to logout</font></center>";
Wayne

Posted: Fri Apr 13, 2007 10:02 am
by John Cartwright

Code: Select all

if(!isset($_REQUEST['logmeout'])){
So as long as you don't have ?logmeout=true in the url or post then you should see the confirmation link. Try viewing the source of the html.. you may have some malformed html :wink:

A couple of other things,

- Why are you using $_REQUEST, if you are expecting data from a specific source then use the appropriate super global. i.e. $_GET
- session_is_registered() is deperecated, simply use isset($_SESSION['username'])

Posted: Fri Apr 13, 2007 10:07 am
by enemeth
i got it i did this :

Code: Select all

<?php
session_start();
if(!isset($_REQUEST['logmeout'])){ 
include 'headermem.php';
    echo "<center><font color=white><font face=calligraphic><strong>Are you sure you want to logout?</strong></font></center><br />"; 
    echo "<center><a href=logout.php?logmeout=true>Yes</a> | 
    <a href=javascript:history.back()>No</a>"; 
include 'footermem.php';
} else { 
    session_destroy(); 
    if(!session_is_registered('username')){ 
$msga = "You are now logged out ! Please come back soon!";
echo "<script langauge=\"javascript\">alert(\"".$msga."\");</script>"; 
    include '../index.php';
    exit();}
    } 
?>
Thanks,

Elaine

Posted: Fri Apr 13, 2007 10:15 am
by guitarlvr
This probably doesn't matter but you have two opening <font> tags and one closing:

Code: Select all

echo "<center><font color=white><font face=calligraphic><strong>Are you sure you want to logout?</strong></font></center><br />";
Should it be:

Code: Select all

echo "<center><font color="white" face="calligraphic"><strong>Are you sure you want to logout?</strong></font></center><br />";
Wayne

Posted: Fri Apr 13, 2007 10:18 am
by enemeth
oh thank you , didnt notice that !
so much code , no time to check everything !
thanks, again
Elaine

Posted: Fri Apr 13, 2007 10:21 am
by guitarlvr
enemeth wrote:so much code , no time to check everything !
haha i hear that. Glad to help.

Wayne

Posted: Fri Apr 13, 2007 10:24 am
by enemeth
hey you no something wayne,

i just changed that but one thing i dont no if many will know , mindu they will find out when they do it ! heheh

but this :

Code: Select all

echo "<center><font color="white" face="calligraphic"><strong>Are you sure you want to logout?</strong></font></center><br />";
if you put the "calligraphic"

the " " in there it gives you an error, i just left them out

works all good ;)

ELaine

Posted: Fri Apr 13, 2007 10:38 am
by RobertGonzalez
Try having a look at string handling in the PHP manual. There is a lot to learn there.

What your code should be doing is something like this:

Code: Select all

<?php
session_start();
// Check a positive return, not a negative
if (isset($_GET['logmeout'])) 
{
    session_destroy();

    // I would probably get rid of this, as it really is doing nothing
//    if (!session_is_registered('username'))
//    {
        $msga = "You are now logged out ! Please come back soon!";
        echo "<script langauge=\"javascript\">alert(\"".$msga."\");</script>";
        include '../index.php';
        exit();
//    }
} 
else 
{
    // Include a file
    include 'headermem.php';

    // Echo something out, in white 
    echo '<div style="text-align: center; color:#fff;">Are you sure you want to logout?<br />';
    echo '<a href="logout.php?logmeout=true">Yes</a> | <a href="javascript:history.back();">No</a></div>';
    include 'footermem.php';
}
?>

Posted: Fri Apr 13, 2007 11:10 am
by guitarlvr
It throws an error? I don't think I've ever had that throw an error. Interesting. Everah's way is probably better anyway. If you are using an xhtml page and run it through the xhtml validator it will throw up if you use font. <div>, <span>, and css are the new way of doing things.

Wayne

Posted: Fri Apr 13, 2007 11:14 am
by RobertGonzalez
It throws an error because there are unescaped double quotes inside of a double quoted string.

Posted: Fri Apr 13, 2007 11:22 am
by guitarlvr
I just tested it, came back and everah posted it ;) heres an example:

we had it like this:

Code: Select all

echo "<center><font color="white" face="calligraphic"><strong>Are you sure you want to logout?</strong></font></center><br />";
since the double quote at "white" is there, the echo closes at that first double quote. to get it to work you have to do one of the following:

Code: Select all

echo "<center><font color=\"white\" face=\"calligraphic\"><strong>Are you sure you want to logout?</strong></font></center><br />";
or

Code: Select all

echo '<center><font color="white" face="calligraphic"><strong>Are you sure you want to logout?</strong></font></center><br />';
Thanks everah!

Wayne

Posted: Fri Apr 13, 2007 11:43 am
by RobertGonzalez
You got it. Glad I could help.