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
Share on other sites

In the future, post the WHOLE error, with the line.
change: $MyName= "Welcome, " $_SESSION['IAmAdmin'] "! <a href="logout.php">Logout</a>";
to: $MyName= 'Welcome, '.$_SESSION['IAmAdmin'].'! <a href="logout.php">Logout</a>';
Link to comment
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
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.