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
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
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
Old 12-04-2007, 10:16 PM   #2 (permalink)
The Wanderer
Newcomer 
 
Swordbeta's Avatar
 
Join Date: Dec 2007
Location: Holland
Posts: 18
Thanks: 0
Swordbeta is on a distinguished road
Default

First of all,you keep repeating <?php,you need to use this one.
I can't really say what's wrong since I don't speak your language but this is at least what I can say:
PHP Code:
if(isset($_POST['submit'])){ 
And I'm also not sure about the query:
PHP Code:
$query mysql_query("  INSERT INTO `protocol` SET `p_who` = '$who',`p_meeting` ='$meeting',`p_protocol` ='$protocol'"); 
Swordbeta is offline  
Reply With Quote
The Following User Says Thank You to Swordbeta For This Useful Post:
Tanax (12-05-2007)
Old 12-04-2007, 10:19 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

In addition to Swordbeta's post, I don't see a session_start() call in that script:

php Code:
<?php

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


    session_start();

    include('config.php');
    include('header.php');
   
    mysql_connect('localhost', 'root', '');
    mysql_select_db('lemons')

    ...
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
Tanax (12-05-2007)
Old 12-05-2007, 05:55 AM   #4 (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

Quote:
Originally Posted by Swordbeta View Post
First of all,you keep repeating <?php,you need to use this one.
I can't really say what's wrong since I don't speak your language but this is at least what I can say:
PHP Code:
if(isset($_POST['submit'])){ 
And I'm also not sure about the query:
PHP Code:
$query mysql_query("  INSERT INTO `protocol` SET `p_who` = '$who',`p_meeting` ='$meeting',`p_protocol` ='$protocol'"); 
Thanks, but it shouldn't be a problem, since checking for $_POST['submit'] is the same as checking if it's set o.O

THe query was no problem :) It's working

Quote:
Originally Posted by Wildhoney View Post
In addition to Swordbeta's post, I don't see a session_start() call in that script:

php Code:
<?php

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


    session_start();

    include('config.php');
    include('header.php');
   
    mysql_connect('localhost', 'root', '');
    mysql_select_db('lemons')

    ...
OFCOURSE!!! It works now :D:D Wieee, thanks Adam! <3
Tanax is offline  
Reply With Quote
Reply



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 11:01 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