CodeIgniter Forums

Full Version: [share]a simple way to check whether a forum has been submit
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]basementDUDE[/eluser]
I am such a noob, I always find isset() and empty() confuseing.

I use this trick.

lets say you have a forum to ask people to submit email address, and you post data to itself.

you can just do this:
Code:
$email = $this->input->post('email', TRUE);

if($email === false)//you have to use triple === otherwise it won't work
{
//forum has not been submit yet
}
else
{
//forum has been submit
}

you don't need any function such as isset(), empty() or place hidden input field as flag in html.

El Forum

[eluser]Prensil Technologies Pvt Ltd.[/eluser]
This might work but the `===` operator will make the string comparison and thus it will be costly in terms of performance. We should use if($email) for better check the condition. If condition will work best in this scenario.