Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'if statement'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. I just started going through the book and ran into my first problem while working through the end of chapter 2 in the Pursue section: The relevant part of Script 2.4 is: if (isset($_POST['gender'])) { $gender = $_POST['gender']; if ($gender == 'M') { echo '<p><b>Good day, Sir!</b></p>'; } elseif ($gender == 'F') { echo '<p><b>Good day, Madam!</b></p>'; } else { $gender = NULL; echo '<p class="error"><b>Gender should be either M or F!</b></p>'; } } else { $gender = NULL; echo '<p class="error"><b>You forgot to select your gender!</b></p>'; } I am using 'yes' and 'no' instead of 'M' and 'F' but this is the code that I used: if(isset($_POST['newsletter']) == 'yes') { echo "<p>Thank you for signing up for our monthly newsletter!</p>"; } elseif(isset($_POST['newsletter']) == 'no') { echo "<p>We are sorry you have decided NOT to sign up for our newsletter.</p>"; } else { echo "<p>You for got to choose a newsletter option!</p>"; } I know the hint suggested that I use the AND operator. The above code seems like it should work but ifelse(or the 'no') is printing the same as the if(or the 'yes') response and the else(where nothing is checked) is printing the correct response. In other words, When no is checked on the form it is saying "thank you for signing up" instead of "sorry you have decided to NOT..."
×
×
  • Create New...