|
| |||||||||
| Tags: content, function, login, php, scripting language |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| After login content in other function
Hi I am trying to do a php program so that when the user log's in the content should be displayed after it. I have the login script available with me. I am working on the remaining program. The problme is how to display the content in other function after users login. I have posted the code below. Code: <?php
if(isset($_COOKIE['usrname']) || $_COOKIE['passwd']){
$usrname = $_COOKIE['usrname'];
$passwd = $_COOKIE['passwd'];
if ($usrname == "test" && $passwd == "test"){
echo 'cookie logged in<br />';
echo 'Click <a href="logout.php">here</a> to log out';
}
}
if(isset($_POST['submit'])){
$usrname = $_POST['usrname'];
$passwd = $_POST['passwd'];
if ($usrname == "test" && $passwd == "test"){
setcookie("usrname", $usrname, time()+3600, "/");
setcookie("passwd", $passwd, time()+3600, "/");
echo 'logged in<br />';
echo 'Click <a href="logout.php">here</a> to log out';
}
else {
echo 'Log in failed';
}
}
else {
if(!isset($_COOKIE['usrname'])){
echo '<form action="" method="POST">';
echo 'usrname - <input name="usrname" type="text"><br />';
echo 'passwd - <input name="passwd" type="passwd"><br />';
echo '<input name="submit" type="submit" value="Submit"><br />';
echo '</form>';
}
}
?> |
|
#2
| ||||
| ||||
| Re: After login content in other function
Hello You can try this. I am posting you a code just place the content inside this code, I mean to say that this code will appear like a wrapper to your content. Code: if(isset($_POST['submit'])){
$usrname = $_POST['usrname'];
$passwd = $_POST['passwd'];
if ($usrname == "test" && $passwd == "test"){
setcookie("usrname", $usrname, time()+3600, "/");
setcookie("passwd", $passwd, time()+3600, "/");
echo 'logged in<br />';
echo 'Click <a href="logout.php">here</a> to log out';
} |
|
#3
| |||
| |||
| Re: After login content in other function
Hi Thanks for you reply and the part of code. Code: if(isset($_POST['submit'])){
$usrname = $_POST['usrname'];
$passwd = $_POST['passwd'];
if ($usrname == "test" && $passwd == "test"){
setcookie("usrname", $usrname, time()+3600, "/");
setcookie("passwd", $passwd, time()+3600, "/");
echo 'logged in<br />';
echo 'Click <a href="logout.php">here</a> to log out';
} Code: unexpected "<" |
|
#4
| ||||
| ||||
| Re: After login content in other function
Hi Ok, I am posting you an entire code, just go through it, may help you Code: <?php
if(isset($_COOKIE['usrname']) || $_COOKIE['passwd']){
$usrname = $_COOKIE['usrname'];
$passwd = $_COOKIE['passwd'];
if ($usrname == "test" && $passwd == "test"){
echo 'cookie logged in<br />';
echo 'Click <a href="logout.php">here</a> to log out';
}
}
if(isset($_POST['submit'])){
$usrname = $_POST['usrname'];
$passwd = $_POST['passwd'];
if ($usrname == "test" && $passwd == "test"){
setcookie("usrname", $usrname, time()+3600, "/");
setcookie("passwd", $passwd, time()+3600, "/");
echo 'logged in<br />';
echo 'Click <a href="logout.php">here</a> to log out';
include_once("../config.inc.php");
include_once("../db_connect.php");
$ptitle = "Approve New Lyrics";
$meta_keys = "";
$meta_desc = "";
$selected = "ADMIN";
include("../header.php");
$approve = $_REQUEST['approve'];
$decline = $_REQUEST['decline'];
$item = $_REQUEST['item'];
if($approve) {
$get_info = mysql_query("SELECT * FROM pendinglyrics WHERE id = ".$item." LIMIT 1");
$artist = mysql_result($get_info, 0, artist);
$track = mysql_result($get_info, 0, track);
$album = mysql_result($get_info, 0, album);
$lyrics = mysql_result($get_info, 0, lyrics);
$dateadded = mysql_result($get_info, 0, dateadded);
$insert = mysql_query("INSERT INTO tracks (artist, title, album, dateadded) VALUES ('".$artist."', '".$track."', '".$album."', '".$dateadded."')");
if($insert) {
$trackid = mysql_insert_id();
$insert2 = mysql_query("INSERT INTO lyrics (trackid, lyrics) VALUES (".$trackid.", '".formatField($lyrics)."')");
if($insert2) $delete = mysql_query("DELETE FROM pendinglyrics WHERE id = ".$item." LIMIT 1");
}
}
elseif($decline) {
$delete = mysql_query("DELETE FROM pendinglyrics WHERE id = ".$item." LIMIT 1");
}
$pending = mysql_query("SELECT * FROM pendinglyrics ORDER BY dateadded LIMIT 30");
?>
<table width="100%" cellspacing="5" cellpadding="0">
<tr>
<td valign="top">
<?php
echo "<b>Approve New Lyrics:</b><br><br>";
echo "Listed below are all the pending lyrics on the system. Choose the relevant option next to each item to approve or remove the lyrics.<br><br>";
?>
</td>
</tr>
</table>
<?php
echo "<table width='100%' cellspacing='0' cellpadding='0'>";
if(mysql_numrows($pending) > 0) {
$tracker = $start+1;
while($row = mysql_fetch_array($pending)) {
echo "<form method='POST' action='index.php'><input name='item' type='hidden' value='".$row[id]."'><tr><td width='40' align='right'><b>".$tracker.".</b> </td><td class='listingtitle'><b>".$row[track]."</b> by <b>".$row[artist]."</b></td><td rowspan='2' width='150'><input name='approve' value='approve' type='submit'> <input name='decline' value='decline' type='submit'></td></tr></form>";
echo "<tr><td></td><td>".trim(substr(stripslashes($row[lyrics]), 0, 120))."... <a href='viewitem.php?j=".$row[id]."' class='morelink'>view lyrics</a><br><br></td></tr>";
$tracker++;
}
}
else echo "<tr><td><br> <b>There are currently no pending lyrics.</b><br><br></td></tr>";
echo "</table>";
?>
<?php
include("../footer.php");
}
else {
echo 'Log in failed';
}
}
else {
if(!isset($_COOKIE['usrname'])){
echo '<form action="" method="POST">';
echo 'usrname - <input name="usrname" type="text"><br />';
echo 'passwd - <input name="passwd" type="passwd"><br />';
echo '<input name="submit" type="submit" value="Submit"><br />';
echo '</form>';
}
}
?> |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "After login content in other function" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Content blocker blocks content on certain sites with Opera | GiveNTake | Technology & Internet | 5 | 21-06-2011 08:30 AM |
| Login Completely Blocked w/User Profile Service Failed the Login | THNKIT | Vista Help | 7 | 09-02-2011 12:39 AM |
| c# function equivalent to gettime function in javascript | Omaar | Software Development | 4 | 10-03-2010 10:44 PM |
| How does abstract function differs from virtual function? | Maddox G | Software Development | 5 | 29-01-2010 11:32 AM |
| WirelessHD(TM) Announces Publication of Wireless DTCP Content Protection Specification for High Definition Content | Jerome | Web News & Trends | 1 | 27-08-2008 02:21 PM |