Jump to content

[SOLVED] check box


runnerjp

Recommended Posts

humm i cant figure out where im off wrong..

 

  <input type="checkbox" name="email" />

 

elseif (isset($_POST['submit']))
{
			$thePost = $_POST['yourpost'];
			$theSubject = $_POST['subject'];
			if ($thePost == "" || $thePost == null)
			{
							$errMsgPost = "Error: You did not type in a post."; //no post entered
			} elseif ($theSubject == "" || $theSubject == null)
			{
							$errMsgSubject = "Error: You did not enter a subject."; //no subject entered
			}
			else
			{
			if (isset($_POST['email'])) {
			$insertpost = "INSERT INTO forumtutorial_posts(emailreply) values('1')";

}

							//we now strip HTML injections
							$theSubject = strip_tags($theSubject);
							$thePost = strip_tags($thePost);
							$insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username')";
							mysql_query($insertpost) or die("Could not insert post"); //insert post
							$updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'";
							mysql_query($updatepost) or die("Could not update post");
							header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum");
							exit;
			}
}
?>	

 

always records 0

Link to comment
Share on other sites

once again, you don't actually send the email value to the DB via a query.

you set the query here:

$insertpost = "INSERT INTO forumtutorial_posts(emailreply) values('1')";

then you overwrite $insertpost here:

$insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username')";

and only call mysql_query here:

mysql_query($insertpost) or die("Could not insert post"); //insert post

so you never actually insert the emailreply = 1 into the forumtutorial_posts table.

Link to comment
Share on other sites

like this (i hope it's not buggy):

<?php
elseif (isset($_POST['submit']))
{
			$thePost = $_POST['yourpost'];
			$theSubject = $_POST['subject'];
			if ($thePost == "" || $thePost == null)
			{
							$errMsgPost = "Error: You did not type in a post."; //no post entered
			} elseif ($theSubject == "" || $theSubject == null)
			{
							$errMsgSubject = "Error: You did not enter a subject."; //no subject entered
			}
			else
			{
			//we now strip HTML injections
			$theSubject = strip_tags($theSubject);
			$thePost = strip_tags($thePost);
			$insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter";
			if (isset($_POST['email'])) {
			$insertpost .= ",emailreply"; //if the checkbox isset, add emailreply to the column list
			}
			$insertpost .= ") values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username'";
			if (isset($_POST['email'])) {
			$insertpost .= ",'1'"; //if checkbox isset add '1' to the value list
			}
			$insertpost .= ")";
			mysql_query($insertpost) or die("Could not insert post"); //insert post
			$updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'";
			mysql_query($updatepost) or die("Could not update post");
			header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum");
			exit;
			}
}
?>

Link to comment
Share on other sites

what i ended up doing is runnign code like this

 

<?php 		if (isset($_POST['email'])) {
			$theSubject = strip_tags($theSubject);
							$thePost = strip_tags($thePost);
							$insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter,emailreply) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username','1')";
							mysql_query($insertpost) or die("Could not insert post"); //insert post
							$updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'";
							mysql_query($updatepost) or die("Could not update post");
							header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum");
							exit;

                                            }
             else
                {

							//we now strip HTML injections
							$theSubject = strip_tags($theSubject);
							$thePost = strip_tags($thePost);
							$insertpost = "INSERT INTO forumtutorial_posts(forum,author,title,post,showtime,realtime,lastrepliedto,lastposter) values('$forum','$username','$theSubject','$thePost','$thedate','$thedate','$thedate','$username')";
							mysql_query($insertpost) or die("Could not insert post"); //insert post
							$updatepost = "UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$username'";
							mysql_query($updatepost) or die("Could not update post");
							header("Location: http://www.runningprofiles.com/members/index.php?page=forum&forum=$forum");
							exit;
			}
                }
}?>

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.