Jump to content

whats wrong with my page logic


Lodius2000

Recommended Posts

I am making a comments feature to my blog and everything is inside of functions(display of form, validation, etc), and then the functions are called using if() statements depending on what has happened so far...

 

here is the logic behind it all, hopefully the comments help

<?php
//validate that user is from comments users table
$valid_user = $db->getCol('SELECT username FROM comments_users');
if (in_array($_SESSION['username'], $valid_user)) {

if($_POST['_submit_check_comment']){
	if($form_errors_comment = validate_form_comment()){
		show_form_comment($form_errors);//display content and comment form
	} else {
		process_form_comment(); //post comment and redisplay page
	}
} else {
	show_form_comment();
}
} else {
if($_POST['_submit_check_login']){
	if($form_errors = validate_form_login()){
		show_form_login($form_errors);//display content and login form
	} else {
		process_form_login();// add user to $_SESSION['username'] and redisplay page
	}
} else {
	show_form_login();
}
}

?>

 

basically, i want the show_form_login to display upon reaching the page, you login click submit and process_form_login runs, which adds your session username, and redisplays the page, since there is now session data the first if() statement checks to make sure the user is a valid user in the comments_users table, if so it runs the show_form_comments function

 

problem:

the login form displays, i plug in any old thing, valid or not, I get no errors, I get not comments form, it just redisplays the login form

 

whats wrong with this logic

 

//i have used the show_form, validate_form, process_form functions before with no problems, but this is the first time I have tried to put 2 sets (comments and login) into the same page, so i think the problem is my integration of the 2 things

Link to comment
https://forums.phpfreaks.com/topic/123201-whats-wrong-with-my-page-logic/
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.