2 Replies Latest reply on Nov 26, 2009 8:20 AM by Matt Le Fevre

    Form requires all text

    jeeepU Level 1

      I have five TextInput boxes that I want to send to PHP to be sent to MySQL. It works if all the textinput boxes are filled. It doesn't work if the all the textinput boxes are not filled out (2/5, 3/5, etc.) How do I get the data sent even if there are several empty textboxes?

        • 1. Re: Form requires all text
          Pappa_John Level 1

          I would handle this in the PHP code - simply check to see if the $_POST variable (or $_GET, if that's what you're using) is set and contains data, and adjust your query accordingly. IMHO, this is something you should be doing anyway, as it gives you the opportunity to sanitize the data before inserting into your database.

          • 2. Re: Form requires all text
            Matt Le Fevre Level 4
            <mx:Button click="sendInfo.send()"/>
            
            <mx:HTTPService id="sendInfo" showBusyCursor="true" method="POST"  url="http://localhost/sendInfo.php" useProxy="false">
                    <mx:request xmlns="">
                    <Box1>
                        {Box1.text}    
                    </Box1>
                    <Box2>
                        {Box2.text}    
                    </Box2>
                    <Box3>
                        {Box3.text}    
                    </Box3>
                    <Box4>
                        {Box4.text}    
                    </Box4>
                    <Box5>
                        {Box5.text}    
                    </Box5>
                    </mx:request>
                </mx:HTTPService>

             

            ==>

             

            <?php
                
                $Box1 = "undefined";
                $Box2 = "undefined";
                $Box3 = "undefined";
                $Box4 = "undefined";
                $Box5 = "undefined";
                
                if ($_POST["Box1"]){
                    $Box1 = $_POST["Box1"]
                }
                if ($_POST["Box2"]){
                    $Box2 = $_POST["Box2"]
                }
                if ($_POST["Box3"]){
                    $Box3 = $_POST["Box3"]
                }
                if ($_POST["Box4"]){
                    $Box4 = $_POST["Box4"]
                }
                if ($_POST["Box5"]){
                    $Box5 = $_POST["Box5"]
                }
                    
                mysql_connect('server_name', 'user_name', 'password');
                mysql_select_db("database_name");
            
                mysql_query("INSERT INTO table_name (Col1, Col2, Col3, Col4, Col5) VALUES ('$Box1' , '$Box2', '$Box3' , '$Box4' , '$Box5'))"; 
            
            ?>