Hi I am wondering how to do the first if statement. The rest works as expected (although longwinded) not sure how to optimise that, but that’s for another time. What I need is to give an error message if a user attempts to post twice in succession.
Thank you
function saveCommentToDatabase($stack, $name, $comment)
{
if($name == previousauthor){
return 'Can\'t post twice';
}
else if(!$name){
return 'You seem to have an existential problem. You do not exist.';
}
else if($name == 'Charles Dickens'){
return 'You are NOT Charles Dickens.';
}
else if($name == 'Author'){
return 'You should try being a little more imaginative with your name.';
}
else if($name == 'password1'){
$name = 'User One';
}
else if($name == 'password2'){
$name = 'User Two';
}
else if($name == 'password3'){
$name = 'User Three';
}
else if($name == 'password4'){
$name = 'User Four';
}
Well, you need to fetch comments from whatever store you are using (DB?) and check if name of previous poster matches name of current poster.
You would also want to check time of previous comment and compare it to current time(). If some period of time is already passed, you would let the user to post another comment.