$_POST and ISSET ($_GET)

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
agupta2683
Forum Newbie
Posts: 2
Joined: Thu Jul 06, 2006 11:11 am

$_POST and ISSET ($_GET)

Post by agupta2683 »

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi All,

I have  a form which asks a user to add and delete the fields. These fields r defined in the backend database. I'm using POST method on the submission and once the user presses submit, the control goes to the form_submit page. This page uses isset($_get[' ']) method to retrive the values entered by the user and perform insertion or deletion operations in the database. The code is not throwing any error . when a user tried to enter the values for the fields on the form, the insertion or deletion operations are not performed in the database.

I have checked that I have made connection to the database. 

I tried different if else combinations but it doesnt seem to work. 

I have also attached the code if anyone can be kind enough to have a look at it. 

I would highly appreciate any sort of help in this.

CODE

Code: Select all

<?php
  
        if( isset( $_GET[ 'region' ], $_GET ['addstate'],$_GET ['deletestate']) )
       {
        $addstate = $_GET[ 'addstate' ];
        $deletestate = $_GET[ 'deletestate' ];    
        $region = $_GET[ 'region' ];
        $query  = "INSERT INTO dbo.off_campus_ashish VALUES ('$region', '$addstate') AND DELETE * FROM dbo.ashishdate WHERE region = '$region' AND state = '$deletestate'" ; 
        mssql_query($query);
        //$result = db_query( "INSERT INTO dbo.ashishdate VALUES ($category, $addate) AND DELETE * FROM dbo.ashishdate WHERE category = $category AND date = $deletedate"); 
        }
       else
       {
       if( isset( $_GET[ 'region' ],$_GET ['addstate']) )
        {
        $addstate = $_GET[ 'addstate' ];
        $region = $_GET[ 'region' ];
        $query  = "INSERT INTO dbo.off_campus_ashish VALUES ('$region', '$addstate')"; 
        mssql_query($query);
        //$result = db_query( "INSERT INTO dbo.ashishdate VALUES ($category, $addate)"); 
        }
        
       else 
       {
        if (isset( $_GET[ 'region' ], $_GET ['deletestate']) )
        {
        $deletestate = $_GET[ 'deletestate' ];    
        $region = $_GET[ 'region' ];
        $query  = "DELETE * FROM dbo.off_campus_ashish WHERE region = '$region' AND state = '$deletestate'" ; 
        mssql_query($query);
        //$result = db_query("DELETE * FROM dbo.ashishdate WHERE category = $category AND date = $deletedate"); 
        }
        else
         {
         echo "You did not submit all the required information.  Please go back and try again.";
         }
        }
        }
    ?>

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Your if statements are not formatted correctly. Format them like this..

Code: Select all

if ((isset( $_GET[ 'region' ])) AND (isset($_GET ['addstate'])) AND (isset($_GET ['deletestate'])))
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You can also use the bitwise comparison operators...

Code: Select all

if ( (isset( $_GET[ 'region' ])) && (isset($_GET ['addstate'])) && (isset($_GET ['deletestate'])) )
But regardless of how you do it, when you post code in the forums, can you please use the appropriate bbCode tags (

Code: Select all

for example). Thanks.
Post Reply