TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 12-04-2007, 10:09 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Newbiee Gah

Seriously.. I'm going NUTS :|

Mom wants me in bed, but I wanna get this script to work, but it doesn't and I'm stressed, and I can't for the love of god(!!!) find the error.

php Code:
<?php

/**
 * @author Tanax
 * @copyright 2007
 */

    include('config.php');
    include('header.php');
   
    mysql_connect('localhost', 'root', '');
    mysql_select_db('lemons')
   
    if(isset($_SESSION['logged'])) {
       
        if($_POST['submit']) {
           
            $who = $_POST['who'];
            $meeting = $_POST['meeting'];
            $protocol = $_POST['protocol'];
               
            $query = mysql_query("  INSERT INTO
                                        `protocol`
                                    SET
                                        `p_who` = '"
.$who."',
                                        `p_meeting` = '"
.$meeting."',
                                        `p_protocol` = '"
.$protocol."'
                                           
                                    "
);
                                       
            if($query) {
                   
                echo 'Protokoll tillagt!';
                echo '<br /><a href="insert.php">Lägg till flera</a>';
                   
            }
               
            else {
                   
                echo 'Nåt gick fel!';
                   
            }
               
        }
           
        else {
           
            ?>
               
            <form action="insert.php" method="POST">
            <h3>Vilka:</h3><br />
            <input name="who" type="text" /><br />
            <h3>När:</h3><br />
            <input name="meeting" type="text" /><br />
            <h3>Protokoll:</h3><br />
            <textarea name="protocol" cols="60" rows="20"></textarea><br />
            <input type="submit" name="submit" value="Lägg till!" />
            </form>
                   
            <?php
           
        }
       
    }
   
    else {
   
        if($_POST['auth']) {
           
            $user = $_POST['user'];
            $pass = $_POST['pass'];
           
            if($user != $admin || $pass != $password) {
               
                echo 'Användarnamn eller lösenord är inkorrekt!';
                echo '<br /><a href="insert.php">Försök igen</a>';
               
            }
           
            else {
           
                $_SESSION['logged'] = 'yes';
               
                if(isset($_SESSION['logged'])) {
                   
                    echo 'Du har nu loggats in! Klicka på <a href="insert.php">denna</a> länk för att lägga till protokoll!';
           
                }
               
                else {
                   
                    echo 'Något gick fel i inloggningsprocessen!';
                   
                }
               
            }
       
        }
       
        else {
           
            ?>
           
            <form action="insert.php" method="POST">
            <h3>Användarnamn:</h3><br />
            <input name="user" type="text" /><br />
            <h3>Lösenord:</h3><br />
            <input name="pass" type="text" /><br />
            <input type="submit" name="auth" value="Logga in!" />
            </form>
           
           
            <?php
           
        }
       
    }
       
    include('footer.php');

?>

Yes, it's a really basic script. I'm only using it for a small site, so I don't use a user system in the database.

I store the admin password and the username in the config.

The messages are in swedish, but I'm pretty sure you can figure out what they mean based on the coding.

The error is that I login, and it echo's "You are logged in, click her to add a protocol", and when I do that, the
PHP Code:
if(isset($_SESSION['logged'])) 
should execute, since I've set the session...
I actually even check before it links me to the same page, that the session is set, and it only echoes the "you are logged in.." if the session is set.

Yet, it doesn't work. When I'm logged in, and click the link, I still get to see the login form -.-

I know this is a very.. insecure script. But it's really a SMALL website, and the ones that are viewing it, doesn't have a clue what website programming is, nonetheless hacking. So yea...

Anyways, please help me :((( You are my only hooooope xD haha
Tanax is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:29 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design