Php pages

Started on the old forum in November 2009 · view the original in the archive · old links redirect here

9 replies · 527 views · started 17 years ago · 1 min read

4 participants
arnage Lead · 811 posts #1

Please can someone code this right

<?php
	$action = strip_tags(trim($_GET['action']));

function header()
	{
echo '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">
<html>';

}

function footer()
	{
echo '
</body></html>';
}

// INDEX PAGE
if($action == "")
    {
echo header();

echo '<p>...</p>';

echo footer();

	exit();
}

if($action == "friends")
    {
echo header();

echo '
Site Friends<hr/>
<div><a href="http://">link</a></div>
<div>> <a href="http://">link</a></div>';

echo footer();

	exit();
}
?>

When in url write ie http://site.tld/index.php?action=blabla , it does not get Error 404 page, gets something blank... 🙁

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
something else Fellow · 2,296 posts #2

blabla is not a varibile so u would end up with a blank page.... however your not your ending up with a status code 404 error page which means that index.php doesnt exsist

subzero Super moderator Fellow · 3,954 posts #3
<?php 
    $action = strip_tags(trim($_GET['action'])); 

/////////////////////////////////////////////////////

echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"> 
<html>";

 
function footer() 
{ 
echo "</body></html>";
} 
////////////////////////////////////////////////////
// INDEX PAGE 
if($action == "") 
{ 

echo '<p><a href="?action=friends">TRY ME</a></p>'; 

echo footer(); 

    exit(); 
} 

if($action == "friends") 
    { 

echo ' 
Site Friends<hr/> 
<div><a href="http://">link</a></div> 
<div>> <a href="http://">link</a></div>'; 

echo footer(); 

    exit(); 
} 
?>

You don't need to add header() function this will show up all pages

You can use footer() function thou as it will read it thou there...

if you want to be smart try using include("body.php");

then use headers and footer function !!

But you may find a error using the name header to change it to head

like this

<?php 
    $action = strip_tags(trim($_GET['action'])); 

/////////////////////////////////////////////////////
function head() 
{ 
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"> 
<html>";
}
 
function footer() 
{ 
echo "</body></html>";
} 
////////////////////////////////////////////////////
// INDEX PAGE 

if($action == "") 
{
 
head();

echo '<p><a href="?action=friends">TRY ME</a></p>'; 

footer(); 

    exit(); 
} 

if($action == "friends") 
    { 

head();

echo ' 
Site Friends<hr/> 
<div><a href="http://">link</a></div> 
<div>> <a href="http://">link</a></div>'; 

footer(); 

    exit(); 
} 
?>

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

arnage Lead · 811 posts #4

Thanks Something else, thats which is what I feared because the index page is there. Is this a security whole?

Subzero, thanks bro, I use somethong like body.php for other pages because it is with prohibition of anonymous browser, do not whant to forbidd it on index.

Is something like this solution for all variables and if someone can code it ? :

if ("non existent or unvalid variable") { header('HTTP/1.1 404 Not Found'); exit(); }

Or something like......?

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
subzero Super moderator Fellow · 3,954 posts #5

do you want to make a error page ??

like i type link.com?action=admin

it will show

ERROR PAGE NOT FOUND!!

or you want to block hiden browsers ?

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

arnage Lead · 811 posts #6

subzero wrote: do you want to make a error page ??

like i type link.com?action=admin

it will show

ERROR PAGE NOT FOUND!!

or you want to block hiden browsers ?

Yes, just to send browser to classic Not Found page if the requested variable does not exists or is undefined, not to make it my self (thats not itneresting 🙂 ).

Does if(isset) function doing something good for this? 😀

Right now I get just blank page.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
subzero Super moderator Fellow · 3,954 posts #7

DEMO http://chat4u.ath.cx/page/test.php

<?php 
    $action = strip_tags(trim($_GET['action'])); 

/////////////////////////////////////////////////////
function head() 
{ 
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"> 
<html>";
}
 
function footer() 
{ 
echo "</body></html>";
} 
////////////////////////////////////////////////////
// INDEX PAGE 

if($action == "") 
{
 
head();

echo '<p><a href="?action=friends">TRY ME</a></p>'; 

footer(); 

    exit(); 
} 

if($action == "friends") 
    { 

head();

echo ' 
Site Friends<hr/> 
<div><a href="http://">link</a></div> 
<div>> <a href="http://">link</a></div>'; 

footer(); 

    exit(); 
}else{
head();

echo '404 ERROR PAGE'; 

footer(); 

    exit(); 
}

?>

Do you know you can change $action = strip_tags(trim($_GET['action'])); to $_GET[action]

like this

if($_GET[action] == "") {

head();

echo ' TRY ME ';

footer();

exit(); 

}

if($_GET[action] == "friends") {

head();

echo ' Site Friends<hr/> link > link';

footer();

exit(); 

}

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

arnage Lead · 811 posts #8

Thats it bro, with }else{ function is something I need. Maybe better than standard error page.

Thanks! 🙂

And whats the difference with $action = strip_tags(trim($_GET['action'])); and $_GET[action] ?

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
subzero Super moderator Fellow · 3,954 posts #9

Nothing really but the way i did mine if page will load if it had nomal page..

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

joseg Junior · 34 posts #10

Using
funtion head{
$mime = ((stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) ? "application/xhtml+xml" : "text/xhtml");

$charset = "utf-8";

header("content-type:$mime;charset=$charset");

$ret = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" >";
$ret .= "<head>";
$ret .= "<title>title</title>";

return $ret; }
funtion footer{ $ret ="</body>"; $ret .="</html>"; return $ret; }

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close