Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 24th, 2006, 11:22 AM
Ols Ols is offline
Registered User
 
Join Date: Jul 2006
Location: Berlin, , Germany.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple login but nothing happens...

Usually problematic codes seem to give the programmer a notice of failure, but my problem concerning login is that nothing happens at all, which is strange considering that my code is the same as in the book Beginning PHP5, just changed in the databases to fit my own.

What could be wrong? It would be nice solving this easy problem, since every answer I've seen concerning login is a lot more complicated, and then I wanna understand the easy one first.

Would be nice if someone know the (probably easy) answer.
Best regards,
Ols


<?php
//fulatyper.php

include "commondatabase.inc";


if(!isset($User)){
    loginform();
    exit;}
else{
    session_start();
    session_register("user", "pass");
    $Name = authentic($_POST['user'], $_POST['pass']);

    if(!$Name){
        $PHP_SELF = $_SERVER['PHP_SELF'];
        session_unregister("user");
        session_unregister("pass");

        echo "Tillträde nekat. " .
            "Du måste ange en giltig användare. " .
            "Klicka på följande länk för att försöka igen.<br>\n";
        echo "<a href=\"$PHP_SELF\">Login</a><br>";

        exit;}

    else{
        echo "Välkommen, $Name!";}}


function loginform() {
    global $PHP_SELF;

    ?>

    <html>
    <head>
    <title>Login</title>
    </head>

    <body>
    <form method="post" action="<?php echo "$PHP_SELF"; ?>">
        <div align="center"><center>
            <h3>Logga in!</h3>

        <table border="1" width="200" cellpadding="2">
        <tr><th width="18%" align="right" nowrap>Id</th>
            <td width="82%" nowrap>
            <input type="text" name="user" size="8">
            </td></tr>
        <tr><th width="18%" align="right" nowrap>Lösen</th>
            <td width="82%" nowrap>
            <input type="password" name="pass" size="8">
            </td></tr>
        <tr><td width="100%" colspan="2" align="center" nowrap>
            <input type="submit" value="login" name="Submit">
            </td></tr>
        </table>
        </center></div>
    </form>
    </body>
    </html>

    <?php }


function authentic($User, $Pass) {
    global $DefaultDatabase;

    $Database = databaseconnection($DefaultDatabase);
    if(!$Database) errormessage(sqlerror());

    $Query = "SELECT username FROM CommonPeople
        WHERE userid = '$User' AND userpassword = password('$Pass')";
    $Result = mysql_query($Query);

    if(!mysql_num_rows($Result)){
        return 0;
    else{
        $Data = mysql_fetch_row($Result);
        return $Data[0];} }

?>
Reply With Quote
  #2 (permalink)  
Old July 25th, 2006, 07:14 PM
Friend of Wrox
 
Join Date: Jan 2006
Location: San Francisco, CA, USA.
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What does the line:

<form method="post" action="<?php echo "$PHP_SELF"; ?>">

Compile to? Can you view source and paste what is written to the client?

Jon Emerson
http://www.jonemerson.net/
Reply With Quote
  #3 (permalink)  
Old July 29th, 2006, 05:04 AM
Ols Ols is offline
Registered User
 
Join Date: Jul 2006
Location: Berlin, , Germany.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not quite sure it does anything, but it seems to call the page itself. Hope the code helps a bit more.


<html>
    <head>
    <title>Login</title>
    </head>

    <body>
    <form method="post" action="/fulatyper.php">
        <div align="center"><center>
            <h3>Logga in!</h3>

        <table border="1" width="200" cellpadding="2">
        <tr><th width="18%" align="right" nowrap>Id</th>
            <td width="82%" nowrap>
            <input type="text" name="user" size="8">
            </td></tr>
        <tr><th width="18%" align="right" nowrap>Lösen</th>
            <td width="82%" nowrap>
            <input type="password" name="pass" size="8">
            </td></tr>
        <tr><td width="100%" colspan="2" align="center" nowrap>
            <input type="submit" value="login" name="Submit">
            </td></tr>
        </table>
        </center></div>
    </form>
    </body>
    </html>
Reply With Quote
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Login Logout Apocolypse2005 PHP Databases 1 September 25th, 2008 01:17 AM
simple Login Nuwang Forum and Wrox.com Feedback 1 June 23rd, 2008 11:36 PM
Simple ASP.NET Membership Provider Login jumpseatnews ASP.NET 2.0 Basics 0 July 16th, 2006 10:53 AM
Simple Java Login Page skchbs Java GUI 0 October 9th, 2003 06:14 PM



All times are GMT -4. The time now is 03:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.