Hilfe Hilfe

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • #31
    Die lösung ist besser:
    PHP-Code:
    <select name="cboAbteilung"> 
    <option selected>Bitte wählen sie aus</option>
        
    <?
    $ret = mysql_db_query("schneggo", "select * from Abteilung");
    while($row = mysql_fetch_array($ret))
        { 
        echo "<option value='$row[id_abteilung]'>$row[name]</option>";
        } 
    ?> 
    </select>
    *winks*
    Gilbert
    ------------------------------------------------
    Hilfe für eine Vielzahl von Problemen!!!
    http://www.1st-rootserver.de/

    Kommentar


    • #32
      Also, aufs neue.

      Wenn ich einen User erstelle, dann wird er in der DB korrekt erzeugt. Nur wenn ich jetzt die Userdaten ändern möchte, dann zeigt er mir die Abteilung die ich vorher ausgewählt habe nicht an. Wie gesagt, in der Datenbank steht es korrekt drinnen.
      Wo liegt jetzt da mein Fehler? Ist bestimmt nur eine Kleinigkeit, oder??

      Hier mal das komplette Programm

      PHP-Code:
      <?
        $intSecurity = 0;
        $intTimeOut = 900;
        $intSecFolder = TRUE;
        $strPageTitle = "Create a new user";

        Include("../includes/security.inc.php");
        Include("../includes/functions.inc.php");
        Include("../includes/db.inc.php");

        If ($HTTP_POST_VARS["btnSubmit"] != "") {
            $strUserID      = validateText("User ID", $txtUserID, 3, 20, TRUE, FALSE);
            $strFirstName   = validateText("First Name", $txtFirstName, 2, 40, TRUE, FALSE);
            $strMiddleInit  = validateText("Middle Initial", $txtMiddleInit, 1, 1, FALSE, FALSE);
            $strLastName    = validateText("Last Name", $txtLastName, 2, 40, TRUE, FALSE);
            $strEmail       = validateEmail("Email Address", $txtEmail, TRUE);
            If ($cboLevel == "" AND $strError == "") {
                $strError = "Please select a security level.";
            } Else {
                $intLevel = $cboLevel;
            } 
            
            If($cboAbteilung == "1" AND $strError == "") {
            $strError = "Please select a department.";
            } Else {
            $intAbteilung = $cboAbteilung;
            } 
            
            
            
            
            
            If ($strError == "") {
                 $strSQL = "SELECT id FROM tblSecurity WHERE userID='$strUserID'";
                 $result = dbquery($strSQL);
                 $intFound = mysql_num_rows($result);
                 If ($intFound != 0) {
                      $strError = "That userID already exists.";
                 } Else {
                      $strSQL = "SELECT id FROM tblSecurity WHERE email='$strEmail'";
                      $result = dbquery($strSQL);
                      $intFound = mysql_num_rows($result);
                      If ($intFound != 0) {
                           $strError = "That email address already exists.";
                      } Else {
                           If ($intLevel != 3) {
                               $strTempString = "ABCDEFGHIJKLMNPQRSTUVWXYZ123456789";
                               for ($i = 0; $i < 8; $i++) {
                                    srand ((double) microtime() * 1000000);
                                    $intPos = rand(0, 33);
                                    $strTempChar = substr($strTempString, $intPos, 1);
                                    $strPassword = $strPassword.$strTempChar;
                               }
                           } Else {
                               $strPassword = "nonuser1";
                           }
                           $strPassword2 = md5($strPassword);
                           $strSQL = "INSERT INTO tblSecurity (userID, password, firstName, middleInit, lastName, email, securityLevel, fk_abteilung) VALUES ('$strUserID', '$strPassword2', '$strFirstName', '$strMiddleInit', '$strLastName', '$strEmail', $intLevel, $intAbteilung)";
                           $result = dbquery($strSQL);
                           $strError = "User '$strUserID' has been added successfully.";
                           $addSuccessful = TRUE;

                           If ($intLevel != 3) {
                                $strURL = makeHomeURL("/security/createUser.php");

                                $msgBody = "Your phpMyInventory username is '$strUserID' and your temporary password is '$strPassword'. ";
                                $msgBody .= "You may log in at $strURL.";
                                mail($strEmail, "phpMyInventory account created: ".date("m-d-Y"), $msgBody);
                           }
                      }
                 }
            }
        }

        Include("../includes/header.inc.php");
        declareError(TRUE);
      ?>

      Users created through this tool will automatically be emailed a random password,
      which they can then use to log in for the first time. <p>

      <u>Explanation of Security Levels</u>: "Full-access" users can do anything, including create and delete users.
      You have full access. "Limited-access" users can edit the inventory database in any way <i>except</i> except for
      the ability to delete entries or create other users. "Read-only" users can view data in this database, but
      not alter it in any way. "No-access" users cannot access this inventory at all; they will not receive an email
      containing account information, or anything else that alerts them to the existence of this system. "No-access"
      users can still be assigned systems, software, and peripherals.

      <p>

      <form name="form1" method="POST" action="createUser.php">
        <p><table border='0' width='415' cellpadding='2'>
          <tr>
            <td width='115'>UserID:</td>
            <td width='300'><input type="text" name="txtUserID" value="<?echo $strUserID;?>" size="20" maxlength="20"></td>
          </tr>
          <tr>
            <td width='115'>First Name:</td>
            <td width='300'><input type="text" name="txtFirstName" value="<?echo $strFirstName;?>" size="40" maxlength="40"></td>
          </tr>
          <tr>
            <td width='115'>Middle Initial:</td>
            <td width='300'><input type="text" name="txtMiddleInit" value="<?echo $strMiddleInit;?>" size="1" maxlength="1"></td>
          </tr>
          <tr>
            <td width='115'>Last Name:</td>
            <td width='300'><input type="text" name="txtLastName" value="<?echo $strLastName;?>" size="40" maxlength="40"></td>
          </tr>
          <tr>
            <td width='115'>Email:</td>
            <td width='300'><input type="text" name="txtEmail" value="<?echo $strEmail;?>" size="40" maxlength="50"></td>
          </tr>
          <tr>
            <td width='115'>Security Level:</td>
            <td width='300'>
                <select name='cboLevel'>
                    <option value=''>&nbsp;</option>
                    <option value='0' <? echo writeSelected($cboLevel, "0"); ?>>Full-access</option>
                    <option value='1' <? echo writeSelected($cboLevel, "1"); ?>>Limited-access</option>
                    <option value='2' <? echo writeSelected($cboLevel, "2"); ?>>Read-only</option>
                    <option value='3' <? echo writeSelected($cboLevel, "3"); ?>>No-access</option>
                </select>
            </td>
          </tr>
      <tr>
      <td width='115'>Department:</td>
      <td width='300'>
      <select name='cboAbteilung'>
      <?
      $db = mysql_connect('localhost' ,'inventory', '20074054');
      $res = mysql_db_query("inventory", "select * from Abteilung");
      while($row = mysql_fetch_array($res)){
        echo "<option value='$row[id_abteilung]'>$row[name] &nbsp;</option>";
      }
      mysql_close($db);
      ?>
      </select>

      </td>
      </tr>

        </table><p>

        <? If (!$addSuccessful) { ?>
        <input type="submit" value="Submit" name="btnSubmit">
        <input type="reset" value="Reset" name="reset">
        <? } ?>
      </form>

      <?
        Include("../includes/footer.inc.php");
      ?>

      Kommentar


      • #33
        Du musst das:
        PHP-Code:
        echo "<option value='$row[id_abteilung]'>$row[name] &nbsp;</option>"
        durch das ersetzen:
        PHP-Code:
        echo "<option value='$row[id_abteilung]'";
        if (
        $row[id_abteilung] == $intAbteilung)
        {
        echo 
        " selected ";
        }
        echo 
        ">$row[name]</option>\n"
        Ich hoffe ich hab es jetzt richtig übersetz auf dein Script.
        *winks*
        Gilbert
        ------------------------------------------------
        Hilfe für eine Vielzahl von Problemen!!!
        http://www.1st-rootserver.de/

        Kommentar


        • #34
          Ich wollt gerade meine Lösung präsentieren. Du warst schneller

          Kommentar


          • #35
            Was hat du für eine Lösung?
            *winks*
            Gilbert
            ------------------------------------------------
            Hilfe für eine Vielzahl von Problemen!!!
            http://www.1st-rootserver.de/

            Kommentar


            • #36
              PHP-Code:
              echo writeSelected($cboAbteilung$intAbteilung); 
              Upps, vielleicht noch die Funktion selber:
              PHP-Code:
              Function writeSelected($SelectValue,$OurValue) {
                    If (
              $SelectValue==$OurValue) {
                        Return 
              "selected";
                    }
                } 
              Zuletzt geändert von Schneggo; 01.08.2002, 12:44.

              Kommentar


              • #37
                Hab gestern hier meine Lösung für ein leeres Auswahlmenuefeld gepostet, leider ergibt sich jetzt folgendes Problem, wenn ich Datensätze lösche, dann werden die neuen vor dem leeren eingefügt. Sprich es wird mir im Auswahlmenue wieder nicht das leere angezeigt. Wer hat eine bessere Lösung?

                War meine Lösung:
                PHP-Code:
                If($cboAbteilung == "1" AND $strError == "") {
                $strError "Please select a department.";
                } Else {
                $intAbteilung $cboAbteilung;

                Für folgendes Menue soll es gelten:
                PHP-Code:
                while($row mysql_fetch_array($res)){
                  echo 
                "<option value='$row[id_abteilung]'"
                Zuletzt geändert von Schneggo; 02.08.2002, 06:34.

                Kommentar


                • #38
                  Hat sich erledigt.

                  Richtiger Code lautet:
                  PHP-Code:
                  $res mysql_db_query("inventory""select * from Abteilung");
                  echo 
                  "<option value=''>&nbsp;</option>\n";
                  while(
                  $row mysql_fetch_array($res)){
                   echo 
                  "<option value='$row[id_abteilung]'"

                  Kommentar


                  • #39
                    welchen wert hat denn $Abteilung?
                    mein Sport: mein Frühstück: meine Arbeit:

                    Sämtliche Code-Schnipsel sind im Allgemeinen nicht getestet und werden ohne Gewähr auf Fehlerfreiheit und Korrektheit gepostet.

                    Kommentar

                    Lädt...
                    X