Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Question If then else (may be a stupid question?)

    This may be a stupid question but it's not working!
    I have this:
    PHP Code:
    if(($row_rsvote['vercode'] != 'voted') ||($row_rsvote['vercode'] != NULL)){
    $MM_redirectLoginSuccess "result.php"//if empty
    }else{
    $MM_redirectLoginSuccess "booksubmit.php"//not empty

    Now the objective is to go to the correct page if the field is NULL or empty.
    It's just not working, any ideas WHY?
    I have tried about 3 different ways no luck!
    Thanks for you support!

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    did you try
    PHP Code:
    if ($row_rsvote['vercode'] == 'voted'){
    $MM_redirectLoginSuccess "booksubmit.php";
    }else{
    $MM_redirectLoginSuccess "result.php";

    also in your code you had 2 open ( on an if, which i believe is not correct
    PHP Code:
    if($row_rsvote['vercode'] != 'voted' ||$row_rsvote['vercode'] != NULL){ // taken out 2 pairs of ()
    $MM_redirectLoginSuccess "result.php"//if empty
    }else{
    $MM_redirectLoginSuccess "booksubmit.php"//not empty


  • #3
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Hi how are things?

    The first one takes me to booksubmit.

    The second one takes me to result.php, even if the field has "voted" in it?
    Thanks for you support!

  • #4
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Try this
    PHP Code:
    if(empty($row_rsvote['vercode'])) || ($row_rsvote['vercode'] == NULL))
    {
         
    // Empty
         
    $MM_redirectLoginSuccess "booksubmit.php";
    }
    else
    {
         
    // Not empty
         
    $MM_redirectLoginSuccess "result.php";


  • #5
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Tried that one about an hour ago.
    Sorry man there must be something strange going on here.

    I even tried:
    header("location:booksubmit.php");

    Thanks for you support!

  • #6
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Have you tried echoing out something to make sure the logic is correct?

  • #7
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Entire PHP part:
    PHP Code:
    <?php 
    session_start
    (); 
    ?> 
    <?php require_once('Connections/cnstu2stu.php'); ?> 
    <?php 
    if (!function_exists("GetSQLValueString")) { 
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue "")  

      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); 

      switch (
    $theType) { 
        case 
    "text"
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL"
          break;     
        case 
    "long"
        case 
    "int"
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL"
          break; 
        case 
    "double"
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL"
          break; 
        case 
    "date"
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL"
          break; 
        case 
    "defined"
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue
          break; 
      } 
      return 
    $theValue


    mysql_select_db($database_cnstu2stu$cnstu2stu); 
    $query_rsvote "SELECT * FROM stulogin"
    $rsvote mysql_query($query_rsvote$cnstu2stu) or die(mysql_error()); 
    $row_rsvote mysql_fetch_assoc($rsvote); 
    $totalRows_rsvote mysql_num_rows($rsvote); 
    ?> 
    <?php 
    // *** Validate request to login to this site. 
    session_start(); 

    $loginFormAction $_SERVER['PHP_SELF']; 
    if (isset(
    $accesscheck)) { 
      
    $GLOBALS['PrevUrl'] = $accesscheck
      
    session_register('PrevUrl'); 


    if (isset(
    $_POST['userid'])) { 
      
    $loginUsername=$_POST['userid']; 
      
    $password=$_POST['passid']; 
      
    $MM_fldUserAuthorization "levelid"
    //   CHANGES NEEDED HERE 
    // if
        
    $MM_redirectLoginSuccess "result.php"//if empty result 
    //}else{ 
        
    $MM_redirectLoginSuccess "booksubmit.php"//not empty booksubmit 
    //} 
    ///////// CHANGES END HERE 
      
    $MM_redirectLoginFailed "loginfailed.php"
      
    $MM_redirecttoReferrer true
      
    mysql_select_db($database_cnstu2stu$cnstu2stu); 
           
      
    $LoginRS__query=sprintf("SELECT StuEmail, StuPassword, levelid FROM stulogin WHERE StuEmail='%s' AND StuPassword='%s'"
      
    get_magic_quotes_gpc() ? $loginUsername addslashes($loginUsername), get_magic_quotes_gpc() ? $password addslashes($password));  
        
      
    $LoginRS mysql_query($LoginRS__query$cnstu2stu) or die(mysql_error()); 
      
    $loginFoundUser mysql_num_rows($LoginRS); 
      if (
    $loginFoundUser) { 
         
        
    $loginStrGroup  mysql_result($LoginRS,0,'levelid'); 
         
        
    //declare two session variables and assign them 
        
    $GLOBALS['MM_Username'] = $loginUsername
        
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;           

        
    //register the session variables 
        
    session_register("MM_Username"); 
        
    session_register("MM_UserGroup"); 

        if (isset(
    $_SESSION['PrevUrl']) && true) { 
          
    $MM_redirectLoginSuccess $_SESSION['PrevUrl'];     
        } 
        
    header("Location: " $MM_redirectLoginSuccess ); 
      } 
      else { 
        
    header("Location: "$MM_redirectLoginFailed ); 
      } 

    ?>
    Thanks for you support!

  • #8
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Have you tried echoing out something to make sure the logic is correct?
    Yes; no info in echo?
    Thanks for you support!

  • #9
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Thank you all for your help.

    Thanks again.
    Cheers
    Last edited by westmatrix99; 06-04-2007 at 08:04 PM.
    Thanks for you support!

  • #10
    Regular Coder
    Join Date
    Apr 2007
    Posts
    295
    Thanks
    0
    Thanked 19 Times in 19 Posts
    Try something like this to debug it, if $row_rsvote['vercode'] is empty, then it could possibly be a problem with the query or what it's returning
    PHP Code:
    echo 'vercode: '$row_rsvote['vercode'] .'<br />';

    if(empty(
    $row_rsvote['vercode']) || ($row_rsvote['vercode'] == NULL))
    {
         
    // Empty
         
    $MM_redirectLoginSuccess "booksubmit.php";
    }
    else
    {
         
    // Not empty
         
    $MM_redirectLoginSuccess "result.php";
    }

    echo 
    $MM_redirectLoginSuccess

  • #11
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Quote Originally Posted by westmatrix99 View Post
    But it seems that I have to fix this issue myself.
    Imagine that. You have to do your own work.

    You wait, what, 50 minutes? And then respond with that?

    Perhaps if your code was properly formatted and not generated by Dreamweaver I would consider reading it. And perhaps others think the same.

  • #12
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Thumbs up

    I have it sorted, something I thought of which I should have thought in the beginning.
    Leave the login as is and redirect to a page that can solve the query.
    PHP Code:
    <?php
    if ($row_rsvote['vercode'] == 'voted'){
    header("Location: booksubmit.php");
    }else{
    header("Location: result.php");
    }
    ?>
    Problem solved.
    Thank you all for your help!
    Thanks for you support!

  • #13
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Thumbs up

    You wait, what, 50 minutes? And then respond with that?
    No I do actually have a life that involves going out and meeting other people also eating 'n stuff.
    Perhaps if your code was properly formatted and not generated by Dreamweaver I would consider reading it. And perhaps others think the same.
    I use dreamweaver as it is a program that I am used to working on and in.
    I don't need to hand code unless needed when a program can actually do it for you.
    Sorry my interpretation of a forum might be different to yours but does that mean that you and others can have the right to rag me or others just because we use a program like dreamweaver?
    Code:
    Don't hate the player, hate the game.
    Last edited by westmatrix99; 06-04-2007 at 10:11 PM.
    Thanks for you support!

  • #14
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    No I do actually have a life that involves going out and seeing other people.
    When you post a topic here, you sit and wait for an answer? You don't keep trying different solutions? You don't go do something else? That seems more like not having a life.

    I use dreamweaver as it is a program that I am used to working on and in.
    And that is your right, to use whatever program you want.

    However, I hate generated code, because it is not formatted properly most of the time. I don't like to disect spaghetti code.

    I don't need to hand code unless needed when a program can actually do it for you.
    The problem is the quality of the code. If a program could do it for you, why are you solving problems with it? Why are you changing it? If it was helpful, you'd click a button and it would work.

    Otherwise you're wasting your own time, as it is most likely an easy thing to do. And if you don't like recreating something others have made, then download a script (a proper one) and use that.

    Sorry my interpretation of a forum might be different to yours but does that mean that you and others can have the right to rag me or others just because we use a program like dreamweaver?
    I am not 'ragging' on you because of you using dreamweaver, I am 'ragging' on you because you appear impatient, and don't seem to be trying yourself. But when you use a program to code for you, how will you ever learn PHP? I don't expect it to happen any time soon. And a forum might be your only way of getting what you need.

  • #15
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Post

    PHP is not my favourite language, I prefer ASP but I am forced to use PHP as my host is the cheapest.

    I do understand how to code in ASP and am learning PHP as there are always new methods to do things; I don't sit and wait for an answer, I keep trying new and other ways to solve the problem.

    Sorry to disappoint you but I was not brought up being spoon fed.
    Why do you come afterwards to complain?
    Thanks for you support!


  •  

    Posting Permissions

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