0

Session is not working.

When user do Sign IN or Sign UP, after that on every page (dashboard.php and configure.php) user email should be displayed.
It is not displaying any error but it is not working.

I have used md5 method for password. I have problem regarding set session.

Let me know IF you have any idea. Thanks a lot in advanced.

//login.php

<?php ?>
<form action="dashboard.php methos="POST">
<table>
    <tr>
    <td> Your email address: </td>
    <td> <input type="text" id="txtEmail" name="txtEmail" value="txtEmail" required="required" /> </td>
    </tr>
    <tr>
    <td> Choose your Password: </td>
    <td> <input type="password" id="pwd" name="pswd" required="required" /> </td>
    </tr>
</table>
<input type="submit" class="btnLogin" value="GO" style="display:inline-block; font-weight:bold; font-size:12px; margin-left:350px;" />
<form>
<?php ?>


// createaccount.php
<form method="post" name="SignUp" action="dashboard.php" onSubmit="return validatenewuser();">                   
                        <div class="divLogin">
                            <table>
                                <tr>
                                    <td> Your email address: </td>
                                    <td> <input type="text" id="txtEmail" name="txtEmail" value="txtEmail" required="required" /> </td>
                                </tr>
                                <tr>
                                    <td> Choose your Password: </td>
                                    <td> <input type="password" id="pwd" name="pswd" required="required" /> </td>
                                </tr>
                                <tr>
                                    <td> Confirm Password: </td>
                                    <td> <input type="password" id="cnfmpwd" name="cnfmpswd" required="required" /> </td>
                                </tr>                    
                            </table>
                        </div>

                        <br /><div id="message">Nothing else required.</div><br />

                        <input type="submit" class="btnLogin" value="OK" style="display:inline-block; font-weight:bold; font-size:12px; margin-left:350px;" />

                    </form>      


// dashboard.php

<?php
    session_start();
?>
<? echo "$txtEmail"; ?>
<div id="dashbox">                           
<input type="button" value="configure">
</div>

// configure.php

<?php
    session_start();
?>
<? echo "$txtEmail"; ?>
<div id="dashbox">                           
<input type="button" value="dashboard">
<input type="button" value="configure">
</div>

Edited by PriteshP23: code

4
Contributors
6
Replies
11
Views
4 Years
Discussion Span
Last Post by PriteshP23
0

you did not save any variable in sessions..how it works..?
did u comparing the email & password from the database..? if yes upload that code snipett that can make easy to find solution for your Problem..

small piece of syntax for sessions here:
page1.php:

session_start();
$_SESSION['name']="varma";

page2.php
session_start();
echo $_SESSION['name'];

it can print the name varma;

if hope it can useful to u buddy..otherwise good practice to me Thank u dude:-)

0

@varma51

Thanks a lot for the reply.

I have already tried this thing in my code. It is not working. I know the syntax for save variable in session. I would be thankful IF one can suggest me the solution which gives result.

In short, i would like to do this WITH SESSION:

There are 4 files.

1.login.php (email and password)
2.createaccount.php ( email and password + confirmpassword )
3.dashboard.php (display users email + 1 button=> configure to go on page )
4.configure.php (display users email + 1 button=> dashboard )

For FULL CODE, you may look at my previous post:

http://www.daniweb.com/web-development/php/threads/446596/session-management-and-login-validation-php

0

@LastMitch

This post id ONLY to solve SESSION part in my code. Previous was along with JS and with more complicated. Both have different output. So, i would like to know the logic behind why it is not working. I have modified my code.

0

Your code above doesn't actually include anything on your sessions? Theres just session_start()? because my guess at the minuete is that there is an error either writing into your session or echoing out of it. I need to see everything concerning the sessions to help on this.

0

I came to know that i have not set SESSION. Now, it is cleared. THANKS A LOT TO ALL OF YOU..!!

<?php
session_start();
$_SESSION['txtEmail'] = $_POST['form_action'];
?>  
<body>
    <table>
                                <tr>
                                    <td> Enter your Email: </td>
                                    <td> <input type="text" id ="form_action" name="form_action" /> </td>
                                </tr>
                                <tr>
                                    <td> Enter your Password:  </td>
                                    <td> <input type="password" id ="pswd" name="pswd" autocomplete="off" /> </td>
                                </tr>                
                            </table>
<input type="hidden" name="login" value="log_me" />
<input type="submit" class="btnLogin" name="form_action2" value="Go" />
</body>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.