php if statement and comparison value
<pre><code>&lt;?php
error_reporting(0);
session_start();
if(!$_SESSION["login"]){
print '&lt;script type="text/javascript"&gt;';
print 'alert("You need to login first")';
print '&lt;/script&gt;';  echo '&lt;meta http-equiv="REFRESH" content="0;url=home.php"&gt;';
die();
}
?&gt;
&lt;?php
//This is the book stuff
                ob_start();
                #error_reporting(0);
                $host="localhost"; // Host name
                include 'databaselogin.php';

                $db_name="X"; // Database name
                $tbl_name="Books"; // Table name

                // Connect to server and select databse.
                mysql_connect("$host", "$username", "$password")or die("cannot connect");
                mysql_select_db("$db_name")or die("cannot select DB");
                $id = $_GET["id"];
                $sql = 'SELECT * FROM Books WHERE `id` = '.$id.' LIMIT 1'; 
                $result=mysql_query($sql) or die(mysql_error());
                while($rows = mysql_fetch_array($result)){
?&gt;

&lt;?
//this is user stuff.
            ob_start();
            error_reporting(0);
            $host="localhost"; // Host name
            include 'databaselogin.php';
            $currentuser = $_SESSION["id"];
            $db_name="X"; // Database name
            $tbl_name="users"; // Table name
            $tbl_name="Books"; // Table name


/*
if ($rows['userid'] != $currentusers)
{
print '&lt;script type="text/javascript"&gt;';
print 'alert("you dont have permissions")';
print '&lt;/script&gt;';  echo '&lt;meta http-equiv="REFRESH" content="0;url=home.php"&gt;';
}

*/
?&gt;

&lt;!doctype html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
    &lt;meta charset="utf-8" /&gt;
    &lt;title&gt;Silent Generation&lt;/title&gt;
    &lt;link rel="stylesheet" href="styles.css" type="text/css" media="screen" /&gt;
    &lt;link rel="stylesheet" type="text/css" href="print.css" media="print" /&gt;
    &lt;!--[if IE]&gt;&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;&lt;![endif]--&gt;
    &lt;!--script section--&gt;
    &lt;script type="text/javascript"&gt;

    &lt;/script&gt;

    &lt;!--end script section--&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;div id="wrapper"&gt;&lt;!-- #wrapper --&gt;

    &lt;header&gt;&lt;!-- header --&gt;
        &lt;h1&gt;&lt;a href="#"&gt;Silent Generation&lt;/a&gt;&lt;/h1&gt;
        &lt;h2&gt;Would it be too chezy to say silent but deadly&lt;/h2&gt;
    &lt;/header&gt;&lt;!-- end of header --&gt;

    &lt;nav&gt;&lt;!-- top nav --&gt;
        &lt;div class="menu"&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href="home.php"&gt;Home&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="sell.php"&gt;Sell&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="buy.php"&gt;Buy&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="stores.php"&gt;Stores&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="donate.php"&gt;Donate&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="contact.php"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="support.php"&gt;Support&lt;/a&gt;&lt;/li&gt;

            &lt;/ul&gt;
        &lt;/div&gt;
    &lt;/nav&gt;&lt;!-- end of top nav --&gt;

    &lt;section id="main"&gt;&lt;!-- #main content and sidebar area --&gt;
            &lt;section id="content"&gt;&lt;!-- #content --&gt;



                &lt;article&gt;
                    &lt;form method="GET" action="editadd.php" name="add" id="add"&gt;
                Book Name: 
                &lt;div align="center" style="margin-top:-15px;"&gt; 
                &lt;input type="text" name="name" id="name"  value="&lt;?echo $rows["name"];?&gt;"/&gt;&lt;/div&gt;
                Author's Name: &lt;div align="center" style="margin-top:-15px;"&gt;&lt;input type="text" name="author" id="author"  value="&lt;?echo $rows["author"];?&gt;"&gt;&lt;/div&gt;
                ISBN: &lt;div align="center" style="margin-top:-15px;"&gt;&lt;input type="text" name="ISBN" id="ISBN"  value="&lt;?echo $rows["ISBN"];?&gt;"&gt;&lt;/div&gt;
                Edition : &lt;div align="center" style="margin-top:-15px;"&gt;&lt;input type="text" name="edition" id="edition"  value="&lt;?echo $rows["edition"];?&gt;"&gt;&lt;/div&gt;
                Contact info:&lt;div align="center" style="margin-top:-15px;"&gt; &lt;input type="text" name="contact" id="contact"  value="&lt;?echo $rows["contact"];?&gt;" /&gt;&lt;/div&gt;
                Price: &lt;div align="center" style="margin-top:-15px;"&gt; &lt;input type="text" name="price" id="price" / value="&lt;?echo $rows["price"];?&gt;"&gt;&lt;/div&gt;
                Comments: &lt;div align="center"&gt;&lt;textarea id="comments" name="comments" rows="13" cols="80"  &gt;&lt;?echo $rows["comment"];?&gt; &lt;/textarea&gt;&lt;/div&gt;
                &lt;div align="center"&gt;&lt;input type="submit" value="Submit" style="width:660px;height:70px;"/&gt;&lt;/div&gt;
                &lt;input type="hidden" name="id" value="&lt;?echo $rows["id"];?&gt;" /&gt;
                &lt;/form&gt;
                current user: &lt;?echo $currentuser;?&gt;
                posted by: &lt;?echo $rows['userid']?&gt;
                &lt;?
                }
                ob_end_flush();
                if ( intval($rows['userid']) ==  intval($currentusers))
                {echo "true";}
                else
                {echo "fasle";}

                ?&gt;
                &lt;/article&gt;


                    &lt;pre&gt;









                            &lt;/pre&gt;







            &lt;/section&gt;&lt;!-- end of #content --&gt;

        &lt;aside id="sidebar"&gt;&lt;!-- sidebar --&gt;
        &lt;?php
        error_reporting(0);
        session_start();
        if(!$_SESSION["login"]){
        ?&gt;
                &lt;h3&gt;Login&lt;/h3&gt;
              &lt;form method="post" ACTION="login.php"&gt;
            E-mail
            &lt;input type="text" id="myusername" name="myusername" /&gt;
            &lt;br/&gt;
            &lt;br/&gt;
            Password    &lt;input type="password" id="mypassword" name="mypassword" /&gt;
            &lt;br/&gt;
            &lt;br/&gt;
            &lt;INPUT TYPE="submit" VALUE="Submit" /&gt;
            &lt;br/&gt;
            &lt;input TYPE="button" VALUE="Password?"onclick="javascript:document.location='lostpass.php'; return false; "/&gt;
            &lt;/form&gt; 
            &lt;pre&gt;
            &lt;/pre&gt;
                &lt;h3&gt;Register&lt;/h3&gt;
                    &lt;form method="post" action="register.php" name="register" id="register"&gt;Name &lt;br/&gt;&lt;input type="text" id="name" name="name" &gt;&lt;br/&gt;
                    Email &lt;br/&gt; &lt;input type="text" id="email" name="email"&gt;&lt;br/&gt;
                    School &lt;br/&gt; &lt;select name="school" id="school"&gt;
                            &lt;option value='Sierra College'&gt;Sierra College&lt;/option&gt;
                            &lt;option value='American River'&gt;American River&lt;/option&gt;
                            &lt;option value='UC Davis'&gt;UC Davis&lt;/option&gt;
                            &lt;option value='UCLA'&gt;UCLA&lt;/option&gt;
                            &lt;option value='UCSD'&gt;UCSD&lt;/option&gt;
                            &lt;/select&gt;&lt;br/&gt;
                    Password &lt;br/&gt; &lt;input type="password" id="password" name="password"&gt;&lt;br/&gt;
                    Conform Password &lt;br/&gt; &lt;input type="password" id="password2" name="password2"&gt;&lt;br/&gt;

                    &lt;br/&gt;
                    &lt;input type="submit" value="Submit"&gt;
                    &lt;input type="reset" value="Clear"&gt;
                    &lt;/form&gt;                         
&lt;?}else{?&gt;
&lt;h3&gt;Welcome&lt;/h3&gt; &lt;?php echo $_SESSION["username1"] ?&gt;

&lt;a href="logout.php"&gt;Logout&lt;/a&gt;
&lt;?}
?&gt;
                &lt;h3&gt;Connect With Us&lt;/h3&gt;
                    &lt;ul&gt;
                        &lt;li&gt;&lt;a href="#"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
                        &lt;li&gt;&lt;a href="#"&gt;Facebook&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;

        &lt;/aside&gt;&lt;!-- end of sidebar --&gt;

    &lt;/section&gt;&lt;!-- end of #main content and sidebar--&gt;

        &lt;footer&gt;
        &lt;section id="footer-area"&gt;

            &lt;section id="footer-outer-block"&gt;


                    &lt;aside class="footer-segment"&gt;
                            &lt;h4&gt;Joubin Jabbari&lt;/h4&gt;
                                &lt;p&gt;&amp;copy; 2011 &lt;a href="#"&gt;Silentgen.com&lt;/a&gt; 
                                presents a site by a student for students. 
                                &lt;/p&gt;
                    &lt;/aside&gt;&lt;!-- end of #fourth footer segment --&gt;

            &lt;/section&gt;&lt;!-- end of footer-outer-block --&gt;

        &lt;/section&gt;&lt;!-- end of footer-area --&gt;
    &lt;/footer&gt;

&lt;/div&gt;&lt;!-- #wrapper --&gt;
&lt;!-- Free template created by http://freehtml5templates.com --&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The above is my entire code.... the fist few blocks of php is all you need to look at. All I want to is to make sure that the person is trying to edit this post is the person that has posted it. otherwise, they need to be rerouted else where. </p>
