Jump to content

php include problemos!


andrew_biggart

Recommended Posts

Ok ive been trying to get this to work for days! But is it possible to have this code on a seperate page and use an include on every page you want it in?

 

<?php
$username=$_SESSION['myusername'];
if(isset($_SESSION['myusername'])) {
echo "
   <img alt='' src='../icons/myacc.gif' width='12' height='11' />
   <a class='button6' href='my_profile.php'>My Account</a>
   <img alt='' src='../icons/mypro.gif' width='12' height='11' />
   <a class='button6' href='profile.php?username=$username'>My Profile</a>
   <img alt='' src='../icons/mymes.gif' width='12' height='11' />
   <a class='button6' href='my_profile_messages.php'>My Messages</a>
   <img alt='' src='../icons/myale.gif' width='11' height='11' />
   <a class='button6' href='my_profile_alerts.php'>My Alerts</a>
   <img alt='' src='../icons/myreq.gif' width='12' height='11' />
   <a class='button6' href='my_profile_requests.php'>My Requests</a>
   <img alt='' src='../icons/myfri.gif' width='12' height='11' />
   <a class='button6' href='my_profile_friends.php'>My Friends</a>
   <img alt='' src='../icons/mylog.gif' width='12' height='12' />
   <a class='button6' href='logout.php'>Logout</a>
";
}
else{
echo "
<form method='post' action='check_login.php'>
<table style='float: right'>
<tr>
<td><img alt='' src='../Header_images/login.jpg' width='120' height='18' /></td>
<td><input class='username' name='myusername' type='text' value='Username'/></td>
<td class='logmein'>:Username</td>
<td><input class='password' name='mypassword' type='password' value='Password'/></td>
<td class='logmein'>:Password</td>
<td><input class='submit' name='Submit2' type='submit' value='Cumon in'/><a href='user_register.htm'><input class='register' name='Submit2' type='button' value='Register'/></a></td>
</tr>
</table>	
</form>
";
}
?>

 

So thats the code i want to have on the include page! called navmenu.php

 

and ive been trying this code to try and include it on my test page but its not working.

 

<?php include("navmenu.php"); ?>

 

I am doing something wrong? Thanks in advance

Link to comment
Share on other sites

ok il give you the code and see what u can spot!

 

Required file!

 

<?php
$username=$_SESSION['myusername'];
if(isset($_SESSION['myusername'])) {
echo "
   <img alt='' src='../icons/myacc.gif' width='12' height='11' />
   <a class='button6' href='my_profile.php'>My Account</a>
   <img alt='' src='../icons/mypro.gif' width='12' height='11' />
   <a class='button6' href='profile.php?username=$username'>My Profile</a>
   <img alt='' src='../icons/mymes.gif' width='12' height='11' />
   <a class='button6' href='my_profile_messages.php'>My Messages</a>
   <img alt='' src='../icons/myale.gif' width='11' height='11' />
   <a class='button6' href='my_profile_alerts.php'>My Alerts</a>
   <img alt='' src='../icons/myreq.gif' width='12' height='11' />
   <a class='button6' href='my_profile_requests.php'>My Requests</a>
   <img alt='' src='../icons/myfri.gif' width='12' height='11' />
   <a class='button6' href='my_profile_friends.php'>My Friends</a>
   <img alt='' src='../icons/mylog.gif' width='12' height='12' />
   <a class='button6' href='logout.php'>Logout</a>
";
}
else{
echo "
<form method='post' action='check_login.php'>
<table style='float: right'>
<tr>
<td><img alt='' src='../Header_images/login.jpg' width='120' height='18' /></td>
<td><input class='username' name='myusername' type='text' value='Username'/></td>
<td class='logmein'>:Username</td>
<td><input class='password' name='mypassword' type='password' value='Password'/></td>
<td class='logmein'>:Password</td>
<td><input class='submit' name='Submit2' type='submit' value='Cumon in'/><a href='user_register.htm'><input class='register' name='Submit2' type='button' value='Register'/></a></td>
</tr>
</table>	
</form>
";
}
?>

 

and this is being injected hear!

 

<div id="nav_menu">
<?php require_once("../Includes/navmenu.php"); ?>
</div>

 

and the css im using for the div is

#nav_menu {
width:640px;
height:25px;
background-image:url('../Layout_images/menu_new.gif');
background-repeat:no-repeat;
padding-left:188px;
padding-right:60px;
padding-top:5px;
text-align:right;

}

 

I have been able to include my flash banner and footer successfully i jut cant get this php to work properly! it adds it to the page but 30-40px below where it should be! im not able to use the login form! and it moves the flash banner down with it! How ever when i remove the nav code and keep the flash banner require there the banner is in the correct place!

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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