plasmagames Posted November 29, 2008 Share Posted November 29, 2008 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'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/ Share on other sites More sharing options...
plasmagames Posted November 29, 2008 Author Share Posted November 29, 2008 can anyone help? ??? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-701891 Share on other sites More sharing options...
plasmagames Posted November 30, 2008 Author Share Posted November 30, 2008 hello? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702045 Share on other sites More sharing options...
revraz Posted November 30, 2008 Share Posted November 30, 2008 Remove the $ before submitter $author = secure($_POST['$submitter']); Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702055 Share on other sites More sharing options...
plasmagames Posted November 30, 2008 Author Share Posted November 30, 2008 but how do i get the variable to put the username into the field Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702058 Share on other sites More sharing options...
revraz Posted November 30, 2008 Share Posted November 30, 2008 How are you capturing the username when they post? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702060 Share on other sites More sharing options...
plasmagames Posted November 30, 2008 Author Share Posted November 30, 2008 well i want it to automatically grab the username which is stored in the variable $uName and i have that going into a variable called $submitter Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702066 Share on other sites More sharing options...
revraz Posted November 30, 2008 Share Posted November 30, 2008 Then why not use $uName instead of $author or $submitter? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702070 Share on other sites More sharing options...
plasmagames Posted November 30, 2008 Author Share Posted November 30, 2008 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'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702087 Share on other sites More sharing options...
Coreye Posted November 30, 2008 Share Posted November 30, 2008 $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. Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702096 Share on other sites More sharing options...
plasmagames Posted November 30, 2008 Author Share Posted November 30, 2008 i cannot believe i missed that thanks man Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702098 Share on other sites More sharing options...
plasmagames Posted December 1, 2008 Author Share Posted December 1, 2008 ok it's posting the news but its not putting in the name Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702773 Share on other sites More sharing options...
dezkit Posted December 1, 2008 Share Posted December 1, 2008 You don't have a form field to for a user to put their name in, i am guessing you have the username in a session? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-702786 Share on other sites More sharing options...
plasmagames Posted December 1, 2008 Author Share Posted December 1, 2008 ya and i went over the code again and i can't find a thing wrong with it. I checked the database and it's not put the name into the database Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-703370 Share on other sites More sharing options...
revraz Posted December 1, 2008 Share Posted December 1, 2008 I asked you this already: How are you capturing the username when they post? So how do you get $uName? Because it's not in your code on where it comes from. Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-703374 Share on other sites More sharing options...
plasmagames Posted December 1, 2008 Author Share Posted December 1, 2008 $uName is the username of a user it grabs the username from the database and put's it as that value Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-703473 Share on other sites More sharing options...
revraz Posted December 2, 2008 Share Posted December 2, 2008 Not in that code it doesn't. Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-703531 Share on other sites More sharing options...
plasmagames Posted December 2, 2008 Author Share Posted December 2, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-703608 Share on other sites More sharing options...
plasmagames Posted December 13, 2008 Author Share Posted December 13, 2008 Hello!!!??? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-714638 Share on other sites More sharing options...
revraz Posted December 13, 2008 Share Posted December 13, 2008 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!!!??? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-714667 Share on other sites More sharing options...
plasmagames Posted December 13, 2008 Author Share Posted December 13, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-714750 Share on other sites More sharing options...
plasmagames Posted December 17, 2008 Author Share Posted December 17, 2008 again....................................... Hello? Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-717382 Share on other sites More sharing options...
premiso Posted December 17, 2008 Share Posted December 17, 2008 again....................................... Hello? You say hello, I say goodbye. Quote Link to comment https://forums.phpfreaks.com/topic/134751-news-system/#findComment-717387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.