Jump to content

[SOLVED] basic help with hyperlink


chanfuterboy

Recommended Posts

hi, I just want to echo Home | Profile  but i have problem to put it, can someone help me out.

 

<?php

if($_SESSION['userid'])

{echo "Welcome, ".$_SESSION['username']. echo <a href="http://home.php">home</a> "[<a href='logout.php'>Logout</a>]";}

else{?>
				<form name='login' method='POST' onsubmit="loginfn(this);" action="javascript://">
					<label>Username:</label> <input type='text' name='username' value=''/>  
					<label>Password:</label> <input type='password' name='password' value=''/>
					<input type='submit' value='Login'/>
					(<a href='javascript:forgotPassword()'>Forgot Password</a>)
				</form>
				<?php } ?>

 

The hyperlink need to come before the welcome username

Link to comment
Share on other sites

try this:

<?php

if($_SESSION['userid'])
{
echo "Welcome, ".$_SESSION['username'];
echo "<a href="http://home.php">home</a> [<a href='logout.php'>Logout</a>]";
}

else
{
?>
               <form name='login' method='POST' onsubmit="loginfn(this);" action="javascript://">
                  <label>Username:</label> <input type='text' name='username' value=''/>  
                  <label>Password:</label> <input type='password' name='password' value=''/>
                  <input type='submit' value='Login'/>
                  (<a href='javascript:forgotPassword()'>Forgot Password</a>)
               </form>
<?php
}
?>

Link to comment
Share on other sites

In the file that checks the username and password register "logged_in" as "1"

<?php

if($_SESSION['logged_in'] == 1){
echo "Welcome, ".$_SESSION['username']. echo <a href="http://home.php">home</a> "[<a href='logout.php'>Logout</a>]";}

else{ echo '
               <form name="login" method="POST" onsubmit="loginfn(this);" action="javascript://">
                  <label>Username:</label> <input type='text' name='username' value=''/>  
                  <label>Password:</label> <input type="password" name="password" value=''/>
                  <input type="submit" value="Login"/>
                  (<a href="javascript:forgotPassword()">Forgot Password</a>)
               </form>
           ';} ?>

Link to comment
Share on other sites

What is the error message?

Here is the exact script I use on my site.

<?php $name=$_SESSION['username']?>

<?php if ($_SESSION['logged_in'] == 0){include "login.php";}else{echo"Welcome back $name! <br><a href=my_profile.php>My Profile</a><br><a href=logout.php>Log Out</a>";} ?>

Link to comment
Share on other sites

hi,

 

the error was " " on the hyperlink, but in this code below, it keep comming after the welcome, it need to be, before the welcome

 

<?php if($_SESSION['userid'])
{
echo "Welcome, ".$_SESSION['username'];
echo "<a href='http://home.php'>home</a> [<a href='logout.php'>Logout</a>]";
}

else
{
?>
               <form name='login' method='POST' onsubmit="loginfn(this);" action="javascript://">
                  <label>Username:</label> <input type='text' name='username' value=''/>  
                  <label>Password:</label> <input type='password' name='password' value=''/>
                  <input type='submit' value='Login'/>
                  (<a href='javascript:forgotPassword()'>Forgot Password</a>)
               </form>
<?php
}
?>

Link to comment
Share on other sites

Your problem is in the if($_SESSION['userid']),

 

That is the equivalent of saying "if raining I will not go out side, if not I will go out side" you need to say "if ITS raining I will not go out side, if not I will go outside".

 

Try this:

if($_SESSION['userid'] != 0)

Link to comment
Share on other sites

hi,

 

my problem is this two lines

 

{
echo "[<a href='http://home.php'>home</a>]"
echo "Welcome, ".$_SESSION['username' "[<a href='logout.php'>Logout</a>]"

}

 

Home need to come first then welcome username then logout. Not it is a error, can someone help me out i mistaken something

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.