Logical problem?

  • Pbpixels
  • Novice
  • Novice
  • User avatar
  • Joined: May 23, 2012
  • Posts: 17
  • Status: Offline

Post June 24th, 2012, 3:32 pm

Hello folks. I made something very simple.
A checkbox and a textfield.

Then I have this piece of code:
PHP Code: [ Select ]
if (isset($_POST['submit'])) {
//If all requirements are fulfilled, send!
if ((isset($r1)) && (empty($i1))) {
   echo 'Please fill all the required fields marked with a red star.';
   }
   else {
   echo 'Sent';
   }
   echo "$i1";
  1. if (isset($_POST['submit'])) {
  2. //If all requirements are fulfilled, send!
  3. if ((isset($r1)) && (empty($i1))) {
  4.    echo 'Please fill all the required fields marked with a red star.';
  5.    }
  6.    else {
  7.    echo 'Sent';
  8.    }
  9.    echo "$i1";


When the checkbox IS set, but the textfield IS empty, Post: 'Please fill all the required fields marked with a red star.'

But it ignores it and posts: 'Sent' instead...

Am I doing something wrong here?
Thanks in advance

- Pbpixels
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 24th, 2012, 3:32 pm

  • Satwant
  • Graduate
  • Graduate
  • User avatar
  • Joined: Dec 27, 2010
  • Posts: 126
  • Loc: Bangalore
  • Status: Offline

Post June 25th, 2012, 3:15 am

Your code is using isset($r1) means some value is set in $rl, and also $il is not set to any value, it will print message only when these condition occurs otherwise it will print 'Sent'.

you need to share more code..
Thank You
Satwant Singh Hundal
http://www.mrhundal.com
  • Pbpixels
  • Novice
  • Novice
  • User avatar
  • Joined: May 23, 2012
  • Posts: 17
  • Status: Offline

Post June 25th, 2012, 3:44 am

I think my problem is that my code forgets the values because they are set earlie in the code, i normally fix this with a hidden inputfield, but i don't know where to place it, and is it the right answer? Sorry im on my phone right now and cant shaee more code at this moment :)

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 181 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.