Jump to content


Checking 'empty' on radio button

  • Please log in to reply
2 replies to this topic

#1 tsfountain

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 31 March 2006 - 07:04 PM

Hello all,

I'm trying to check the state of a radio button group using empty to run a post variable into a session variable.

HTML looks something like this:

<input type="radio" name="foo" value="bar1">BAR1</input>
<input type="radio" name="foo" value="bar2">BAR2</input>

Then I'm checking (on submit) to see if they've acually selected a radio button.
if (!empty($_POST['foo'])) {
  $_SESSION['foo'] = $_POST['foo'];
else {
  echo " Yuo haven't filled in anything";

The problem is it never gets to the else statement even if it is empty.

Any ideas?

#2 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 March 2006 - 07:11 PM

It returns Yuo haven't filled in anything for me as its reaching the else statement

#3 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 31 March 2006 - 07:22 PM


if (isset($_POST['foo']))
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users