| | |
Seeion handeling
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
hi shreya,
hope this will help u
php Syntax (Toggle Plain Text)
<? ob_start(); include("../conn.php"); if($_SERVER['REQUEST_METHOD']=="POST" && isset($_POST['rlog'])) { $res="select * from `date_profiles` where email='".mysql_real_escape_string($_POST['login'])."' and password='".mysql_real_escape_string($_POST['pass1'])."'"; $res1=mysql_query($res); $res2=mysql_num_rows($res1); if($res2==0) { echo "invalid user"; } else{ $res="select * from `date_profiles` where email='".$_POST['login']."' and password='".$_POST['pass1']."'"; $res1=mysql_query($res); $row=mysql_fetch_assoc($res1); $id=$row['id']; session_unregister("user_id"); session_register("user_id"); $_SESSION['user_id']=$id; session_unregister("name"); session_register("name"); $_SESSION['name']=$row['fname']; header("location:index.php"); } } ?>
Failure is success if we learn from it
use this code in your application:
And in your next page:
let me know if any error comes....
php Syntax (Toggle Plain Text)
session_start(); //these folllowing lines are after insert query... session_unregister('userid'); session_unregister('password'); session_register('userid'); session_register('password'); $_SESSION['userid']=$_POST['userid']; $_SESSION['uid']=$_POST['password'];
And in your next page:
php Syntax (Toggle Plain Text)
session_start(); echo $_SESSION['userid']; echo $_SESSION['password'];
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
hi,
the above code i posted in inlogin page and in outher page like login succesful u can use sessions like this if user logged in then it will display welcome (username) otherwise it will display
welcome guest
i think its clear now any doubts let us know
the above code i posted in inlogin page and in outher page like login succesful u can use sessions like this
php Syntax (Toggle Plain Text)
<table border="0" cellspacing="0" cellpadding="0"> <? if(isset($_SESSION['user_id']) && isset($_SESSION['name'])) {?> <tr> <td width="113" class="us">Welcome : <?=$_SESSION['name'];?></td> <td width="19"><img src="../images/spacer.gif" width="12" height="1" /></td> <td width="10" bgcolor="#FF9999"><img src="../images/spacer.gif" width="1" height="1" /></td> <td width="12"><img src="../images/spacer.gif" width="12" height="1" /></td> <td width="96"><a href="signout.php" class="signup">LogOut</a></td> </tr> <? }else { ?> <tr> <td height="1" class="us">Welcome : <strong>Guest</strong></td> <td> </td> <td bgcolor="#FF9999"></td> <td> </td> <td><a href="#" class="signup">Sign Up </a></td> </tr> <? } ?> </table>
welcome guest
i think its clear now any doubts let us know
Failure is success if we learn from it
hi shreyasi,
i wrote a script for login which has 2 fields username and password if user is already registered then he will simply login, these two fields are placed at right.php and included in every page and if he is not registered user he will register in registerpage,after completion he will be logged in. so, to avoid confusion fom which the user is logged in i took one hidden value rlog in one right.php,structure is pretty complex becoz i used same table for different modules in my project which may be very confusion for u(i think) based on ur requirement u create your
tables
i wrote a script for login which has 2 fields username and password if user is already registered then he will simply login, these two fields are placed at right.php and included in every page and if he is not registered user he will register in registerpage,after completion he will be logged in. so, to avoid confusion fom which the user is logged in i took one hidden value rlog in one right.php,structure is pretty complex becoz i used same table for different modules in my project which may be very confusion for u(i think) based on ur requirement u create your
tables
Failure is success if we learn from it
![]() |
Other Threads in the PHP Forum
- Previous Thread: sending email
- Next Thread: Multiple type of users
Views: 683 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla jquery limit link login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem procedure query radio ram random recursion regex remote script search select server sessions smash sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web websitecontactform xml youtube






