Logical problem?

  • Pbpixels
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

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
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Satwant
  • Graduate
  • Graduate
  • User avatar
  • Posts: 127
  • Loc: Bangalore

Post 3+ Months Ago

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..
  • Pbpixels
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

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 139 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.