Jump to content

News system


plasmagames

Recommended Posts

I made a news system by myself it has a title field, author field, and a news field.

 

So i decided i want to make it easier by getting rid if the author field and replace it with the username of the user posting the news with the $uName variable but now it's not entering anynews at all. also i have had  a problem with entering news a message that is to long. heres my code

 

news.php

<?php
$submitter = $uName;
    //If the form hasn't been submitted, show it!
    if (!$_POST['submit']) {

        echo "<div class=\"reg\"><div class=\"point\"><img src=\"i/to.png\" alt=\"arrow\"><STRONG>News<STRONG></div><form action='index.php?action=news' method='POST'>
<p><center><strong>Editing the News</strong></center><br />
<br />
<strong>Title:</strong><input class=\"field\" type='text' name='title' />
<br />
<br />
news:
<br />
<textarea name='news' rows='20' cols='60'>
</textarea></p>
<input class='submit' type='submit' name='submit' value='Submit News' />
</form></div> ";
    } else {

        //Or else it has.. Secure all the inputs
        $news = secure($_POST['news']);
        $author = secure($_POST['$submitter']);
        $title = secure($_POST['title']);
        /*************************/
        /*************************/
        $date = date("D, d M Y"); //displays something like: "Mon, 29 Sept 2008"
        $time = date("h:i") ; //displays something like: "10:59 GMT"
        /*************************/
        /*************************/

        
                        //Insert the user information into the database
                        $add = "INSERT INTO `news` (`news`, `author`, `title`, `date`, `time`) VALUES ( '$news', '$author', '$title', '$date', '$time')";


                        //If the insert went ok...
                        if (mysql_query($add)) {

                            //Tell them the good news
                            echo "News That was entered <br /> <strong>$news</strong><br />";
                        } else {

                            echo 'Error, News was not added';

                        }
}
?>

Link to comment
Share on other sites

still not working

 

here's the updated code

<?php
$submitter = $uName;
    //If the form hasn't been submitted, show it!
    if (!$_POST['submit']) {

        echo "<div class=\"reg\"><div class=\"point\"><img src=\"i/to.png\" alt=\"arrow\"><STRONG>News<STRONG></div><form action='index.php?action=news' method='POST'>
<p><center><strong>Editing the News</strong></center><br />
<br />
<strong>Title:</strong><input class=\"field\" type='text' name='title' />
<br />
<br />
news:
<br />
<textarea name='news' rows='20' cols='60'>
</textarea></p>
<input class='submit' type='submit' name='submit' value='Submit News' />
</form></div> ";
    } else {

        //Or else it has.. Secure all the inputs
        $news = secure($_POST['news']);
        $uName = secure($_POST['author']);
        $title = secure($_POST['title']);
        /*************************/
        /*************************/
        $date = date("D, d M Y"); //displays something like: "Mon, 29 Sept 2008"
        $time = date("h:i") ; //displays something like: "10:59 GMT"
        /*************************/
        /*************************/

        
                        //Insert the user information into the database
                        $add = "INSERT INTO `news` (`news`, `author`, `title`, `date`, `time`) VALUES ( '$news', '$author', '$title', '$date', '$time')";


                        //If the insert went ok...
                        if (mysql_query($add)) {

                            //Tell them the good news
                            echo "News That was entered <br /> <strong>$news</strong><br />";
                        } else {

                            echo 'Error, News was not added';

                        }
}
?>

 

Link to comment
Share on other sites

$add = "INSERT INTO `news` (`news`, `author`, `title`, `date`, `time`) VALUES ( '$news', '$author', '$title', '$date', '$time')";

 

Should be

 

$add = "INSERT INTO `news` (`news`, `author`, `title`, `date`, `time`) VALUES ( '$news', '$uName', '$title', '$date', '$time')";

 

You're no longer defining $auther.

Link to comment
Share on other sites

ya i know that. heres my index.php code that shows it all I use the switch statment and all pages show up in one page so $uName is carried through the entire site from register.php i will also say that this is a pre made script hat i have modified

 

<?php
// Get the configuration file


$filename = 'defs.php';
$setup = 'install/index.php';

if (!file_exists($filename)) {
    die("Please install Isus beafore usage! <a href=\"install/\">Click here</A>");
}
if (file_exists($setup)) {
    die("Please remove the install folder beafore usage. It can be harmful to your site if it exists and someone uses it!");
}


include ('config.php');

// get the theme
$result = mysql_query("SELECT theme FROM theme WHERE id=1");
$theme = mysql_result($result, 0);

