PDA

View Full Version : UserSystem Problem



Rockstar
03-11-2007, 09:34 PM
Ok on the login im getting this link:
http://habbishfm.com/user/User/login.php


Parse error: syntax error, unexpected ':' in /home/habbish/public_html/user/User/login.php on line 8
and my DB Config

<?php
mysql_connect("localhost", "habbish_user", "*****") or die(mysql_error()); // connects to the mysql db or outputs an error
mysql_select_db("habbish_user") or die(mysql_error()); // selects the database from the choosen serve or outputs an error
?>
Apparently andy says its your cpanel pass for the habbish_user part but it isisn't right and why am I getting that error


ALSO here is the login.php


<?php
require_once "dbconfig.php"; // include the database information
$sql = mysql_query("SELECT * FROM users WHERE username='".addslashes($_POST['username'])."'") or die("username was in correct. MySQL said".mysql_error()); // this checks to see if the username exists
$result = mysql_fetch_array($sql); // puts the database information into an array

if($result[’password’] == sha1($_POST[’password’])) { // if the passwords match
session_start(); // start the session
header(”Cache-control: private”);
$_SESSION[”sessioname”] = $_POST[’username’];
header(”location: protected.php”);
}else{
echo “Incorrect login details please try again.”;
}

?>

Andys
03-11-2007, 09:39 PM
I've told you, the error has nothing to do with the databse. It's a simple error in the login.php file.

Rockstar
03-11-2007, 09:41 PM
I've told you, the error has nothing to do with the databse. It's a simple error in the login.php file.

Yeh , your probelly right but Im waiting to see if anyone says anything.

[Oli]
03-11-2007, 09:53 PM
If I only look at the error, the problem is in this line:


header("Cache-control: private");

so the ":" is a problem...

try:


header('Cache-control: private');

and if that doesn't work try:


@header("Cache-control: private");

otherwise, have a look here:
http://be.php.net/header

Rockstar
03-11-2007, 09:56 PM
;4084663']If I only look at the error, the problem is in this line:


header(”Cache-control: private”);so the ":" is a problem...

try:


header('Cache-control: private');and if that doesn't work try:


@header(”Cache-control: private”);otherwise, have a look here:
http://be.php.net/header

Nop none of them work

[Oli]
03-11-2007, 09:58 PM
Nop none of them work


I'm also a newbie in this but is there a difference between these two ?:

” & "

they display different in color things when you put under php tags

Rockstar
03-11-2007, 10:00 PM
;4084690']I'm also a newbie in this but is there a difference between these two ?:

” & "

they display different in color things when you put under php tags

Mm got it working


<?
require_once "dbconfig.php";
$sql = mysql_query("SELECT * FROM users WHERE username='".addslashes($_POST['username'])."'") or die("Username not found! MySQL said".mysql_error());
$result = mysql_fetch_array($sql);

if($result[’password’] == sha1($_POST[’password’])) {
session_start();
header('Cache-control: private');
$_SESSION[”sessioname”] = $_POST[’username’];
header('location: protected.php');
}else{
echo 'Incorrect login details, please try again.';
}

?>

But when I create a account it says created now login I log in and It says wrong user :'(
http://habbishfm.com/user/User/register.php

[Oli]
03-11-2007, 10:02 PM
Mm got it working


<?
require_once "dbconfig.php";
$sql = mysql_query("SELECT * FROM users WHERE username='".addslashes($_POST['username'])."'") or die("Username not found! MySQL said".mysql_error());
$result = mysql_fetch_array($sql);

if($result[’password’] == sha1($_POST[’password’])) {
session_start();
header('Cache-control: private');
$_SESSION[”sessioname”] = $_POST[’username’];
header('location: protected.php');
}else{
echo 'Incorrect login details, please try again.';
}

?>

But when I create a account it says created now login I log in and It says wrong user :'(
http://habbishfm.com/user/User/register.php

Yeah so it was with 's instead of ”s.

And about the register, post the code please, i'll look at it

Rockstar
03-11-2007, 10:04 PM
;4084713']Yeah so it was with 's instead of ”s.

And about the register, post the code please, i'll look at it
I had a Look seen nothing.


<form method="post" action="register.php">
<label>Username</label><br/><input name="username"/><br/>
<label>Password</label><br/><input name="password" type="password"/><br/>
<input type="submit" name="join" value="register"/>
</form>

[Oli]
03-11-2007, 10:08 PM
I had a Look seen nothing.


<form method="post" action="register.php">
<label>Username</label><br/><input name="username"/><br/>
<label>Password</label><br/><input name="password" type="password"/><br/>
<input type="submit" name="join" value="register"/>
</form>



wait :S is that the only bit of code inside register.php ?

Wheres the whole php part that sends the username & password into a database.

obviously it would say wrong username/password if the username & password don't get storred...

Rockstar
03-11-2007, 10:09 PM
;4084746']wait :S is that the only bit of code inside register.php ?

Wheres the whole php part that sends the username & password into a database.

obviously it would say wrong username/password if the username & password don't get storred...

Mmm i dunno Lol i just followed this http://forumnerds.com/showthread.php?t=5

[Oli]
03-11-2007, 10:13 PM
Mmm i dunno Lol i just followed this http://forumnerds.com/showthread.php?t=5

This is suppoced to be your register.php :


<?php
require_once "dbconfig.php"; // include the database information
if(!isset($_POST['join'])){
echo "<form method=\"post\" action=\"register.php\">
<label>Username</label><br/><input name=\"username\"/><br/>
<label>Password</label><br/><input name=\"password\" type=\"password\"/><br/>
<input type=\"submit\" name=\"join\" value=\"register\"/>
</form>";
}else{
$pass = sha1($_POST['password']);
$user = mysql_real_escape_string($_POST['username']);
mysql_query("INSERT INTO users (id, username, password) VALUES (NULL, '$user', '$pass')") or die("somthing went wrong during the registration. MySQL said: ".mysql_error());
echo "registration compleate you may now <a href=\"loginform.html\">login</a>.";
}
?>

Rockstar
03-11-2007, 10:16 PM
;4084772']This is suppoced to be your register.php :


<?php
require_once "dbconfig.php"; // include the database information
if(!isset($_POST['join'])){
echo "<form method=\"post\" action=\"register.php\">
<label>Username</label><br/><input name=\"username\"/><br/>
<label>Password</label><br/><input name=\"password\" type=\"password\"/><br/>
<input type=\"submit\" name=\"join\" value=\"register\"/>
</form>";
}else{
$pass = sha1($_POST['password']);
$user = mysql_real_escape_string($_POST['username']);
mysql_query("INSERT INTO users (id, username, password) VALUES (NULL, '$user', '$pass')") or die("somthing went wrong during the registration. MySQL said: ".mysql_error());
echo "registration compleate you may now <a href=\"loginform.html\">login</a>.";
}
?>

That was my register.php
Still makes no diffrence

Beau
03-11-2007, 10:17 PM
Make sure the database is actually receiving the login information (use the form, then check phpMyAdmin to see whether it inserted properly). If it did, that gives you a starting point.

[Oli]
03-11-2007, 10:19 PM
You did set up your dbcongif.php did you ?

Beau
03-11-2007, 10:23 PM
;4084801']You did set up your dbcongif.php did you ?

If the file's included into the script, he'd be getting errors if it was stuffing up (wrong credentials, script not where it should be etc).

Want to hide these adverts? Register an account for free!