Jump to content

[SOLVED] Mysql + Echo Variable


Hooo

Recommended Posts

Stupid problem indeed, i'm basically trying to echo a name I have grabbed using an array, and put into a variable (Or something like that?)

 

<?php

 

include 'config.php';

include 'opendb.php';

 

session_start();

 

$data = mysql_query("SELECT * FROM Users");

$info = mysql_fetch_array($data) or die(mysql_error());

 

if(isset($_SESSION['usname']))

{

 

?>

 

<html>

<body>

Login Successful<br /><br />

Your name is: <?php echo $info['name']; ?><br /><br />

<a href="http://www.website.com/logout.php">Logout</a>

</body>

</html>

 

<?php

 

}

else

{

 

echo '<meta http-equiv="refresh" content="2;url=index.php">';

 

}

 

?>

 

 

Sorry if this is so stupid, at the moment its coming up on main.php:

 

Login Successful

 

Your name is:

 

Logout

Link to comment
https://forums.phpfreaks.com/topic/171067-solved-mysql-echo-variable/
Share on other sites

<?php

include 'config.php';
include 'opendb.php';

session_start();

$data = mysql_query("SELECT * FROM Users");
$info = mysql_fetch_array($data) or die(mysql_error());

if(isset($_SESSION['usname']))
{
$name = $info['name'];
echo "

<html>
<body>
Login Successful<br /><br />
Your name is: $name ><br /><br />
<a href='logout.php'>Logout</a>
</body>
</html>

"

}
else
{

echo '<meta http-equiv="refresh" content="2;url=index.php">';

}

?>

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.