Jump to content

Archived

This topic is now archived and is closed to further replies.

Plazman65

a lot of ifs and elses, I need a little guidance

Recommended Posts

Good Morning, I am trying to get this page to work. What I need to do is,
if members exceed the amount entered it stopps processing and says "you have succeeded the number of.."
then if it goes past that but it they already have that job in their favorites for it to say " hey you its already in there" and then if it goes past that then goes ahead and enters inserts the data.
It doing everything but the unique job part. Does anyone see whats wrong?
I appreciate the help. Thanks, Michelle


<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" class="style1" id="form1">
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if
(
($_SESSION['mem_type']=="standard" && $_SESSION['count']>=5)||
($_SESSION['mem_type']=="silver" && $_SESSION['count']>=10)||
($_SESSION['mem_type']=="gold" && $_SESSION['count']>=25)){
echo "You have exceeded your maximum number of Departments. ".
"Please edit your departments or consider upgrading your account.";
}

else
$st = mysql_query("SELECT ,username,depid FROM mydepartments WHERE depid = '$posted_depid' AND username='MM_Username'");
$recs = mysql_num_rows($st);
$row = mysql_fetch_array($st);
if ($recs >=1)

echo "You already have this department in your favorites";


else
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO mydepartments (username, depid, mem_type) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['username2'], "text"),
GetSQLValueString($_POST['depid2'], "int"),
GetSQLValueString($_POST['textfield'], "text"));

mysql_select_db($database_jobs, $jobs);
$Result1 = mysql_query($insertSQL, $jobs) or die(mysql_error());


if (isset($_SERVER['QUERY_STRING']))
echo"Your department has been successfully added.";



}
?>

Share this post


Link to post
Share on other sites
actually, i think it's simply a matter of misplaced curly brackets. try this and see if it helps:
[code]
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING']))
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

if (($_SESSION['mem_type']=="standard" && $_SESSION['count']>=5) ||
    ($_SESSION['mem_type']=="silver" && $_SESSION['count']>=10) ||
    ($_SESSION['mem_type']=="gold" && $_SESSION['count']>=25))
}
  echo "You have exceeded your maximum number of Departments. ".
       "Please edit your departments or consider upgrading your account.";
} else {
  $st = mysql_query("SELECT ,username,depid FROM mydepartments WHERE depid = '$posted_depid' AND username='MM_Username'");
  $recs = mysql_num_rows($st);
  $row = mysql_fetch_array($st);
  if ($recs >=1)
      echo "You already have this department in your favorites";
  elseif ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
        $insertSQL = sprintf("INSERT INTO mydepartments (username, depid, mem_type) VALUES (%s, %s, %s)", GetSQLValueString($_POST['username2'], "text"), GetSQLValueString($_POST['depid2'], "int"), GetSQLValueString($_POST['textfield'], "text"));
        mysql_select_db($database_jobs, $jobs);
        $Result1 = mysql_query($insertSQL, $jobs) or die(mysql_error());
        
        if ($Result1)
            echo"Your department has been successfully added.";
    }
}
?>

[/code]

i really haven't changed any code, just cleaned it up a little

Share this post


Link to post
Share on other sites
Thanks for your help, If the number of jobs exceeds then it says hey you cant do that , if its added it says its added. The checking for unique part though it isnt catching that. Any ideas?
Thanks, Michelle

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.