FortMyersDrew Posted June 26, 2007 Share Posted June 26, 2007 Alright I have my shout box set up too how i want it and all but i need help on my shoutbox admin <?php //Start the session so you would stay logged in..//must be ABOVE ANY outputsession_start(); //Get the cmd variable$cmd=$_GET['cmd'];$idg=$_GET['id'];?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><title>ACP</title></head><body><?php//include config.phpinclude 'config.php';//get the username from the form and add some security//so you cant get hacked so easy $username = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username'])));$password = md5($_POST['password']);//if login button is pressedif ($_POST['login']){//check if username and password are insertedif((!$username) || (!$password)){//if not tell them to...do insert all of infoecho "Please enter both values<br>";}//when they have we check if the username and the password exists$sql = mysql_query("SELECT * FROM `shoutbox_admin` WHERE `name` = '$username' AND `password`= '$password'") OR die(mysql_error());//so we need to check it for real //mysql_num_rows() counts the rows which are returned as true$login_check = mysql_num_rows($sql);//if the check is true....true = 1 and $login check is set as $login_check=1if($login_check > 0){//so if it is larger than 1 we set some session variables -//username and id$r=mysql_fetch_array($sql);$_SESSION['id'] = $r['id'];$_SESSION['username'] = $r['name'];//if it's not let's make him suffer...moahahahaa...//reload the page I mean.. }else {header("Refresh:2;admin.php");echo 'Go and login <-<';}}//so if session username isn't set show user the login formif(!isset($_SESSION['username'])){?><center><form action='<?=$_SERVER['PHP_SELF']?>' method='POST'>Username: <input type='text' size='15' name='username'><br>Password: <input type='password' size='15' name='password'><br><input name="login" type="submit" value="Submit"></form></center><? }//if not - show him the contents and stuff...else{//welcome message and logout link...echo "<center>Welcome, ". $_SESSION['username'] ."! <a href='logout.php'>Log Out</a></center>";echo "<br><br><center>";//see my ?id= browsing tutorial to understand switch()switch($cmd){default://getting all of the shouts and adding `delete me` link...$result = mysql_query("select * from shoutbox order by id desc"); while($r=mysql_fetch_array($result)) { $name=$r["name"];$message=$r["message"];$time=$r["time"];$id=$r["id"];echo "Shout by: ".$name." <strong>@</strong> ".$time."<br>".$message."<br><a href='?cmd=delete&id=".$id."'>Delete me</a><br><br>";}break;case 'delete':$sql = "DELETE FROM shoutbox WHERE id=".$idg."";$result = mysql_query($sql);header('Refresh:2;admin.php');echo "deleted";};} This is what my friend helped me with but he gave me it like this... and i dont think its working right Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/ Share on other sites More sharing options...
DJTim666 Posted June 26, 2007 Share Posted June 26, 2007 Can you spce out the code a little so we can see it properly. Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283385 Share on other sites More sharing options...
FortMyersDrew Posted June 26, 2007 Author Share Posted June 26, 2007 Yea give me a second Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283392 Share on other sites More sharing options...
FortMyersDrew Posted June 26, 2007 Author Share Posted June 26, 2007 Admin.php <?php //Start the session so you would stay logged in.. //must be ABOVE ANY output session_start(); //Get the cmd variable $cmd=$_GET['cmd']; $idg=$_GET['id']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <title>ACP</title> </head> <body> <?php //include config.php include 'config.php'; //get the username from the form and add some security //so you cant get hacked so easy $username = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username']))); $password = md5($_POST['password']); //if login button is pressed if ($_POST['login']){ //check if username and password are inserted if((!$username) || (!$password)){ //if not tell them to...do insert all of info echo "Please enter both values<br>";} //when they have we check if the username and the password exists $sql = mysql_query("SELECT * FROM `shoutbox_admin` WHERE `name` = '$username' AND `password`= '$password'") OR die(mysql_error()); //so we need to check it for real //mysql_num_rows() counts the rows which are returned as true $login_check = mysql_num_rows($sql); //if the check is true....true = 1 and $login check is set as $login_check=1 if($login_check > 0){ //so if it is larger than 1 we set some session variables - //username and id $r=mysql_fetch_array($sql); $_SESSION['id'] = $r['id']; $_SESSION['username'] = $r['name']; //if it's not let's make him suffer...moahahahaa... //reload the page I mean.. }else { header("Refresh:2;admin.php"); echo 'Go and login <-<'; } } //so if session username isn't set show user the login form if(!isset($_SESSION['username'])){ ?> <center> <form action='<?=$_SERVER['PHP_SELF']?>' method='POST'> Username: <input type='text' size='15' name='username'><br> Password: <input type='password' size='15' name='password'><br> <input name="login" type="submit" value="Submit"> </form></center> <? } //if not - show him the contents and stuff...else{ else{ //welcome message and logout link... echo "<center>Welcome, ". $_SESSION['username'] ."! <a href='logout.php'>Log Out</a></center>"; echo "<br><br><center>"; //see my ?id= browsing tutorial to understand switch() switch($cmd){ default: //getting all of the shouts and adding `delete me` link... $result = mysql_query("select * from shoutbox order by id desc"); while($r=mysql_fetch_array($result)) { $name=$r["name"]; $message=$r["message"]; $time=$r["time"]; $id=$r["id"]; echo "Shout by: ".$name." <strong>@</strong> ".$time."<br>".$message."<br><a href='?cmd=delete&id=".$id."'>Delete me</a><br><br>"; } break; case 'delete': $sql = "DELETE FROM shoutbox WHERE id=".$idg.""; $result = mysql_query($sql); header('Refresh:2;admin.php'); echo "deleted"; } ;} ?> Phew long file but here it is. Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283412 Share on other sites More sharing options...
FortMyersDrew Posted June 26, 2007 Author Share Posted June 26, 2007 Warning: Cannot modify header information - headers already sent by (output started at /home/content/d/r/e/drewsmedia/html/admin.php:16) in /home/content/d/r/e/drewsmedia/html/admin.php on line 44 Go and login <-< I get this error message! Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283416 Share on other sites More sharing options...
FortMyersDrew Posted June 26, 2007 Author Share Posted June 26, 2007 Line 44 header("Refresh:2;admin.php"); Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283418 Share on other sites More sharing options...
FortMyersDrew Posted June 26, 2007 Author Share Posted June 26, 2007 Does anyone know what i should do Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283477 Share on other sites More sharing options...
per1os Posted June 26, 2007 Share Posted June 26, 2007 Do not output any html or data for that matter before the header call, that or make it a META tag or Javascript. Headers can only be sent if no ouput has been sent to the screen, which in that call obviously there is a bunch of output sent to the screen. Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283480 Share on other sites More sharing options...
FortMyersDrew Posted June 26, 2007 Author Share Posted June 26, 2007 wait i dont get it so where should i put that code? <?php //Start the session so you would stay logged in.. //must be ABOVE ANY output session_start(); //Get the cmd variable $cmd=$_GET['cmd']; $idg=$_GET['id']; ?> Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283494 Share on other sites More sharing options...
FortMyersDrew Posted June 26, 2007 Author Share Posted June 26, 2007 Can anyone help me out on this lol Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283508 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 *BUMP* Still Unsolved Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283546 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 <?php //Start the session so you would stay logged in.. //must be ABOVE ANY output session_start(); //Get the cmd variable $cmd=$_GET['cmd']; $idg=$_GET['id']; ?> remove this //Start the session so you would stay logged in.. //must be ABOVE ANY output that will give you the error message about header and dont put white space on the top of session start Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283549 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 I don't know what I am doing wrong but no matter what I delete I am still getting the same error message Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283553 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 to debug comment the session start then run if the same error occur the your declaration headers is the prob pls check note you cannot perform echo or printing if you will have the header function Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283556 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 To tell you the truth i have no idea what any of that means i mean i can provide the code but can you help me out Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283559 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 { header("Refresh:2;admin.php"); echo 'Go and login <-<'; } try to remove the echo like on that ^^ remove the echo Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283562 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 Parse error: parse error, unexpected $ in /home/content/d/r/e/drewsmedia/html/admin.php on line 82 I get that error at line 82 ?> Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283563 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 can see the code Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283564 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 <?php //Start the session so you would stay logged in.. //must be ABOVE ANY output session_start(); //Get the cmd variable $cmd=$_GET['cmd']; $idg=$_GET['id']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <title>ACP</title> </head> <body> <?php //include config.php include 'config.php'; //get the username from the form and add some security //so you cant get hacked so easy $username = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username']))); $password = md5($_POST['password']); //if login button is pressed if ($_POST['login']){ //check if username and password are inserted if((!$username) || (!$password)){ //if not tell them to...do insert all of info echo "Please enter both values<br>";} //when they have we check if the username and the password exists $sql = mysql_query("SELECT * FROM `shoutbox_admin` WHERE `name` = '$username' AND `password`= '$password'") OR die(mysql_error()); //so we need to check it for real //mysql_num_rows() counts the rows which are returned as true $login_check = mysql_num_rows($sql); //if the check is true....true = 1 and $login check is set as $login_check=1 if($login_check > 0){ //so if it is larger than 1 we set some session variables - //username and id $r=mysql_fetch_array($sql); $_SESSION['id'] = $r['id']; $_SESSION['username'] = $r['name']; //if it's not let's make him suffer...moahahahaa... //reload the page I mean.. }else { header("Refresh:2;admin.php"); echo 'Go and login <-<'; } } //so if session username isn't set show user the login form if(!isset($_SESSION['username'])){ ?> <center> <form action='<?=$_SERVER['PHP_SELF']?>' method='POST'> Username: <input type='text' size='15' name='username'><br> Password: <input type='password' size='15' name='password'><br> <input name="login" type="submit" value="Submit"> </form></center> <? } //if not - show him the contents and stuff...else{ else{ //welcome message and logout link... echo "<center>Welcome, ". $_SESSION['username'] ."! <a href='logout.php'>Log Out</a></center>"; echo "<br><br><center>"; //see my ?id= browsing tutorial to understand switch() switch($cmd){ default: //getting all of the shouts and adding `delete me` link... $result = mysql_query("select * from shoutbox order by id desc"); while($r=mysql_fetch_array($result)) { $name=$r["name"]; $message=$r["message"]; $time=$r["time"]; $id=$r["id"]; echo "Shout by: ".$name." <strong>@</strong> ".$time."<br>".$message."<br><a href='?cmd=delete&id=".$id."'>Delete me</a><br><br>"; } break; case 'delete': $sql = "DELETE FROM shoutbox WHERE id=".$idg.""; $result = mysql_query($sql); header('Refresh:2;admin.php'); echo "deleted"; } ;} ?> Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283569 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 <?php session_start(); //Get the cmd variable $cmd=$_GET['cmd']; $idg=$_GET['id']; //include config.php include 'config.php'; //get the username from the form and add some security //so you cant get hacked so easy $username = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username']))); $password = md5($_POST['password']); //if login button is pressed if ($_POST['login']){ //check if username and password are inserted if((!$username) || (!$password)){ //if not tell them to...do insert all of info //echo "Please enter both values<br>"; } //when they have we check if the username and the password exists $sql = mysql_query("SELECT * FROM `shoutbox_admin` WHERE `name` = '$username' AND `password`= '$password'") OR die(mysql_error()); //so we need to check it for real //mysql_num_rows() counts the rows which are returned as true $login_check = mysql_num_rows($sql); //if the check is true....true = 1 and $login check is set as $login_check=1 if($login_check > 0){ //so if it is larger than 1 we set some session variables - //username and id $r=mysql_fetch_array($sql); $_SESSION['id'] = $r['id']; $_SESSION['username'] = $r['name']; //if it's not let's make him suffer...moahahahaa... //reload the page I mean.. }else { header("Refresh:2;admin.php"); exit(); } } //so if session username isn't set show user the login form if(!isset($_SESSION['username'])){ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <title>ACP</title> </head> <body> <center> <form action='<?=$_SERVER['PHP_SELF']?>' method='POST'> Username: <input type='text' size='15' name='username'><br> Password: <input type='password' size='15' name='password'><br> <input name="login" type="submit" value="Submit"> </form></center> <? } //if not - show him the contents and stuff...else{ else{ //welcome message and logout link... echo "<center>Welcome, ". $_SESSION['username'] ."! <a href='logout.php'>Log Out</a></center>"; echo "<br><br><center>"; //see my ?id= browsing tutorial to understand switch() switch($cmd){ default: //getting all of the shouts and adding `delete me` link... $result = mysql_query("select * from shoutbox order by id desc"); while($r=mysql_fetch_array($result)) { $name=$r["name"]; $message=$r["message"]; $time=$r["time"]; $id=$r["id"]; echo "Shout by: ".$name." <strong>@</strong> ".$time."<br>".$message."<br><a href='?cmd=delete&id=".$id."'>Delete me</a><br><br>"; } break; case 'delete': $sql = "DELETE FROM shoutbox WHERE id=".$idg.""; $result = mysql_query($sql); header('Refresh:2;admin.php'); exit(); } } ?> Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283572 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 Try it just like that? Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283573 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 ya and tell me if theres an error Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283575 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 Parse error: parse error, unexpected T_STRING in /home/content/d/r/e/drewsmedia/html/admin.php on line 21 $sql = mysql_query("SELECT * FROM `shoutbox_admin` WHERE `name` = '$username' AND `password`= '$password'") OR die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283576 Share on other sites More sharing options...
teng84 Posted June 27, 2007 Share Posted June 27, 2007 <?php session_start(); //Get the cmd variable $cmd=$_GET['cmd']; $idg=$_GET['id']; //include config.php include 'config.php'; //get the username from the form and add some security //so you cant get hacked so easy $username = mysql_real_escape_string(strip_tags(htmlspecialchars($_POST['username']))); $password = md5($_POST['password']); //if login button is pressed if ($_POST['login']){ //check if username and password are inserted if((!$username) || (!$password)){ //if not tell them to...do insert all of info //echo "Please enter both values"; } //when they have we check if the username and the password exists $sql = mysql_query("SELECT * FROM `shoutbox_admin` WHERE `name` = '$username' AND `password`= '$password'") OR die(mysql_error()); //so we need to check it for real //mysql_num_rows() counts the rows which are returned as true $login_check = mysql_num_rows($sql); //if the check is true....true = 1 and $login check is set as $login_check=1 if($login_check > 0){ //so if it is larger than 1 we set some session variables - //username and id $r=mysql_fetch_array($sql); $_SESSION['id'] = $r['id']; $_SESSION['username'] = $r['name']; //if it's not let's make him suffer...moahahahaa... //reload the page I mean.. }else { header("Refresh:2;admin.php"); exit(); } } //so if session username isn't set show user the login form if(!isset($_SESSION['username'])){ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <title>ACP</title> </head> <body> <center> <form action='<?=$_SERVER['PHP_SELF']?>' method='POST'> Username: <input type='text' size='15' name='username'> Password: <input type='password' size='15' name='password'> <input name="login" type="submit" value="Submit"> </form></center> <? } //if not - show him the contents and stuff...else{ else{ //welcome message and logout link... echo "<center>Welcome, ". $_SESSION['username'] ."! <a href='logout.php'>Log Out[/url]</center>"; echo " <center>"; //see my ?id= browsing tutorial to understand switch() switch($cmd){ default: //getting all of the shouts and adding `delete me` link... $result = mysql_query("select * from shoutbox order by id desc"); while($r=mysql_fetch_array($result)) { $name=$r["name"]; $message=$r["message"]; $time=$r["time"]; $id=$r["id"]; echo "Shout by: ".$name." <strong>@</strong> ".$time." ".$message." <a href='?cmd=delete&id=".$id."'>Delete me[/url] "; } break; case 'delete': $sql = "DELETE FROM shoutbox WHERE id=".$idg.""; $result = mysql_query($sql); header('Refresh:2;admin.php'); exit(); } } ?> that should run cause it works fine on me Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283583 Share on other sites More sharing options...
FortMyersDrew Posted June 27, 2007 Author Share Posted June 27, 2007 alright it works it brings up all the shouts however when i click delete the shout it goes to this Welcome, FortMyersDrew! Log Out[/url] Warning: Cannot modify header information - headers already sent by (output started at /home/content/d/r/e/drewsmedia/html/admin.php:60) in /home/content/d/r/e/drewsmedia/html/admin.php on line 85 However it is deleting the files, but they are all put together like this aaaaaaaaaaaabbbbbbbbbbbbccccccccccccccccdddddddddddddddeeeeeeeeeeeeeeeeffffffffffffffffffgggggggggggggggggggggghhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiiiiiiiijjjjjjjjjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkklllllllllllllllllllllllllllllllll and when i delete one it kicks me off its still coming off line 85 header('Refresh:2;admin.php'); Link to comment https://forums.phpfreaks.com/topic/57324-solved-fixing-my-admin-file-for-my-shout-box/#findComment-283585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.