Jump to content


Photo

PHP & Login Sessions


  • Please log in to reply
5 replies to this topic

#1 Deon

Deon
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 27 May 2006 - 05:03 PM

Hi there,

DW 8.0.2, PHP & mySQL

I use this in my ASP VBScript pages which I got from a NG.

<% if Session("MM_Username") <> "" then %>

<Strong>Welcome <%= Session("MM_Username") %>< /strong><br>
<A HREF="<%= MM_Logout %>">Log Out</A>

<%End If %>

<% if Session("MM_Username") = "" then %>

<form name="form1" method="post" action="<%=MM_LoginAction%>">
<table width="150" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><b>Name:</b>
<input type="text" name="txtName">
</td>
</tr>
<tr>
<td><b>Password:</b>
<input type="password" name="txtPassw">
<br>
<font size="2">
<input type="checkbox" name="checkbox" checked>
remember me<br></font></td>
</tr>
<tr>
<td align="center">
<input type="submit" name="Submit" value="log in &gt;&gt;">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

<%End If %>


This works perfectly well for me. What it does is to welcome a visitor with his/her registrated name once logged in together with a Log out link. The log out is done with DW.
If the visitor is NOT logged in, it presents the visitor with the login form.

How can I accomplich the same with PHP? I will REALLY appreciate your help.

Regards,
Deon


#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 27 May 2006 - 05:07 PM

Perhaps something like:

<?php if ($_SESSION['MM_Username'] != "") { ?>

<Strong>Welcome <?= $_SESSION['MM_Username'] ?>< /strong><br>
<A HREF="<?= $MM_Logout ?>">Log Out</A>

<?php } else {  ?>

<form name="form1" method="post" action="<?=$MM_LoginAction?>">
<table width="150" border="0" cellspacing="0" cellpadding="3">
<tr>
<td><b>Name:</b>
<input type="text" name="txtName">
</td>
</tr>
<tr>
<td><b>Password:</b>
<input type="password" name="txtPassw">
<br>
<font size="2">
<input type="checkbox" name="checkbox" checked>
remember me<br></font></td>
</tr>
<tr>
<td align="center">
<input type="submit" name="Submit" value="log in &gt;&gt;">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

<?php } ?>

~ D Kuang

#3 Deon

Deon
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 27 May 2006 - 05:42 PM

Thank you so much!!! This is exactly 100% what I needed.

Why do I get this message?

Notice: Undefined index: MM_Username in c:\Inetpub\wwwroot\sincro\members\member-login.php on line 277

when not logged in? Apart from this message, your suggestions work 100% and perfectly well.

This is line 277:
<?php if ($_SESSION['MM_Username'] != "") { ?>

Regards,
Deon


#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 27 May 2006 - 06:41 PM

This happens because $_SESSION['MM_Username'] is not defined.

If you defined it indeed, maybe the session is not being passed correctly.
~ D Kuang

#5 xbase

xbase
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 27 May 2006 - 06:42 PM

I noticed that you are using a windows server, please note I have found a lot of severe issues regarding the use of php with IIS

#6 Deon

Deon
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 27 May 2006 - 06:46 PM

Thank you so much to the both of you.

I have uploaded my test files to my server and it works perfectly well. Maybe there is something wrong with the settings/installation of PHP on my testing PC.

Thank you again!

Regards,
Deon





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users