Jump to content

[SOLVED] Tricky forms...


Guest

Recommended Posts

I have a form on my website that looks like this...

 

<form action="newComment.php?postId=<?php echo $postId; ?>" method="post">

 

When it gets to the newComment.php, it's supposed to redirect the user back to post.php if they forgot to fill in a required field on the form...

 

if (empty($_POST['title']) || empty($_POST['author']) || empty($_POST['content'])) {
  header("Location: post.php?id=$postId");

 

It successfully send the user back, but I get a MySQL query error here...

 

$postId = $_GET['id'];
$postQuery = "SELECT title, author, datetime, content, blog, tags FROM posts WHERE id = $postId";
$postResult = mysql_query($postQuery);
list($postTitle, $postAuthor, $postDatetime, $postContent, $postBlog, $postTags) = mysql_fetch_row($postResult);

 

The error says that $postResult is not a valid MySQL resource. Is there something wrong with my header() function? This is extremely frustrating. Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/112874-solved-tricky-forms/
Share on other sites

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.