Ninjakreborn Posted April 23, 2007 Share Posted April 23, 2007 <?php require_once("../config.php"); ?> <?php if ($_SESSION['controller'] == true) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" href="css/admin1.css" /> <title>$$$$$$</title> <script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced" }); </script> </head> <body id="admin"> <div id="adminwrap"> <div id="adminheader"><h2>Control Panel</h2></div> <div id="adminbody"> <div id="adminleftcol"> <?php require_once("./includes/admin.leftnav.inc.php"); ?> </div> <div id="adminrightcol"> <?php if (isset($_POST['submit'])) { $errorhandler = ""; if ($_POST['date'] == "") { $errorhandler .= "Date Required.<br />"; } if ($_POST['news'] == "") { $errorhandler .= "News Required.<br />"; } if ($errorhandler != "") { echo '<span style="color:red;"'; echo $errorhandler; echo '</span>'; $show = "yes"; } if ($errorhandler == "") { $insert = "INSERT INTO news_cms (date, news) VALUES ('$date', '$news');"; if (mysql_query($insert)) { echo "Success"; $show = "no"; }else { echo "Failed"; $show = "yes"; } } } ?> <h2>New's Entry</h2> <p>Add New new's entries here.</p> <form name="addnews" id="addnews" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <label for="date">Date:(any format)</label> <input name="date" type="text" value="<?php echo $_POST['date']; ?>" /> <br /> <label for="news">News</label> <br /><br /> <textarea name="news"></textarea> <br /> <input name="submit" id="submit" type="submit" value="Enter" /> </form> </div> <div id="adminfooter"> </div> </div> </body> </html> <?php }else { header("Location: index.php"); } ?> It's passing the new's but not the date. Actually it is passing the date properly (using print_r) but when I try to detect it using the error hanlding it's not doing anything I replicated this same format thousands of time's, I just don't understand why that one variable isn't passing. It's doing the news properly, but acting like date isn't even there. Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/ Share on other sites More sharing options...
marmite Posted April 23, 2007 Share Posted April 23, 2007 you don't seem to have set $date or $news anywhere maybe you didn't post all the code? Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236049 Share on other sites More sharing options...
Ninjakreborn Posted April 23, 2007 Author Share Posted April 23, 2007 Yes, it's in the form. So the form is suppose to pass it to the script. It's there in the array but not active in the error handler, and what's wierd is when you submit the form. If you look at the view source there is now a d in the value area for date, but it's not showing in the browser, or as an error, or in the array :S Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236053 Share on other sites More sharing options...
trq Posted April 23, 2007 Share Posted April 23, 2007 As has been said. You don't define $date or $news anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236056 Share on other sites More sharing options...
mpharo Posted April 23, 2007 Share Posted April 23, 2007 how is $_POST['date'] being populated....you must be getting it from another form.....in your error handle you have If ($_POST['date'] == "") which means if it is intialized but it is empty { Do This } so how is it getting populated? Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236058 Share on other sites More sharing options...
Ninjakreborn Posted April 23, 2007 Author Share Posted April 23, 2007 Look at the login behind the code. the $date, and the $news aren't set yet. That part of the script isn't accomplished yet. I am just looking at the form, and the error handler, that's it for now The form is populated by whatever the person types in. It is initially empty because post isn't populated. It's just a quick way to repopulate the form. They submit it, then the post field comes back on itself and repopulates if they had an error. However in this situation, the initial error checking isn't working. Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236059 Share on other sites More sharing options...
mpharo Posted April 23, 2007 Share Posted April 23, 2007 Well it wont work because your saying if it is equal to null, not not initialized...try doing this... If (!$_POST['date'] or $_POST['date'] == "") { Echo "Date empty..."; } Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236061 Share on other sites More sharing options...
Ninjakreborn Posted April 23, 2007 Author Share Posted April 23, 2007 It's a style preference. that can't be it, because news is done the same way and it works. This is simply the way I currently code. If the value is empty (which it's not suppose to be) then return an error, if it's not empty "" then it's got something in it. It can't be that, it's something else I just can't figure out what's causing it. Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236063 Share on other sites More sharing options...
mpharo Posted April 23, 2007 Share Posted April 23, 2007 edited Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236065 Share on other sites More sharing options...
Ninjakreborn Posted April 23, 2007 Author Share Posted April 23, 2007 Got it, it was the error handler line. Where I was outputting the span tag's, I forgot to close it so it was throwing the whole form out of wack. Quote Link to comment https://forums.phpfreaks.com/topic/48286-solved-variable-not-passing/#findComment-236067 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.