0

hello friends,
Help me plz.any body can tell me how to pass a value from one page to another page by using a session. After login page.

Help me plz

login.php

<form name="join" action="check_login.php" method="post" onsubmit="return validate_form(join)">
<table border="0px">
<tr><td align="left">E-mail: </td><td><input type="text" name="email" value="" class="form_field" /></td></tr>
<td>&nbsp;</td>
<tr><td align="left">Password: </td><td><input type="password" name="password" value="" class="form_field" /></td></tr>
<td>&nbsp;</td>
<tr><td></td><td align="right"><span style="width:150px; float:left; font-family:'Times New Roman', Times, serif; color:#CC0000"><a href="join.php">Not a member yet? <em>Register Now</em></a></span><input type="submit" name="submit" value="Login" /></td></tr>
</table><br />

</form>

check_login.php


<?php session_start()?>

<?php
$host="localhost";
$user="root";
$pass="";
$db_name="oma";
$con=mysql_connect($host,$user,$pass) or die(mysql_error());
$sql=mysql_select_db($db_name,$con);


$email=$_POST;
$password=$_POST;

$select="SELECT * FROM users WHERE email='$email' and password='$password'";
$result=mysql_query($select);
if(mysql_num_rows($result) > 0)
{
$_SESSION=$email;
header("location:home.php");
}
else{


header("location:login_wrong.php");

}


?>

6
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by backendcode
0

Read the tutorials as rajarajan07 suggested, but for a quick answer to your question, if you just add

<?php
session_start();
?>

to the top of home.php, you should be able to use the variable $_SESSIOIN. Remember to sanitize the $_POST data before you use it though.


Zagga

0

Note* You should have the session_start() code at the top of every page you intent to use session data with.

0

i think this code help you
First send the variable to a script
<form method="post" action="array_script.php">
0.<br/>
<input type="text" name="first_name"/><br/><br/>

<input type="submit" name="submit"/> </form>
Move $_POST variable contents into $_SESSION
I will always need to call "session_start()" to use $_SESSION

<?php session_start();

$_SESSION = $_POST;

?>

Above I called the the session_start() function, created a session variable, and set that variable the values sent over via POST. Now I can access that $_SESSION variable from any page on my server.
Accessing $_SESSION Variable
I will always need to call "session_start()" to use $_SESSION

<?php session_start();

$first_name = $_SESSION

echo $first_name;

?>

This topic has been dead for over six months. 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.