Web Analytics Made Easy -
StatCounter What's wrong with this script? - CodingForum

Announcement

Collapse
No announcement yet.

What's wrong with this script?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • What's wrong with this script?

    Something is wrong with my script, could anyone help me out please?

    Code:
    <?php 
    define('IN_PHPBB',true);
    
    $phpbb_root_path = "./forums/"; // set path to phpBB files 
    include($phpbb_root_path . 'extension.inc'); 
    include($phpbb_root_path . 'common.'.$phpEx); 
    
    // 
    // Start session management 
    // 
    $userdata = session_pagestart($user_ip, PAGE_LOGIN); // initiate session 
    init_userprefs($userdata); // load user prefs 
    // 
    // End session management 
    // 
    $page_title = "RoAR clan :: ACP"; 
    
    // session id check
    if (!empty($HTTP_POST_VARS['sid']) || !empty($_GET['sid']))
    {
    	$sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $_GET['sid'];
    }
    else
    {
    	$sid = '';
    }
    $link = mysql_connect(localhost, MY_USERNAME, MY_PASSWORD); 
    $db = mysql_select_db(forum, $link);
    ?>
    Code:
    <?php
    			  if ($userdata['session_logged_in'] && !isset($_GET['login']) && !isset($_GET['logout']) && !isset($_GET['announce']) && !isset($_GET['submitannounce']) && !isset($_GET['announce2']) && !isset($_GET['delete']) && !isset($_GET['editannouncement'])){
    			  if ($userdata[group_id] = "2"){
    			  //We are admin! WELCOME THEM BACK!
    			  echo"Welcome back to the administrations control panel for the RoAR clans website $userdata[username]!";
    			  //Announcements section
    			  echo"<hr color=#990000><b><u><font color=red>ANNOUNCEMENTS SECTION</u></b><br>- <a href=acp.php?announce=true>Add an announcement</a><br>- <a href=acp.php?announce2=true>Remove/Edit an announcement</a><br>- <a href=index.php>View announcements</a>";
    			  //Downloads section
    			  echo"<hr color=#990000><b><u><font color=red>DOWNLOADS SECTION</u></b><br>- <a href=>Add a download</a><br>- <a href=>Remove/Edit a download</a><br>- <a href=downloads.php>View downloads</a>";
    			  //Members section
    			  echo"<hr color=#990000><b><u><font color=red>MEMBERS SECTION</u></b><br>- <a href=>Add a member</a><br>- <a href=>Remove/Edit a member</a><br>- <a href=members.php>View registered members</a><br>- <a href=>View membership applications</a>";
    			  }
    			  else{
    			  //Not an admin? GET OUT!
    			  echo'You are not an administrator of the RoAR clan! <b><font color="red">GET OUT OF THIS PAGE NOW!</b>';
    			  }
    	}
    	else if (!$userdata['session_logged_in'] && !isset($_GET['login']) && !isset($_GET['logout'])){
    	//Not logged in? Please login!
    	echo'You are currently not logged in! <b><font color="red">LOG IN NOW!</b>';
    	}
    	
    	//----------------------------
    	// ADD ANNOUNCEMENTS SECTION!
    	//----------------------------
    	if ($userdata[group_id] = "2" && isset($_GET['announce']) && !isset($_GET['submitannounce']) && !isset($_GET['delete']) && !isset($_GET['editannouncement'])){
    	$today = date("Y-m-d");
    	echo"Welcome to the administration announcement addition part of the administrative control panel. Lets add a new announcement!<hr color=#990000>";
    	echo"<form action=\"acp.php?submitannounce=true\" method=\"post\"><table>
    	<tr><td>Author:</td><td><input type=\"text\" size=\"30\" name=\"author\" value=\"$userdata[username]\"></td></tr>
    	<tr><td>Date:</td><td><input type=\"text\" size=\"30\" name=\"date\" value=\"$today\"></td></tr>
    	<tr><td>Title:</td><td><input type=\"text\" size=\"30\" name=\"title\"></td></tr>
    	<tr><td>Content:</td><td><textarea size=\"30\" name=\"content\" rows=\"6\" cols=\"40\"></textarea></td></tr>
    	<tr><td>- <a href=\"./acp.php\">Back</a></td><td><input type=\"submit\" value=\"Submit New Announcement\"></td></tr>
    	</table></form>";
    	}
    	if (isset($_GET['submitannounce'])){
    	 if (!$_POST[content]){ 
         echo "Missing CONTENT, please fill out the form again.<br>";
    	 }
         else{
        $query = "INSERT INTO web_announcements (author, date, title, content) VALUES ('$_POST[author]', '$_POST[date]', '$_POST[title]', '$_POST[content]')"; 
        $result = mysql_query($query, $link);
        echo'Your new announcement was succesfully added!<br><br>- <a href="./acp.php">Back</a>'; 
    	}
    	}
    	
    	//----------------------------
    	// REMOVE/EDIT ANNOUNCEMENTS SECTION!
    	//----------------------------
    	//DELETE
    if (isset($_GET['delete']) && !empty($_GET['id']))
    {
    $sql = mysql_query("DELETE FROM web_announcements WHERE id='$id'") or die(mysql_error());
    if($sql) echo "The announcement has successfully been removed.<br><br>- <a href=./acp.php>Back</a>";
    else echo "No row deleted..";
    }
    else
    {
    echo "You are now ready to either remove or edit an announcement, please select your options below.<hr color=#990000>";
    $query = mysql_query("SELECT * FROM web_announcements") or die(mysql_error());
    while ($results = mysql_fetch_array($query))
    {
    extract($results);
    echo"- $title (<a href=>EDIT</a>)/(<a href=$PHP_SELF?delete=1&amp;id=$id>DELETE</a>)<br>";
    }
    }
    
    //VIEW
    	if (isset($_GET['announce2'])){
    	echo"You are now ready to either remove or edit an announcement, please select your options below.<hr color=#990000>";
    	 $query = "SELECT * FROM web_announcements";
    	 $result = mysql_query($query);
    	  while ($results = mysql_fetch_array($result)){
    	  extract($results);
    	  echo"- $title (<a href=$PHP_SELF?editannouncement&id=$id>EDIT</a>)/(<a href=$PHP_SELF?id=$id&delete>DELETE</a>)<br>";
    	}
    	}
    	//EDIT
    	if (isset($_GET['editannouncement'])){
    	echo"You are now ready to edit an announcement.<hr color=#990000>";
    	 $query = "SELECT * FROM web_announcements WHERE id=$id";
    	 $result = mysql_query($sql, $link);
    	 extract($results);
    	 echo"<form action=\"acp.php?submiteditedannounce=true\" method=\"post\"><table>
    	 <input type=\"hidden\" name=\"id\" value=\"$id\">
    	<tr><td>Author:</td><td><input type=\"text\" size=\"30\" name=\"author\" value=\"$author\"></td></tr>
    	<tr><td>Date:</td><td><input type=\"text\" size=\"30\" name=\"date\" value=\"$date\"></td></tr>
    	<tr><td>Title:</td><td><input type=\"text\" size=\"30\" name=\"title\" value=\"$title\"></td></tr>
    	<tr><td>Content:</td><td><textarea size=\"30\" name=\"content\" rows=\"6\" cols=\"40\">$content</textarea></td></tr>
    	<tr><td>- <a href=\"./acp.php\">Back</a></td><td><input type=\"submit\" value=\"Submit Edited Announcement\"></td></tr>
    	</table></form>";
    	}
    	if (isset($_GET['submiteditedannounce'])){
    	$sql = "UPDATE web_announcements SET author='$_POST[author]', date='$_POST[date]', title='$_POST[title]', content='$_POST[content]' WHERE id=$id";
    	$result = mysql_query($sql, $link);
    	}
    			  ?>

  • #2
    welcome here!

    please read the posting guidelines and choose a more descriptive title.
    please also use the [php] tags instead of the [code] tags when posting php code.
    please also specify what is wrong --> with your current post, you have about 0% chances that someone will look into it.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment

    Working...
    X