Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Login script woun't work why ??
Old 06-17-2005, 11:31 AM Login script woun't work why ??
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
hello guys my login script woun't login.. Though all the Forms as been Validated with Javascript by the designer.. i'm to use PHP/MySQL to create the backend but my script woun't login don't know keep get.. this error !
Parse error: parse error, unexpected ';' in /home/sibfonl/public_html/login.php on line 14

here is my login script.
PHP Code:
<?php
session_start
();
include (
"dbconn.php");

if(!
$submit){

$username $_POST["username"];
$password $_POST["password"];

$sql mysql_query("SELECT * FROM users WHERE 'username' = 

'
$username' AND 'password' = '$password'") or die(mysql_error());

while(
$row mysql_fetch_array($sql);
header("location: members.php");
} else {
echo 
"Sorry you can't be login either your username or password is 

incorrect
include "
newaccount-2.htm";
exit();
?>
Please can some help me figure that out.
Thanks in Advanced
Thanks in Advance
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
 
Register now for full access!
Old 06-17-2005, 12:43 PM
stoot98's Avatar
Ultra Talker

Posts: 427
Name: Stuart
Location: Glasgow, Scotland
Trades: 0
Your while loop isn't right. You shouldnt have a semi-colon at the end it should have a '{' and then a closing one at the end.

PHP Code:
while($row mysql_fetch_array($sql) {
header("location: members.php"); 

...


Stoot
stoot98 is offline
Reply With Quote
View Public Profile
 
Old 06-17-2005, 04:23 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Also, how are you gonna check to see if they are logged in? Anyone could access the members page from that code, and also, the security for passwords... Is it just the password stored there or is it md5 hashed?
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-18-2005, 07:15 AM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Yeah it's an md5
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 06-18-2005, 07:20 AM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
And the sessions?
PHP Code:
if($submit){

$username $_POST["username"];
$password $_POST["password"];
$pass1 md5($password);
$sql mysql_query("SELECT * FROM users WHERE 'username' =

'
$username' AND 'password' = '$pass1'") or die(mysql_error()); 
Sessions I have done this:
PHP Code:
session_start();
$_SESSION['loggedinuser'] = $username;
setcookie("id""$id"time()+36000); 
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-18-2005, 03:50 PM Still having Problem i'm i dumb or what
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Hello guys, i must thank you all for helping me out.. but i'm still having problem don't know wat is wrong can take a look at this now ?? idon't know wat is wrong

i got this error !
Parse error: parse error, unexpected T_STRING in /home/sibfonl/public_html/login.php on line 3


PHP Code:
<? php

session_start
(); 
$_SESSION['loggedinuser'] = $username
setcookie("id""$id"time()+36000); 

if(
$submit){ 

$username $_POST["username"]; 
$password $_POST["password"]; 
$pass1 md5($password); 
$sql mysql_query("SELECT * FROM users WHERE 'username' = 

'
$username' AND 'password' = '$password'") or die(mysql_error()); 

while(
$row mysql_fetch_array($sql)){ 
header("location: members.php"); 
} else { 
echo 
"Sorry you can't be login either your username or password is 

incorrect 
include "
newaccount-2.htm"; 
exit(); 
?>
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 06-18-2005, 04:14 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
Heres my script:
PHP Code:
<? 
include("functions.php");
db_connect();

$pass $_POST['pass'];
$username $_POST['user'];
$averify $_POST['admin'];
$md5pw md5($pass);

$query="SELECT * FROM users WHERE username='$username' AND md5pw='$md5pw'";
$result=mysql_query($query) or die("Unable to carry out task because ".mysql_error());

$row mysql_fetch_array($result);

$id $row['id'];


if(
mysql_num_rows($result)==0) {
echo (
"The database contains no record of your user or your password is incorrect."); 
} else {


session_start();
$_SESSION['loggedinuser'] = $username;
setcookie("id""$id"time()+36000);

mysql_close();    


?>

<html>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=./?p=">
</html>

<?

echo("Logging you in as: $user");
}
?>
Ths is linked by login.php. login.php has a form linking to that, username and password, once these have been entered check_login checks it and if it is correct it sets a session and if not .. well, it doesnt log you in!
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-20-2005, 06:25 AM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
Trades: 0
Thanks I'm gonna try ur code out... and gv u feed back
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.

Please login or register to view this content. Registration is FREE
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 06-20-2005, 03:44 PM
gavinf's Avatar
Novice Talker

Posts: 11
Location: York, UK
Trades: 0
If your installation of PHP has register_globals turned off (default for php 5 and recommended of other PHP versions) then I doubt you're going to get anything from checking the submit var like this:

PHP Code:
if($submit){ 
do 
this
} else {
do 
this instead

You need to be calling the submit var like this:

PHP Code:
if ( isset($_POST['submit']) ){ 
do 
this
} else {
do 
this instead

Hope that helps some!
__________________

Please login or register to view this content. Registration is FREE

Web Development + E-Commerce
gavinf is offline
Reply With Quote
View Public Profile Visit gavinf's homepage!
 
Reply     « Reply to Login script woun't work why ??
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28385 seconds with 12 queries