Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2007, 06:06 PM
Authorized User
 
Join Date: Sep 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login

I can't find whats wrong in the code below, yet the browser keeps displaying:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/michael/upload/register.php on line 13

Can anyone correct my error?



<?php

include_once('config.php');

$login_query = "select id, username, password, info from user_login where username='".$_POST['username']."'";
if($result = mysql_query($login_query)){
        if($row = mysql_fetch_array($result)){
                $_SESSION['error'] = "Username already taken.";
        } else {
                if($_POST['password'] === $_POST['password2']){
                        mysql_query("insert into user_login (username, password) values ('".$_POST['username'].")', ('".md5($_POST['password'].")');
                        if($result = mysql_query($login_query)){
                                $_SESSION['swf_user'] = mysql_fetch_array($result);
                        }
                } else {
                        $_SESSION['error'] = "Passwords did not match.";
                }
        }
}

header("Location: main.php");
?>
__________________
Visit my website at GladiatorStudios.com!
 
Old September 12th, 2007, 12:17 AM
Registered User
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi TheSchwa

In your code
there is a syntax error in mysql query

try to use the following query

mysql_query("insert into user_login (username, password) values ('".$_POST['username'].")', ('".md5($_POST['password'])."')");


:)

 
Old September 12th, 2007, 03:09 PM
Authorized User
 
Join Date: Sep 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now the error isn't displayed, but the login doesn't work.

http://www.gladiatorstudios.com/upload.html
 
Old September 13th, 2007, 12:44 AM
Registered User
 
Join Date: Sep 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi

i think you registration process working well;
you have to write the login query and registration query separately;

Login query;
<?php

$login_query = "select id, username, password, info from user_login where username='".$_POST['username']."' and password='".$_POST['password']."'";

$result=mysql_fetch_array($login_query);
if(mysql_num_rows($result)==1){
header("Location: main.php");
}else{
echo "wrong username or password";
}
?>









Similar Threads
Thread Thread Starter Forum Replies Last Post
login script: user can't hit "return" for login dmerrill Java Basics 13 July 14th, 2006 07:25 PM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM
login failed for user nt authority\anonymous login rj1406 Classic ASP Databases 1 October 24th, 2004 09:15 AM





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