Jump to content

PHP & Login Sessions


Deon

Recommended Posts

Hi there,

DW 8.0.2, PHP & mySQL

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

[i] [b]<% if Session("MM_Username") <> "" then %>[/b]

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

[b]<%End If %>[/b]

[b]<% if Session("MM_Username") = "" then %>[/b]

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

[b] <%End If %>[/b]
[/i]

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

Perhaps something like:

[code]<?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 } ?>[/code]
Link to comment
Share on other sites

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

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
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.