Boat Drinks  

Go Back   Boat Drinks > General > Computer and Consoles

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 07-02-2009, 16:13   #1
Joe 90
Absinthe
 
Joe 90's Avatar
 
Join Date: Jan 2007
Location: Chester
Posts: 2,345
Default Any PHP coders around here?

I'm having issues with errors and i can't stand debugging PHP.

i've written a forum, got all the code, forms, scripts etc sorted. but obviously when you put it up it moans.

http://homepages.shu.ac.uk/~mwalker8/bbad/forum/

The registration works fine, login doesnt no idea why at the moment.

main problem though i guess;
Code:
Fatal error: Call to undefined function mysqli_connect()
so i'm using that standard sqli function like this;
Code:
$con = mysqli_connect($host,$user,$passwd) or die(mysql_error());
does anybody know exactly what this function does? its obviously in compatible with the uni server so i guess i need to write it out myself as it were.


also, theres that login that doesn't work...
so my code;
login form
Code:
<?php if (isset($login_error)) { ?>
There was an error: <?php echo $login_error; ?>, please try again.
<?php } ?>
<form action="login_submit.php" method="post">

<b>Username:</b> <input type="text" size="20" maxlength="20" name="username"
<?php if (isset($_POST['Username'])) { ?> value="<?php echo $_POST['Username']; ?>" <?php } ?>/><br />

<b>Password:</b> <input type="password" size="20" maxlength="10" name="Password" /><br />

<input type="submit" name="submit" value="Login" />
</form>
login script;
Code:
<?php

// Include start file
include 'start.php';

if (!isset($_POST['submit']))
{
     // Show the form
     include 'login.php';
     exit;
}
else
{
     // Try and login with the given Username & pass
     $result = user_login($_POST['Username'], $_POST['Password']);

     if ($result != 'Correct')
     {
          // Reshow the form with the error
          $login_error = $result;
          include 'login.php';
     }
     else
     {
          echo 'Thank you for logging in, please <a href="login.php">click here</a>.';
     }
}
?>
and those login functions;
Code:
function user_login($Username, $Password)
{
     // Try and get the rand from the database using the Username
     $query = "select rand from forum_Users where Username='$Username' limit 1";
     $result = mysql_query($query);
     $user = mysql_fetch_array($result);

     // Using the rand, encrypt the given Password to see if it
     // matches the one in the database
     $encrypted_pass = md5(md5($Password).$user['rand']);

     // Try and get the user using the Username & encrypted pass
     $query = "select UserID, Username from forum_Users where Username='$Username' and Password='$encrypted_pass'";
     $result = mysql_query($query);
     $user = mysql_fetch_array($result);
     $numrows = mysql_num_rows($result);

     // Now encrypt the data to be stored in the session
     $encrypted_id = md5($user['UserID']);
     $encrypted_name = md5($user['Username']);

     // Store the data in the session
     $_SESSION['UserID'] = $UserID;
     $_SESSION['Username'] = $Username;
     $_SESSION['encrypted_id'] = $encrypted_id;
     $_SESSION['encrypted_name'] = $encrypted_name;

    if ($numrows == 1)
    {
        return 'Correct';
    }
    else
    {
        return false;
    }
}

function user_logout()
{
     session_unset ();
     session_destroy ();
}

function is_authed()
{
     // Check if the encrypted Username is the same
     // as the unencrypted one, if it is, it hasn't been changed
     if (isset($_SESSION['Username']) && (md5($_SESSION['Username']) == $_SESSION['encrypted_name']))
     {
          return true;
     }
     else
     {
          return false;
     }
}
can anyone see an error? i can't figure it out
__________________
360 Blog | Join GiffGaff | Twitter
Joe 90 is offline   Reply With Quote
 

Thread Tools
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 On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:31.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.