SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,657
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    if statement throws error?

    I don't understand why this if statement throws an error
    PHP Code:
    <?php
    if(!isset($_POST['submit'])) || (!isset($_GET['cform']))) { 
    ?>
    the error, http://offthevinesd.com/lukescontact.php

    Thanks...
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Let's separate the terms.

    Code php:
    <?php
    if(
        !isset($_POST['submit'])) ||
        (!isset($_GET['cform']))
    ) { 
    ?>

    Do you see where the bracket needs to go?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some code editors have a nice feature where if you put the cursor on an opening parenthesis, it will highlight it, as well as the closing parenthesis. This makes it real easy to spot where you have the wrong number of parenthesis, and even just plain mismatched them.

    notepad++ is a pretty simple editor with this capability.

  4. #4
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,657
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    jeez... dreamweaver sux.....
    "Oh, and Jenkins--apparently your mother died this morning."

  5. #5
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,657
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    k, I dont see why my if statements dond see to be working.
    What I'm tryin to makle happen is if the form hasn't been submitted or the $_GET['cform'] is missing, then the form will display.
    But once the form is submitted, the javascript thing woulod run. Then once the javascript script is run, it suppllies a
    $_GET variable and when the page sees that it has been set, it displays a Thank you.
    Heres what I have soo far
    <?php
    if(
    (!isset($_POST['submit'])) ||
    (!isset($_GET['cform']))
    ) {
    ?>
    <div style="background-image:url(images/contactform_top.jpg); width:583px; margin:0 auto; height:30px">
    </div>
    <div style="background-image:url(images/contactform_mid.jpg); width:583px; margin:0 auto">
    <form id="contact" action="#" method="post" class="contact" name="contact">
    <fieldset><legend>Contact form</legend>
    <p class="first">
    <label for="name">Name</label>
    <input type="text" name="name" id="name" size="30" class="validate['required','length[3,-1]','nodigit']" />
    </p>
    <p>
    <label for="email">Email</label>

    <input type="text" name="email" id="email" size="30" class="validate['required','length[5,-1]','email']" />
    </p>
    <p>
    <label for="phone">Phone</label>

    <input type="text" name="phone" id="phone" size="30" />
    </p>
    <p>
    <label for="message">Message</label>

    <textarea name="message" id="message" cols="30" rows="10" class="validate['required']"></textarea>
    </p>

    <p class="submit"><button type="submit" class="validate['submit']" name="submit">Send</button></p>

    </fieldset>

    </form>
    </div>
    <div style="background-image:url(images/contactform_bot.jpg); width:583px; margin:0 auto; height:33px; background-color:#000000">
    </div>
    <?php
    } elseif (isset($_POST['submit'])) {
    echo '<br><br><br><br><br><center>';
    echo '<script language="javascript" src="/js/timerbar.js"></script>';
    echo '</center>';
    } else {
    echo '<br><br><br><br><br><center>';
    echo '<h3>Thank you!</h3>';
    echo '</center>';
    }
    ?>
    Thanks
    "Oh, and Jenkins--apparently your mother died this morning."

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by lukeurtnowski View Post
    k, I dont see why my if statements dond see to be working.
    What I'm tryin to makle happen is if the form hasn't been submitted or the $_GET['cform'] is missing, then the form will display.
    You'll want to use the && operator instead, so that the condition will be filfilled when neither of them are true.

    if (!foo && !bar) {
    do baz
    }

    If you use the || operator, the condition will be filfilled when only one of them is true.

    Code:
     &&   True False
    True   1     0
    False  0     0
    
     ||  True False
    True   1     1
    False  1     0
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,657
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    oh ok, thanks (again)
    "Oh, and Jenkins--apparently your mother died this morning."


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •