Jump to content

Not Reading Submit Button


Tenaciousmug

Recommended Posts

Whenever I hit the submit button, it's not even reading if they hit it and doing all that if and else statements I have. Why is not noticing the submit button?

I had this working last night, but my dumb self saved over it with another file I was editing.

 

<?php
session_start();
include("config.php");
include("logincheck.php");

$time = date_default_timezone_set("US/Eastern");
$timeformat = date("Y-m-d H:i:s");
$author = $_SESSION['username'];
$title = $_POST['title'];
$body = $_POST['body'];

if (isset($_POST['submit']))
{
if (!empty($title))
{
	if (!empty($body))
	{
		$sql = "INSERT INTO news (author, title, body, time) VALUES ('$author', '$title', '$body', NOW())";
		mysqli_query($cxn, $sql);
		$error = "Your news posting has been submitted successfully.";
	}
	else
	{
		$error = "You must fill out the body of the posting!";
	}
}
else
{
	$error = "You must fil out the title of the posting!";
}
}

$sql = "SELECT userlevel FROM members WHERE userid='".$_SESSION['userid']."'";
$result = mysqli_query($cxn, $sql);
$row = mysqli_fetch_array($result);
if ($row['userlevel'] != 2)
{
$error = "You do not have the power to view this page!";
header("Location: news.php");
}
else
{
?>

<?php include("header.php"); ?>
<h1>Post News</h1>
<?php
echo $error;
?>

<form method="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<b>Author:</b> <?php echo $author; ?><br>
<b>Title:</b><br>
<input type="text" maxlength="25" name="title" value="<?php echo $title; ?>" /><br>
<b>Body:</b><br>
<textarea name="body" maxlength="999" rows="10" cols="40"><?php echo $body; ?></textarea><br>
<input type="submit" name="submit" value="Post News" />
</form>
<?php
}
?>		
<?php include("footer.php"); ?>

Link to comment
https://forums.phpfreaks.com/topic/235779-not-reading-submit-button/
Share on other sites

No it just refreshes the page.

I do notice that it's putting all the attributes up in the URL.

I mean it's reading them perfectly fine.

 

But whenever I hit submit, it doesn't actually follow the

if (isset($_POST['submit']))

I have going on.

 

I took away that whole IF statement and it does the same thing.

So I know it's not reading the submit button.

I just don't get why it's not because last night, it was. :/

And I'm looking at my old books and I have everything correct...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.