Problem with Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
szms
Forum Contributor
Posts: 101
Joined: Thu Jun 26, 2003 12:23 pm

Problem with Form

Post by szms »

You win the award for most annoying cross-posting ever (5 total). :) Please don't do it again.

Hi everyone!!

I am having problem with HTML FORM and PHP implementation. In my following code I am always gettimg the output for "Hello" For some reason my if (!$Submit) is not working. And when I do not use this condition I get the check box out put but that does not help me anyway because I want activate my Delete button so that I can delete the items selected from checkbix. Can you help me? Thank you.

Code: Select all

<form action = "SendDomainName.php" Method = "GET">

<?php
    require("......");
    $link = mysql_connect($host,$user,$pass);
    if (!$link)
        die("Couldn't connect to MySQL");

     mysql_select_db($db)
        or die("Couldn't open $db: ".mysql_error());

    if (!$submit)
    &#123;
            if (isset($_POST&#1111;'DomainMenu']))
            &#123;
                $table = "DomainEquivalence";
                $val = $_POST&#1111;'DomainMenu'];
                if($val != '')
                &#123;
                   
                    $result = mysql_query("SELECT First FROM $table where Name = '". $_POST&#1111;'DomainMenu'] ."'");
                    if (!$result)
                    &#123;
                        print "Query Failed: " .mysql_error();
                    &#125;
                    else
                    &#123;
                        $Next_ID = mysql_result($result, 0, 'First');
                        print "<br> Select any of the following Domain for deletion from $val :<p>";
                        while($Next_ID != NULL)
                        &#123;
                            $table = "DomainEquivalentList";
 $result = mysql_query("SELECT Domain_ID, Next_ID from $table where DomainEquivalentList_ID= $Next_ID");
                            $Next_ID = mysql_result($result,0,'Next_ID');
                            $Domain_ID = mysql_result($result,0,'Domain_ID');
                            $table = "Domain";
                            $result = mysql_query("SELECT Name from $table where Domain_ID =  $Domain_ID");
                            $Domain_Name = mysql_result($result,0,'Name');

?>
                            <INPUT TYPE="checkbox" NAME="Name&#1111;]" VALUE="<?php echo $Domain_Name;?>">
<?php

                             print "$Domain_Name<br>";
                        &#125;
?>
                            <input type="submit" value="Delete" name="submit">
                            <input type = "reset" value = "Reset" name = "reset">
</form>
<?php
                        &#125;


     
                  &#125;
     
               else
                 print "Plese Select a Domain and try again";
            &#125;


           &#125;
           else if ($submit)
               print "Hello";
 mysql_close($link);
?>
:roll:
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

You are using mixed methods for submitting and reading data, your form is being submitted as "GET" but you are accessing parameters via "POST".

Also, your $submit would not be checked as its a GET var:

Code: Select all

if (!$_GET['submit'])
    { 
         ......
Regards,
Post Reply