TechnoMonkey
TechnoMonkey

Reputation: 1

For some reason I do not seem to be parsing my second if statement

What am I doing wrong? then I never get "OK".

I had tried some other code that contained too much HTML and could not clean it up well enough to suit me. My trouble seems to be a lack of ability in the form area.

<?php
include "connect.php";

  session_start();
  if (isset($_SESSION['username']))
  {
    print "<A href='addquote.php'>Add a quote</a> | <A href='deletequote.php'>Delete a quote</a> | <A href='search.php'>Search</a><br><br>";

    if(isset($add))
    {
        print "OK";

        $addquote="Insert into rquote_quotes (quote) values ('$add')";
        $result=mysql_query($addquote) or die("Could not insert quote");

        if($result)
        {
            print "Quote added successfully";
        }
        else
        {
            print "ERROR";
        }
    }
    else
    {
        print "<form action='addquote.php' method='post'>";
        print "Type quote here<br>";
        print "<textarea name='quote' rows='3' cols='20'></textarea><br>";
        print "<input type='submit' name='add' value='add quote'></form>";
    }
  }
  else
  {
    print "Not logged in as Administrator, please <A href='login.php'>Login</a>";
  }

?>

Upvotes: 0

Views: 30

Answers (1)

Sam Ivichuk
Sam Ivichuk

Reputation: 1038

You need to change:

if(isset($add))

to this:

if(isset($_POST['add']))

Upvotes: 1

Related Questions