Jump to content

dynamic page


lukerodham

Recommended Posts

hey guys stuck on this one cant see why it wont work, hope someone can help. im trying to just change the content not the whole page while still only a admin can see it. if you get my jist. but everytime i click the link nothing shows up for some reason.

 

thanks in advance.

 

<?php 
session_start();
include("login.php"); 
?>
<html>
<body>
<?php
if(isset($_SESSION['user'])){
?>
<table width='90%' height='100%' border='1' align='center'>
  <tr valign='top'>
    <td><table width='60%' border='0' align='center'>
      <tr>
        <td colspan='3' align='center'>You've succesfully logged in.<p></td>
        </tr>
      <tr>
        <td><a href='index.php?page=post.php'>post news</a></td>
        <td><a href='index.php?page=mail.php'>mailing list</a></td>
        <td><a href='index.php?page=stats.php'>site stats</a></td>
	<td><a href='login.php?logout'>logout</a></p></td>
      </tr>
      <tr>
        <td colspan='3'>
<?php
        $page = $_GET['page'];
        if($page){
            include("inc/".$page.".php"); 
        }
?>        
        </td>
        </tr>
    </table></td>
  </tr>
</table>
?>
<?php
}
else {
    die();
}
?>
</body>
</html>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/233210-dynamic-page/
Share on other sites

hmmm strange i echo'd it out and it saying post.php so i guess its working fine, this is the code for the post.php page which im trying to see, could you please tell me if have doing something wrong on there.

 

thanks.

 

<?php
session_start();

if(isset($_SESSION['user'])){
    echo "
    <h1>Post news</h1>
    <hr />
    <form action='post.php' method='post'>
    Title:<br /><input type='text' name='title'> <p>
    Body:<br /><textarea rows='6' cols='35' name='body'></textarea><p>
    <input type='submit' name='post' value='post this'>
    </form>
    ";
    
    if ($_POST['post']){
        
        $title = $_POST['title'];
        $body = $_POST['body'];
        
        if ($title&&$body){
            
            mysql_connect("","","");
            mysql_select_db("") or die(mysql_error());
    
            $date = date("y-m-d");
    
            $insert = mysql_query("INSERT INTO news VALUES ('','$title','$body','$date')") or die(mysql_error());
    
            die("Your news has been posted.");
        }
        else  
        echo "Please fill out title and body<p>";
    }
}
else {
    die("Sorry you dont have access.");
}

?>

Link to comment
https://forums.phpfreaks.com/topic/233210-dynamic-page/#findComment-1199375
Share on other sites

and i think what Pikachu2000 is saying look at your $page code

 

<?php
        $page = $_GET['page'];
        if($page){
            include("inc/".$page.".php"); 
        }
?>        

 

so here is your problem:

$page = $_GET['page']; <== that will get ?page=pagename.php from the url

so your include("inc/".$page.".php"); <= looks like this [include("inc/pagename.php.php");

 

the .php is coming up as .php.php

 

:P

 

either remove the .php from ?page=

or

change include("inc/".$page.".php"); to include("inc/".$page."");

Link to comment
https://forums.phpfreaks.com/topic/233210-dynamic-page/#findComment-1199380
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.