Page 1 of 1

Checking Values

Posted: Fri Mar 25, 2005 10:59 pm
by anthony88guy
This is wrong. You can check it out, as you can see it doesn't update anything to the database. I know their is something wrong with my if statement on line:19.

Posted: Fri Mar 25, 2005 11:11 pm
by feyd
line 19 has logic errors.

Posted: Sat Mar 26, 2005 6:45 am
by anthony88guy
I want line 19 to do this: IF username, pass1, pass2, statlinks are not empty = true and if pass1 = pass2 = true. Then connect to mysql... Whats wrong with my logic?

Posted: Sat Mar 26, 2005 8:16 am
by feyd
logical or will make the entire expression true if any one of them is true.

Posted: Sat Mar 26, 2005 10:17 am
by thallish
use :

if(($username !== "" || $pass1 !== "" || $pass2 !== "" || $statslink !== "") && $pass1 == $pass2)


regards
thallish

Posted: Sat Mar 26, 2005 10:22 am
by feyd
that logic is flawed for the intention of the line. Using logical and throughout or empty() would make the logic work.

Posted: Sat Mar 26, 2005 11:40 am
by anthony88guy
sorry, but i am lost.

Posted: Sat Mar 26, 2005 11:45 am
by method_man
he means do this

Code: Select all

<?php
$status = "";
$status1 = "";
$status2 = "";
 
include_once('database.php');
 
if($_POST){
    $username = $_POST['usrname'];
    $pass1 = $_POST['pass1'];
    $pass2 = $_POST['pass2'];
    $statslink = $_POST['statslink'];
    if($pass1 !== $pass2){
    $status = "Passwords Do Not Match<br>";
    }
    if($username == "" || $pass1 == "" || $pass2 == "" || $statslink == ""){
    $status1 = "Please Fill in All Fields";
    }
    if(($username !== "" || $pass1 !== "" || $pass2 !== "" || $statslink !== "") && $pass1 == $pass2) {
    mysql_connect("$host", "$dbuser", "$dbpass") or die("Cannot Connect to Database at this time.");
    mysql_select_db("$dbname") or die("Cannot Connect to Database at this time.");
    mysql_close();
    $status2 = "You have Successfully Registered, You can now <a href=\"login.php\">Login</a>.";
    }
}    
?>

 
 
<html>
<head>
<title>No Kidding</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
 
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
 
<body bgcolor="#333333" text="#CCCCCC" link="#FFCC00" vlink="#FFCC00" alink="#FFCC00" onLoad="MM_preloadImages('../Images/menu05ov.gif','../Images/menu02ov.gif','../Images/menu03ov.gif','../Images/menu04ov.gif','../Images/menu01ov.gif')">
<div align="center"> 
  <table width="100%" height="50" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr> 
      <td height="50" background="../Images/bg.gif"> <div align="center"> </div>
        <div align="right"></div>
        <div align="center"><a href="http://www.nokidding.websiteallies.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','../Images/menu01ov.gif',1)"><img src="../Images/menu01.gif" alt="Home" name="Image6" width="95" height="50" border="0"></a><a href="http://www.nokidding.websiteallies.com/downloads.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../Images/menu02ov.gif',1)"><img src="../Images/menu02.gif" alt="Downloads" name="Image2" width="140" height="50" border="0"></a><a href="http://www.nokidding.websiteallies.com/links.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','../Images/menu03ov.gif',1)"><img src="../Images/menu03.gif" alt="Links" name="Image3" width="91" height="50" border="0"></a><a href="http://www.nokidding.websiteallies.com/bankingcalc.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','../Images/menu04ov.gif',1)"><img src="../Images/menu04.gif" alt="KOC Calculators" name="Image4" width="163" height="50" border="0"></a><a href="http://www.nokidding.websiteallies.com/mail.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','../Images/menu05ov.gif',1)"><img src="../Images/menu05.gif" alt="Contact" name="Image5" width="111" height="50" border="0"></a> 
          <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','../Images/menu05ov.gif',1)"></a></div></td>
    </tr>
  </table>
  <p><strong>UNDER CONSTRUCTIO<font color="#CCCCCC">N</font> </strong> <br>
    <br>
<?php print "<b><font color=\"#FF0000\"> $status $status1 $status2</font></b>";?>  </p>
  <form action="register.php" method="post" name="register" id="register">
    <table width="520" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td bgcolor="#990000">&nbsp;</td>
        <td width="68%" bgcolor="#990000"> <div align="center"><strong>Registration Form</strong></div></td>
      </tr>
      <tr> 
        <td width="32%" height="25" bgcolor="#666666"> 
          <div align="right"><strong>KoC Username:</strong></div></td>
        <td height="25" bgcolor="#666666"> 
          <input name="usrname" type="text" id="usrname" size="20" style="color:black; background-color:#CCCCCC; border-width:0px;"></td>
      </tr>
      <tr> 
        <td height="25" bgcolor="#333333"> 
          <div align="right"><strong>Password*:</strong></div></td>
        <td height="25"> 
          <input name="pass1" type="password" id="pass1" size="20" style="color:black; background-color:#CCCCCC; border-width:0px;"></td>
      </tr>
      <tr> 
        <td height="25" bgcolor="#666666"> 
          <div align="right"><strong>ReEnter Password*:</strong></div></td>
        <td height="25" bgcolor="#666666"> 
          <input name="pass2" type="password" id="pass2" size="20" style="color:black; background-color:#CCCCCC; border-width:0px;"></td>
      </tr>
      <tr> 
        <td height="25" bgcolor="#333333"> 
          <div align="right"><strong>KoC Stat Link:</strong></div></td>
        <td height="25"> 
          <input name="statslink" type="text" id="statslink" size="50" style="color:black; background-color:#CCCCCC; border-width:0px;"></td>
      </tr>
      <tr> 
        <td height="30" bgcolor="#990000"> <div align="center"> 
            <input type="reset" name="Submit2" value="Reset" style="color:black; background-color:#CCCCCC; border-width:0px;">
          </div></td>
        <td height="30" bgcolor="#990000"> <div align="center"> 
            <input type="submit" name="Submit" value="Register" style="color:black; background-color:#CCCCCC; border-width:0px;">
          </div></td>
      </tr>
      <tr bgcolor="#333333"> 
        <td colspan="2"><div align="center"><font size="-1"><strong>* Not your 
            KoC password, even though your password is encypted.</strong></font></div></td>
      </tr>
    </table>
  </form>
  <p><br>
  </p>
  <p>&nbsp;</p>
</div>
</body>
</html>
replace line 19 with
if(($username !== "" || $pass1 !== "" || $pass2 !== "" || $statslink !== "") && $pass1 == $pass2){ like thallish said.

matt

Posted: Sat Mar 26, 2005 11:47 am
by feyd
as I said, thallish's code has a logic error when compared to the logic anthony wants.

Posted: Sat Mar 26, 2005 11:58 am
by method_man
oh i didnt see ur post feyd

matt

Posted: Sat Mar 26, 2005 4:04 pm
by anthony88guy
what about this?

Posted: Sat Mar 26, 2005 11:15 pm
by feyd
try it?