//Set the navigation up, secure it's input.
$nav = $_GET['action'];
secure($nav);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <meta name="generator" content="HTML Tidy for Linux (vers 1 September 2005), see www.w3.org">

    <title><?php echo SITE_NAME; ?></title>
    <link rel="stylesheet" type="text/css" href="theme/<?php echo $theme;?>/visus.css">
    <style type="text/css">
    div.c1 {text-align: center}
    </style>
</head>

<body bgcolor="#FFFFFF" background="theme/<?php echo $theme;?>/images/logo.png">
<p>
    <div class="c1" valign = "top">
        <div class="logo">
            <img src="theme/<?php echo $theme;?>/images/logo.png" height="250" width = "800">
        </div>

        <div class="pages">
            <?php include ("navbar.php"); ?>
        </div>

        <div class="Container" style=" background-image:url(images/cbg.png);">
            <div class="content" style="width:580">
                <?php
                //Use a switch statement to go through the URLS.
                switch ($nav) {
                    case "login":
                        include ('login.php');
                        break;

                    case "logout":
                        include ('logout.php');
                        break;

                    case "editprofile":
                        include ('editprofile.php');
                        break;

                    case "memberlist":
                        include ('memberlist.php');
                        break;

                    case "register":
                        include ('register.php');
                        break;

                    case "viewterms";
                        include ('terms.php');
                        break;

                    case "forgot";
                        include ('reset_pw.php');
                        break;

                    case "profile";
                        include ('profile.php');
                        break;

                    case "admin";
                        include ('admin/index.php');
                        break;

				case "theme";
                        include ('admin/theme.php');
                        break;

				case "news";
                        include ('admin/news.php');
                        break;

				case "general";
                        include ('admin/general.php');
                        break;

				case "download";
                        include ('download.php');
                        break;

				case "game";
                        include ('game.php');
                        break;

				case "tutorial";
                        include ('tutorial.php');
                        break;

				case "contact";
                        include ('contact.php');
                        break;

                    default:
                        include ('default.php');
                        break;


                }

                ?>
            </div>

            <div  class="sidebar" align="right">
                <?php include ('nav.php'); ?>
            </div>
        </div>
        <div align="center" class="footer">
            <?php include ('footer.php'); ?>
        </div>   
    </div>
    </p>
</body>
</html>

Link to comment
Share on other sites

  • 2 weeks later...

Hi

 

BTW, $uName is no where in that code either.  How do you "carry" it from page to page?  There are sessions or post variables at all.

 

Hello!!!???

 

i know that.

 

heres the code

that has it

<?php
ob_start();
//Allows us to use cookies on all of the pages

//Get some additional functions
include ('functions.php');
include ('defs.php');
//*********************************************//
//Length Of Time Cookie Lasts - 1 week default
$cookieTime = time() + 7 * 86400;
//***********************************************//

//Path to index.php file , no following slash
//Eg, if the index file were located at http://iscripting.net/isus/index.php - you would enter http://iscripting.net/isus
$siteurl = SITE_PATH;

//Your Website name, not the <title>
$sitename = SITE_NAME;

//The default membergroup when someone registers.
$defaultmembergroup = "user";

//**********************************************//

//Connect to the database
$connect = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$connect)
    echo 'There was an error connecting to the database';

mysql_select_db(DB_NAME);


// Get and authenticate their cookie information.
$u1 = secure($_COOKIE['username']);
$p1 = secure($_COOKIE['password']);

//Check theyre logged in.
$logged = mysql_query("SELECT * FROM `users` WHERE username = '$u1' AND password = '$p1'");

$logged = mysql_fetch_array($logged, MYSQL_ASSOC);

//Rename some of the $logged['variables'] with easier names.
$uId = $logged['id'];
$uName = $logged['username'];
$uEmail = $logged['email'];
$uMsn = $logged['msn'];
$uIp = $logged['ip'];
$uSignup = $logged['signup'];
$uLevel = $logged['level'];
$uGtalk = $logged['gtalk'];
$uMsn = $logged['msn'];
$uAim = $logged['aim'];
$uLocation = $logged['location'];
$uBio = $logged['bio'];
$uGroup = $logged['gid'];
$uMembergroup = $logged['membergroup'];

//If the user isn't logged in, we'll set their name to guest and membergroup to guest as well so they don't screw anything up
if (!$uName) {

    $uName = guest;
    $uMembergroup = guest;

}
//Get the permissions sorted out.
$permquery1 = mysql_query("SELECT * FROM `permissions` WHERE mg_name = '$uMembergroup' ");
$uCan = mysql_fetch_assoc($permquery1);

$action = secure($_GET['action']);
$sa = secure($_GET['sa']);
$ssa = secure($_GET['ssa']);

?>

 

which btw is included with all pages

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.