Jump to content

Please Help With Variables And Login


Spartan 117

Recommended Posts

Hello, I am having trouble with echoing the username from a session. I have  a session made like this:

[code]<?php
// username and password sent from signup form
$IAmAdmin=$_POST['IAmAdmin'];
$mypassword=$_POST['mypassword'];

$sql="SELECT * FROM $tbl_name WHERE name='$IAmAdmin' and password ='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("IAmAdmin");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
php?>
[/code]

Here is my echo code:

[code]  <?php
  //Echo: Welcome, Username! Logout Link, or Welcome Guest & Login Link
  $MyName= "Welcome, " $_SESSION['IAmAdmin'] "! <a href="logout.php">Logout</a>";

if (!(isset($_SESSION['IAmAdmin']))) {
          $MyName="&nbsp;&nbsp; <font size=\"1\" face=\"Arial\"> Welcome, Guest! Please <a href=\"http://evgclan.net/index.php?option=com_smf&Itemid=41&action=login\">Login</a> Or <a href=\"http://evgclan.net/index.php?option=com_smf_registration&task=register\">Register</a></font>");
      } 

echo ($MyName);

  ?>[/code]

I get an error on this for some reason: "parse error, unexpected T_VARIABLE" I just want it to echo: Welcome Guest Please Login Or Register if there is no session, but if there is I want it to say, Welcome, USERNAME. Logout_Link

Could somebody please help me?
Link to comment
https://forums.phpfreaks.com/topic/34891-please-help-with-variables-and-login/
Share on other sites

Thank You! I got the username to work without the guest part. But the guest part doesn't work.

I put that right under the part that says: " $MyName= "Welcome, " ...

[code]if (!(isset($_SESSION['IAmAdmin']))) {
          $MyName="&nbsp;&nbsp; <font size=\"1\" face=\"Arial\"> Welcome, Guest! Please <a href=\"http://evgclan.net/index.php?option=com_smf&Itemid=41&action=login\">Login</a> Or <a href=\"http://evgclan.net/index.php?option=com_smf_registration&task=register\">Register</a></font>");
      }  [/code]

Here is the error I get with that:
[quote]Parse error: parse error, unexpected ')' in /mnt/w0000/d07/s24/b02a01ae/www/new/admin/login.php on line 71[/quote]

How do I do this?

Thanks

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.