#1
  1. How can I meet Jenny?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    199
    Rep Power
    7

    Question Popup Error Message?


    How can I include an error popup message with my php code? I was told that javascripting was my only real option? I honestly have no clue how to get that to work.

    Any ideas?

    Basically Im trying to validate data to see if the record type is listed and if so popup the error message:

    PHP Code:

    // Test loop of the data inputted to verify the data inputted into the table.
    if ($testit['PassGood'] == 'Yes') {
        (
    need error popup code here)
        } else {
        
    mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `ProdNum` = '$prodNum'") or die(mysql_error());
        
        
    // Notify the User that the record is being copied to the ProdHist Table.
        
    print "<p>This record was updated in the History Table.</p>";
        
        
    // Insert the new data for this record in the main Prod Table.
    (code to be developed here
    I honestly have no idea to create these types of popups. Is there some good tutorials out there for this?

    Thanks in advance
  2. #2
  3. garish grotesque gargoyle
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2006
    Location
    gracing gargantuan gothic gateways
    Posts
    1,337
    Rep Power
    1037
    please give full context so we can determine what kind of solution you're looking for. are you looking for a way to notify the user before submitting a form, or a way to notify user when the form page reloads? by 'pop-up' do you mean an actual new browser window, an alert dialog, or a floating html message on the screen?

    it's really hard to even tie down what you want to happen.. you want the <p> tag from your message to be in a popup, or the mysterious '(need error popup code here)'? what happens with that <p> text right now when the page is run?

    please post back with more info and I'll see if I can steer you in the right direction. good luck!

    "Human history becomes more and more a race between education and catastrophe." (H.G. Wells)
    "Giving me a new idea is like handing a cretin a loaded gun, but I do thank you anyhow, bang, bang." (Philip K. D!ck)
  4. #3
  5. How can I meet Jenny?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    199
    Rep Power
    7
    Sorry... I truly do not have all the code completed... so to provide real code examples may be difficult.

    What I'm trying to do is the following:

    1) If the user enters in data that was previously entered into the table with a particular worked processed (let's say if I repackaged a unit for shipping and I enter that same product number into this form) the code will check the table if that ProdNum exists... if so the I need an error message to pop up to say something like "this unit is in the system.".

    2) the code is html forms with php and some javascript since this form is a popup window created from javascript on the parent page.

    This is an example of what I'm looking for.... again I cannot provide real code since I do not have that thought out 100% yet...

    Here is the variable data:

    PHP Code:
    // variables from the SELECT Query
    $done=$testit['PassGood']; 
    PHP Code:
    // Test loop of the data inputted to verify the data inputted into the table.
    if ($done == 'Yes') {
        ?>
        <head>
        <script language="JavaScript">
        alert("This Unit Is in the system.  Please try another");
        </script>
        </head>
        <?php
        
    } else {
        
    mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `ProdNum` = '$Prod'") or die(mysql_error());
        
        
    // Notify the User that the record is being copied to the ProdHist Table.
        
    print "<p>This record was updated in the History Table.</p>";
        
        
    // Insert the new data for this record in the main Prod Table.
        
    mysql_query("UPDATE `Prod` 
                    SET `BatchNum` = '
    $batch'
                    Set `ProdNum` = '
    $Prod'
                    Set `OrderNum` = '
    $order'
                    Set `Diagnositc` = '
    $Diag'
                    Set `ModelSku` = '
    $sku'
                    Set `ModelType` = '
    $type'
                    Set `CardType` = '
    $card'
                    Set `Kitted` = '
    $kitted'
                    Set `qcstatus` = '
    $qc'
                    Set `TestResults` = '
    $ota'
                    Set `undernotes` = '
    $notes'
                    Set `DateRep` = Now()
                    WHERE `ProdNum = '
    $Prod'") or die(mysql_error());

        @
    mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); 

     
    mysql_close($con);
     }
    }
    ?>
    Here is the form I have setup:

    PHP Code:
    <!-- This section will create the form for the input Unit popup window. -->
    <form method="post" name="prod" action="testload.php"><font color="#000080" face="Arial">
    <input type="hidden" name="param1" value="<?php echo $imei?>" />  
     <p><u><b><font size="2" font color="maroon" font type="Tahoma">Product Test Section:</font></b></u></p>
        <p><font face="Arial" font size="2">
          <b>OTA Pass/Fail:&nbsp;&nbsp; <select name="TestResults" size="1" name="TestResults">
        <option value="NULL">--</option>
        <option value="Passed">Passed</option>
        <option value="Failed">Failed</option>
        </select></b></font>&nbsp;&nbsp;&nbsp; <font face="Arial" font size="2">
        <td <font color="Navy" size="3" face="Tahoma"><b><u>Notes:</u>&nbsp;&nbsp;&nbsp;</b></font></td>        
         <td><input name="undernotes" type="text" id="undernotes" size="35">
        <p align="center">
        <input type="submit" value="Repair Data Submit" name="submit" onclick="window.close()"></p>
    </form>
    Not sure if I supplied what you are in need of, but if not just let me know.
    Last edited by twilsonsnalog; August 8th, 2008 at 01:18 PM.
  6. #4
  7. How can I meet Jenny?
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    199
    Rep Power
    7
    Well I got the error message to work the problem is I had to take on the following command to see it:
    PHP Code:
    <input type="submit" value="Repair Data Submit" name="submit" onclick="window.close()"></p
    Is there a way to have the error message pop up when the submit button is click, but also shutdown window as well... like a time delay or something?

    Here the code again:

    PHP Code:
    <?php
    if (isset($_GET['param1']) && !empty($_GET['param1'])){
        
    $imei=$_GET['param1'];     
        echo 
    "Your Prod Number is:\n$prod"
        }
        elseif (
    $_SERVER['REQUEST_METHOD'] == 'POST'){    
        
    $imei=$_POST['param1']; 
        
    // echo "Your Bloody Prod Number is:\n$prod";    
               
    // Main PHP code for connecting to the database for production processing
    $con mysql_connect("localhost","user","xxxxxxx") or die('Connection: ' mysql_error());;
    mysql_select_db("logdata"$con) or die('Database: ' mysql_error());

    //Initial search and selection.
        
    $grabit "SELECT * FROM `Prod` WHERE `ProdNum` = '$prod";
        
    $testdata mysql_query($grabit) or die(mysql_error());
        
    $testit mysql_fetch_assoc($testdata) or die(mysql_error()); 
    //SQL query for is the Prod Num was completed fine, this will populate the PROD table accordingly.

    // This query is to generate values for validation.
    echo "\nThere is a Completed Transaction for this Record in this table.";
    // variables from the SELECT Query
    $done=$testit['PassGood'];
    $batch=$testit['BatchNum'];
    $sku=$testit['ModelSku'];
    $type=$testit['ModelType'];
    $rts=$testit['RTSNum'];
    $card=$testit['CardType'];
    $notes=$_POST['undernotes'];

    // variables for this section only!
    $qc =$_POST['qcstatus'];
    $Diag 'Passed';
    $ota =$_POST['TestResults'];

    // Test loop of the data inputted to verify the data inputted into the table.
    if (isset($done)) {
        
    ?>
        <head>
        <script language="JavaScript">
        alert("This Unit has been passed as ALL GOOD.  Please forward to Kitting.");
        </script>
        </head>
        <?php
        
    } else {
        
    mysql_query("INSERT INTO `Prod` (`BatchNum`,`ProdNum`,`ModelNum`,`Diagnostic`,`ModelSku`,`ModelType`,`CardType`,`TestResults`,`undernotes`,`DateRep`) 
    VALUES ('
    $batch', '$prod','$modnum','$Diag','$sku','$type','$card','$ota','$notes', Now())") or die(mysql_error()); 
    @
    mysql_query("DELETE FROM `Prod` WHERE `ProdNum` = 0"); 
        
        
    mysql_query("INSERT INTO `ProdHist` SELECT * FROM `Prod` WHERE `IMEINum` = '$prod'") or die(mysql_error());
        
        
    // Notify the User that the record is being copied to the ProdHist Table.
        
    print "<p>This record was updated in the History Table.</p>";
        
    mysql_close($con);
     }
    }
    ?>    
    <body>
    <P>

    <!-- This section will create the form for the "Repair" Unit popup window. -->
    <form method="post" name="prod" action="repair.php"><font color="#000080" face="Arial">
    <input type="hidden" name="param1" value="<?php echo $prod?>" />  
     <p><u><b><font size="2" font color="maroon" font type="Tahoma">Under 30 Repair OTA Section:</font></b></u></p>
        <p><font face="Arial" font size="2">
          <b>OTA Pass/Fail:&nbsp;&nbsp; <select name="TestResults" size="1" name="TestResults">
        <option value="NULL">--</option>
        <option value="Passed">Passed</option>
        <option value="Failed">Failed</option>
        </select></b></font>&nbsp;&nbsp;&nbsp; <font face="Arial" font size="2">
        <td <font color="Navy" size="3" face="Tahoma"><b><u>Notes:</u>&nbsp;&nbsp;&nbsp;</b></font></td>        
         <td><input name="undernotes" type="text" id="undernotes" size="35">
        <p align="center">
          <input type="submit" value="Repair Data Submit" name="submit"></p> 
        </td>
    </body>
    </form>
    I desire the popup form to be closed when the user clicks submit, but the error message to popup even if the form is closed... OR Have the error message popup when the SUBMIT button is clicked and when the OK button on the error message is clicked both the form and message go away. The only problem is what if the user enters in a value that is not in the table and the ELSE option kicks in. Currently, without the onclick=windows.close() function, the form remains. If I put the function back in the error message and form disappear so the user has no idea what transpired.

    I guess I would like my cake and eat it too!

    Any ideas what I'm doing wrong?

    thanks,
  8. #5
  9. garish grotesque gargoyle
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2006
    Location
    gracing gargantuan gothic gateways
    Posts
    1,337
    Rep Power
    1037
    I think this actually belongs in the PHP forum, since what you're asking is how to display a response to a form request. You're saying, the popup is what contains the form in question. when the form in the popup is submitted, it should show a response message - either 'yay it worked' or 'already in system - not processed', and then the window should either close automatically or close on a button press...

    your PHP form page (in the popup) should return a response message either way. then, to close automatically after a delay, add this to a script tag in the HEAD:

    Javascript Code:
    onload = function() { // set up a function once the page is loaded
      setTimeout(function() { // set a timeout for the following code
        self.close(); // close the window
      },5000); // 5 seconds (5000 ms) after load this will be run
    }


    to make it close after the user acknowledges, put a button on the page like:

    Code:
    <button id="closeButt">Close Window</button>
    and assign the activity onload like in the last example:

    Javascript Code:
    onload = function() { // set up a function once the page is loaded
      document.getElementById('closeButt').onclick = function() { // when closeButt is clicked...
        self.close(); // close the window
      }
    }


    seems to me that this is what you're looking for. try putting it into practice, and come back if your code isn't working -- it's hard to answer a question that hasn't been fully formulated yet. Also, keep in mind there are LOTS of forums at DevShed; try to put your question into the forum where it most applies (but only post it in one forum; cross-posting is bad form). good luck!

    "Human history becomes more and more a race between education and catastrophe." (H.G. Wells)
    "Giving me a new idea is like handing a cretin a loaded gun, but I do thank you anyhow, bang, bang." (Philip K. D!ck)

IMN logo majestic logo threadwatch logo seochat tools logo