Jump to content

[SOLVED] variable not passing


Ninjakreborn

Recommended Posts

<?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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.