Jump to content
Killersites Forums

LiquidFire

Member
  • Posts

    5
  • Joined

  • Last visited

Posts posted by LiquidFire

  1. Ive got another problem now though, when i edit something it gets messed up if it has coding in the post. such as if it has <p align="center"> it will change the align="center" to align=\"center\" will do the same thing to random text like don't will be don\'t

     

    also is there a way to change it to where when im viewing the post to edit or delete them, to show the code if i embeded a video or if theres code in there at all, show that instead of showing what it would look like

  2. Hey ben, really like the code and modded it to fit my benefits but im having a small problem with editing where what it shows when im viewing a post i had made it doesn't show up in the box when i click edit (view attachment if you dont understand)

    post-43095-014480600 1334942404_thumb.jpg

     

     

    ADMIN.PHP

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <?php
    include("../include/session.php");
    include("db.php");
    ?>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>AzureDivinity's Website</title>
    <link href="../../css/style1.css" rel="stylesheet" type="text/css">
    <link href="../../css/style2.css" rel="stylesheet" type="text/css">
    <link href="../../css/style3.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="../../slider/themes/default/default.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../slider/nivo-slider.css" type="text/css" media="screen" /> 
    
    </head>
    
    <body>
    
    <div id="everything">
    
    	<div id="header">
    
    		<ul id="menu">
    			<li><a class="main" href="http://azuredivinity.com/"></a></li>
    			<li><a class="profile" href="http://azuredivinity.com/profile.php"></a></li>						
                   <li><a class="cms" href="http://azuredivinity.com/forum/content.php"></a></li>
    			<li><a class="forum" href="http://azuredivinity.com/forum/forum.php"></a></li>
    			<li><a class="blog" href="http://azuredivinity.com/forum/blog.php"></a></li>
                   <li><a class="contact" href="http://azuredivinity.com/index.php?page=contact"></a></li>
                   <li><a class="login" href="http://azuredivinity.com/login/main.php"></a></li>
    			<li><a class="rotate" href="http://azuredivinity.com/#"></a></li>
                   <li><a class="coaching" href="http://azuredivinity.com/coaching/index.html"></a></li>
                   <li><a class="clanex" href="http://www.combatex.com/forum/index.php"></a></li>
    		</ul>  
    
    	</div>
    
    	<div id="middle">
    
    
    		<div class="slider-wrapper theme-default">
    
    		<div class="ribbon">
    		</div>
    
    			<div id="slider" class="nivoSlider">
                   	<img src="../../css/images/slider_images/img15.png" alt="" />
    				<img src="../../css/images/slider_images/img1.png" alt="" />
    				<img src="../../css/images/slider_images/img3.png" alt="" />
    				<img src="../../css/images/slider_images/img6.png" alt="" />
    				<img src="../../css/images/slider_images/img7.png" alt="" />
    				<img src="../../css/images/slider_images/img8.png" alt="" />
    				<img src="../../css/images/slider_images/img9.png" alt="" />
    				<img src="../../css/images/slider_images/img10.png" alt="" />
    				<img src="../../css/images/slider_images/img11.png" alt="" />
        				<img src="../../css/images/slider_images/img12.png" alt="" />
    				<img src="../../css/images/slider_images/img13.png" alt="" />
    				<img src="../../css/images/slider_images/img14.png" alt="" />
    			</div>
    
    		</div>
    
    	</div>
    
    <script type="text/javascript" src="../../slider/scripts/jquery-1.6.1.min.js"></script>
       <script type="text/javascript" src="../../slider/jquery.nivo.slider.pack.js"></script>
       <script type="text/javascript">
    	$(window).load(function() {
    		$('#slider').nivoSlider();
    	});
       </script>
    
    <br />
       <br />
       <br />
    
    			<div id="left_column">
    
    				<div class="left_break">
    				</div>
    
    				<div class="left">
    
    
    				<div class="left_nav_header">
    				</div>
    
    				<div class="post_body_nav">
    
    				<div id="navigation">
    					<a class="tbt" href="http://blacktowerclan.com/"></a>
                           <a class="scu" href="http://starcraftuniverse.org"></a>
    					<a class="combat" href="http://www.twitch.tv/combatex"></a>
    					<a class="clanwater" href="http://www.twitch.tv/clanwater"></a>
    					<a class="azure" href="http://www.justin.tv/azuredivinity"></a>
    					<a class="teammnm" href="http://www.twitch.tv/mnmsc2?"></a>
    					<a class="combatsite" href="http://www.combatex.com/" target="_blank"></a>
    					<a class="vile" href="http://www.twitch.tv/illusioncss" target="_blank"></a>                    						
                       <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="TG4YRKN4S3NDY">
    <input type="image" src="../css/images/buttons/donate2.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
    </form>
                       </div>
    
                       </div>
    
    				<div class="footer">
    				</div>
    
    				</div>
    
                       <div class="left">
    
                       <div class="left_break">
    				</div>
    
                       <div class="left_header">
    				</div>
    
    				<div class="post_body_nav">
    					<br><p><img src="../../css/images/achievements/achieve_1.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_2.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_3.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_4.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_5.png" alt="About Me" align="center"/></p></br>
    				</div>
    
    				<div class="footer">
    				</div>
    
    				</div>
    
    			</div>
    
    
       			<div id="middle_column" class="two_column">
    
    			<div class="post">
    
    				<div class="header">
    				</div>
    
    				<div class="post_body">
    
    					<?
    
    
    					/**
    					* User not an administrator, redirect to main page
    					* automatically.
    					*/
    
    					if(!$session->isAdmin()){
    						printf("<script>location.href='main.php'</script>");
    					}
    					else{
    
    
    					/**
    					* Administrator is viewing page, so display all
    					* forms.
    					*/
    
    					?>
    
    				<h1>Admin Center</h1>
    				<font size="5" color="#ff0000">
    				<b>::::::::::::::::::::::::::::::::::::::::::::</b></font>
    				<font size="4">Logged in as <b><? echo $session->username; ?></b></font><br><br>
    				Back to [<a href="main.php">Main Page</a>]<br><br>
    				Add A  [<a href="http://www.azuredivinity.com/index.php?p=add">New Entry</a>]<br><br>
    
    				<?
    				if($form->num_errors > 0){
    					echo "<font size=\"4\" color=\"#ff0000\">"
    						."!*** Error with request, please fix</font><br><br>";
    				}
    				?>
    
    	<?php
           // number of results to show per page
           $per_page = 6;
    
           // figure out the total pages in the database
           $result = mysql_query("SELECT * FROM tt_blog");
           $total_results = mysql_num_rows($result);
           $total_pages = ceil($total_results / $per_page);
    
    
           // check if the 'page' variable is set in the URL (ex: view-paginated.php?page=1)
           if (isset($_GET['page']) && is_numeric($_GET['page']))
           {
                   $show_page = $_GET['page'];
    
                   // make sure the $show_page value is valid
                   if ($show_page > 0 && $show_page <= $total_pages)
                   {
                           $start = ($show_page -1) * $per_page;
                           $end = $start + $per_page; 
                   }
                   else
                   {
                           // error - show first set of results
                           $start = 0;
                           $end = $per_page; 
                   }               
           }
           else
           {
                   // if page isn't set, show first set of results
                   $start = 0;
                   $end = $per_page; 
           }
    
           // display pagination
           for ($i = 1; $i <= $total_pages; $i++)
           {
                   echo "<a href='admin.php?page=$i'>$i</a> ";
           }
           echo "</p>";
    
           // display data in table
           echo "<table border='1' cellpadding='10'>";
           echo "<tr> <th>ID</th> <th>Post Date</th> <th>Post Title</th> <th>Post Text</th> <th></th> <th></th></tr>";
    
           // loop through results of database query, displaying them in the table 
           for ($i = $start; $i < $end; $i++)
           {
                   // make sure that PHP doesn't try to show results that don't exist
                   if ($i == $total_results) { break; }
    
                   // echo out the contents of each row into a table
                   echo "<tr>";
                   echo '<td>' . mysql_result($result, $i, 'id') . '</td>';
                   echo '<td>' . mysql_result($result, $i, 'datetime') . '</td>';
                   echo '<td>' . mysql_result($result, $i, 'title') . '</td>';
                   echo '<td>' . mysql_result($result, $i, 'content') . '</td>';
                   echo '<td><a href="edit.php?id=' . mysql_result($result, $i, 'id') . '">Edit</a></td>';
                   echo '<td><a href="delete.php?id=' . mysql_result($result, $i, 'id') . '">Delete</a></td>';
                   echo "</tr>"; 
           }
           // close table>
           echo "</table>"; 
    
           // pagination
    
    
    ?>
    
    				<?
    				}
    				?>
    
    				</div>
    
    				<div class="postedby">
    				</div>
    
    			</div>
    
    		</div>
    
    	<div id="footer">
    	</div>
    
    		</div>
    
    </body>
    </html>

     

     

    EDIT.PHP

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <?php
    include("../include/sessions.php");
    ?>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>AzureDivinity's Website</title>
    <link href="../../css/style1.css" rel="stylesheet" type="text/css">
    <link href="../../css/style2.css" rel="stylesheet" type="text/css">
    <link href="../../css/style3.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="../../slider/themes/default/default.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="../../slider/nivo-slider.css" type="text/css" media="screen" /> 
    
    </head>
    
    <body>
    
    <div id="everything">
    
    	<div id="header">
    
    		<ul id="menu">
    			<li><a class="main" href="http://azuredivinity.com/"></a></li>
    			<li><a class="profile" href="http://azuredivinity.com/profile.php"></a></li>						
                   <li><a class="cms" href="http://azuredivinity.com/forum/content.php"></a></li>
    			<li><a class="forum" href="http://azuredivinity.com/forum/forum.php"></a></li>
    			<li><a class="blog" href="http://azuredivinity.com/forum/blog.php"></a></li>
                   <li><a class="contact" href="http://azuredivinity.com/index.php?page=contact"></a></li>
                   <li><a class="login" href="http://azuredivinity.com/login/main.php"></a></li>
    			<li><a class="rotate" href="http://azuredivinity.com/#"></a></li>
                   <li><a class="coaching" href="http://azuredivinity.com/coaching/index.html"></a></li>
                   <li><a class="clanex" href="http://www.combatex.com/forum/index.php"></a></li>
    		</ul>  
    
    	</div>
    
    	<div id="middle">
    
    
    		<div class="slider-wrapper theme-default">
    
    		<div class="ribbon">
    		</div>
    
    			<div id="slider" class="nivoSlider">
                   	<img src="../../css/images/slider_images/img15.png" alt="" />
    				<img src="../../css/images/slider_images/img1.png" alt="" />
    				<img src="../../css/images/slider_images/img3.png" alt="" />
    				<img src="../../css/images/slider_images/img6.png" alt="" />
    				<img src="../../css/images/slider_images/img7.png" alt="" />
    				<img src="../../css/images/slider_images/img8.png" alt="" />
    				<img src="../../css/images/slider_images/img9.png" alt="" />
    				<img src="../../css/images/slider_images/img10.png" alt="" />
    				<img src="../../css/images/slider_images/img11.png" alt="" />
        				<img src="../../css/images/slider_images/img12.png" alt="" />
    				<img src="../../css/images/slider_images/img13.png" alt="" />
    				<img src="../../css/images/slider_images/img14.png" alt="" />
    			</div>
    
    		</div>
    
    	</div>
    
    <script type="text/javascript" src="../../slider/scripts/jquery-1.6.1.min.js"></script>
       <script type="text/javascript" src="../../slider/jquery.nivo.slider.pack.js"></script>
       <script type="text/javascript">
    	$(window).load(function() {
    		$('#slider').nivoSlider();
    	});
       </script>
    
    <br />
       <br />
       <br />
    
    			<div id="left_column">
    
    				<div class="left_break">
    				</div>
    
    				<div class="left">
    
    
    				<div class="left_nav_header">
    				</div>
    
    				<div class="post_body_nav">
    
    				<div id="navigation">
    					<a class="tbt" href="http://blacktowerclan.com/"></a>
                           <a class="scu" href="http://starcraftuniverse.org"></a>
    					<a class="combat" href="http://www.twitch.tv/combatex"></a>
    					<a class="clanwater" href="http://www.twitch.tv/clanwater"></a>
    					<a class="azure" href="http://www.justin.tv/azuredivinity"></a>
    					<a class="teammnm" href="http://www.twitch.tv/mnmsc2?"></a>
    					<a class="combatsite" href="http://www.combatex.com/" target="_blank"></a>
    					<a class="vile" href="http://www.twitch.tv/illusioncss" target="_blank"></a>                    						
                       <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="TG4YRKN4S3NDY">
    <input type="image" src="../../css/images/buttons/donate2.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
    </form>
                       </div>
    
                       </div>
    
    				<div class="footer">
    				</div>
    
    				</div>
    
                       <div class="left">
    
                       <div class="left_break">
    				</div>
    
                       <div class="left_header">
    				</div>
    
    				<div class="post_body_nav">
    					<br><p><img src="../../css/images/achievements/achieve_1.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_2.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_3.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_4.png" alt="About Me" align="center"/></p></br>
    					<br><p><img src="../../css/images/achievements/achieve_5.png" alt="About Me" align="center"/></p></br>
    				</div>
    
    				<div class="footer">
    				</div>
    
    				</div>
    
    			</div>
    
    		<div id="middle_column" class="two_column">
    
    			<div class="post">
    
    				<div class="header">
    				</div>
    
    				<div class="post_body">
    
    <?php
    /* 
    EDIT.PHP
    Allows user to edit specific entry in database
    */
    
    // creates the edit record form
    // since this form is used multiple times in this file, I have made it a function that is easily reusable
    function renderForm($id, $datetime, $title, $content, $error)
    {
    ?>
    
    <?php 
    // if there are any errors, display them
    if ($error != '')
    {
    echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
    }
    ?> 
    
    <form action="" method="post">
    <input type="hidden" name="id" value="<?php echo $id; ?>"/>
    <div>
    <p><strong>ID:</strong> <?php echo $id; ?></p>
    <strong>Post Date: *</strong> <input type="text" name="datetime" value="<?php echo $datetime; ?>"/><br/>
    <strong>Post Title: *</strong> <input type="text" name="title" value="<?php echo $title; ?>"/><br/>
    <strong>Post Text: *</strong> <textarea type="text" name="content" value="<?php echo $content; ?>"></textarea><br/>
    <p>* Required</p>
    <input type="submit" name="submit" value="Submit">
    </div>
    </form> 
    </body>
    </html> 
    <?php
    }
    
    
    
    // connect to the database
    include('db.php');
    
    // check if the form has been submitted. If it has, process the form and save it to the database
    if (isset($_POST['submit']))
    { 
    // confirm that the 'id' value is a valid integer before getting the form data
    if (is_numeric($_POST['id']))
    {
    // get form data, making sure it is valid
    $id = $_POST['id'];
    $datetime = mysql_real_escape_string(htmlspecialchars($_POST['datetime']));
    $title = mysql_real_escape_string(htmlspecialchars($_POST['title']));
    $content = mysql_real_escape_string(htmlspecialchars($_POST['content']));
    
    // check that datetime/title fields are both filled in
    if ($datetime == '' || $title == '' || $content == '')
    {
    // generate error message
    $error = 'ERROR: Please fill in all required fields!';
    
    //error, display form
    renderForm($id, $datetime, $title, $content, $error);
    }
    else
    {
    // save the data to the database
    mysql_query("UPDATE tt_blog SET datetime='$datetime', title='$title', 'content=$content' WHERE id='$id'")
    or die(mysql_error()); 
    
    // once saved, redirect back to the view page
    header("Location: admin.php"); 
    }
    }
    else
    {
    // if the 'id' isn't valid, display an error
    echo 'Error!';
    }
    }
    else
    // if the form hasn't been submitted, get the data from the db and display the form
    {
    
    // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
    if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
    {
    // query db
    $id = $_GET['id'];
    $result = mysql_query("SELECT * FROM tt_blog WHERE id=$id")
    or die(mysql_error()); 
    $row = mysql_fetch_array($result);
    
    // check that the 'id' matches up with a row in the databse
    if($row)
    {
    
    // get data from db
    $datetime = $row['datetime'];
    $title = $row['title'];
    $content = $row['content'];
    
    // show form
    renderForm($id, $datetime, $title, $content, '');
    }
    else
    // if no match, display result
    {
    echo "No results!";
    }
    }
    else
    // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
    {
    echo 'Error!';
    }
    }
    ?>
    
    
    				</div>
    
    				<div class="postedby">
    				</div>
    
    			</div>
    
    		</div>
    
    				<div id="footer">
    	</div>
    
    		</div>
    
    </body>
    </html>

×
×
  • Create New...