PHP Echo

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
enemeth
Forum Commoner
Posts: 66
Joined: Tue Mar 27, 2007 8:55 am

PHP Echo

Post 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
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

have you tried:

Code: Select all

echo "<center><font color="white">Are you sure you want to logout</font></center>";
Wayne
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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'])
enemeth
Forum Commoner
Posts: 66
Joined: Tue Mar 27, 2007 8:55 am

Post 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
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post 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
enemeth
Forum Commoner
Posts: 66
Joined: Tue Mar 27, 2007 8:55 am

Post by enemeth »

oh thank you , didnt notice that !
so much code , no time to check everything !
thanks, again
Elaine
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post by guitarlvr »

enemeth wrote:so much code , no time to check everything !
haha i hear that. Glad to help.

Wayne
enemeth
Forum Commoner
Posts: 66
Joined: Tue Mar 27, 2007 8:55 am

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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';
}
?>
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

It throws an error because there are unescaped double quotes inside of a double quoted string.
User avatar
guitarlvr
Forum Contributor
Posts: 245
Joined: Wed Mar 21, 2007 10:35 pm

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You got it. Glad I could help.
Post Reply