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
https://forums.phpfreaks.com/topic/170686-solved-basic-help-with-hyperlink/
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
}
?>

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>
           ';} ?>

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>";} ?>

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
}
?>

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)

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

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.