Hi, I have a login script but need to put some content in so that after the user logs in, it displays the content. Here is the Login code. ...And I need there to be this content on the page after the person log's in. Thanks!
Place your content between here: if(isset($_POST['submit'])){ $username = $_POST['username']; $password = $_POST['password']; if ($username == "test" && $password == "test"){ setcookie("username", $username, time()+3600, "/"); setcookie("password", $password, time()+3600, "/"); echo 'logged in<br />'; echo 'Click <a href="logout.php">here</a> to log out'; } CONTENT GOES HERE, AS THE USER HAS SUCCESSFULLY LOGGED IN PHP:
Hey, Thanks! Just wondering how to insert the content though. When I try to insert that code between where you said it gives an error message (unexpected "<").
Try this: <?php if(isset($_COOKIE['username']) || $_COOKIE['password']){ $username = $_COOKIE['username']; $password = $_COOKIE['password']; if ($username == "test" && $password == "test"){ echo 'cookie logged in<br />'; echo 'Click <a href="logout.php">here</a> to log out'; } } if(isset($_POST['submit'])){ $username = $_POST['username']; $password = $_POST['password']; if ($username == "test" && $password == "test"){ setcookie("username", $username, time()+3600, "/"); setcookie("password", $password, 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['username'])){ echo '<form action="" method="POST">'; echo 'Username - <input name="username" type="text"><br />'; echo 'Password - <input name="password" type="password"><br />'; echo '<input name="submit" type="submit" value="Submit"><br />'; echo '</form>'; } } ?> PHP:
Remove the <?php at the beginning and the ?> at the end of your pasted code. You've already declared it is PHP Script so it script is not expecting you to declare it a second time without first closing the first declaration - hence the "unexpected <". (missed my response by one minute)... What D-Fraz posted should work because I also forgot to mention removing the first two include lines as you've probably included those already.