PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old February 1st, 2013, 08:05 PM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
forms - PHP registration and login form

PHP Code:
<?php
require('config.php');

if(isset(
$_POST['submit'])){
    
    
//Perform the verification of the nation
    
$email1 $_POST['email1'];
    
$email2 $_POST['email2'];
    
$pass1 $_POST['pass1'];
    
$pass2 $_POST['pass2'];
    
    if(
$email1 == $email2){
        if(
$pass == $pass2){
            
//All good. Carry on.
        
}else{
            echo 
"Sorry, your passwords do not match.<br />";
            exit();
        }
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    {
    
    
    
}else{ 

$form = <<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br> />
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="text" name="pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
<input type="submit" value="Register" name="submit" />
</form>
EOT;

echo 
$form;

}

?>



Somethings wrong and i don't know what it is please help.

I get an error at
Code:
?>
Code:
}else{

Reply With Quote
Old February 2nd, 2013, 04:24 AM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,437 DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Month 3 Days 20 h 56 m 48 sec
Reputation Power: 9
change

Code:
$form = <<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br> />
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="text" name="pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
<input type="submit" value="Register" name="submit" />
</form>
EOT;

echo $form;

to

Code:
<<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br> />
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="text" name="pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
<input type="submit" value="Register" name="submit" />
</form>
EOT;
__________________
When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car.

Reply With Quote
Old February 2nd, 2013, 11:36 AM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
PHP Code:
<?php
require('config.php');

if(isset(
$_POST['submit'])){
    
    
//Perform the verification of the nation
    
$email1 $_POST['email1'];
    
$email2 $_POST['email2'];
    
$pass1 $_POST['pass1'];
    
$pass2 $_POST['pass2'];
    
    if(
$email1 == $email2){
        if(
$pass == $pass2){
            
//All good. Carry on.
        
}else{
            echo 
"Sorry, your passwords do not match.<br />";
            exit();
        }
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    {
    
    
    
}else{ 

<<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br> />
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="text" name="pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
<input type="submit" value="Register" name="submit" />
</form>
EOT;

}

?>


Did i do the right thing?

Reply With Quote
Old February 2nd, 2013, 12:00 PM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,437 DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Month 3 Days 20 h 56 m 48 sec
Reputation Power: 9
looks about right, might want to display a message to the user to confirm that the update was successful

Reply With Quote
Old February 2nd, 2013, 01:22 PM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by DavidMR
looks about right, might want to display a message to the user to confirm that the update was successful


Still giving me the same errors

At }else{ and ?>


To give you some more info when i run the script it says Parse error: syntax error, unexpected T_ELSE in /website/project/register.php on line 25

Reply With Quote
Old February 2nd, 2013, 01:29 PM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,437 DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Month 3 Days 20 h 56 m 48 sec
Reputation Power: 9
Code:
else{
        echo "Sorry your email's do not match<br /><br />";
    { 


your second { should be a }

Reply With Quote
Old February 2nd, 2013, 01:36 PM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by DavidMR
Code:
else{
        echo "Sorry your email's do not match<br /><br />";
    { 


your second { should be a }


PHP Code:
}
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    {
    
    
    
}else{ 


Where at i'm kinda new to php scripting.

Reply With Quote
Old February 2nd, 2013, 01:44 PM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,437 DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Month 3 Days 20 h 56 m 48 sec
Reputation Power: 9
PHP Code:
}
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    {
    
    
    
}else{ 


should be

PHP Code:
}
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    }
    
    
    
}else{ 

Reply With Quote
Old February 2nd, 2013, 01:46 PM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by DavidMR
PHP Code:
}
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    {
    
    
    
}else{ 


should be

PHP Code:
}
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    }
    
    
    
}else{ 



Works thank you

Reply With Quote
Old February 2nd, 2013, 04:07 PM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
PHP Code:
<?php
require('config.php');

if(isset(
$_POST['submit'])){
    
    
//Perform the verification of the nation
    
$email1 $_POST['email1'];
    
$email2 $_POST['email2'];
    
$pass1 $_POST['pass1'];
    
$pass2 $_POST['pass2'];
    
    if(
$email1 == $email2){
        if(
$pass == $pass2){
            
//All good. Carry on.
            
        
$name mysql_escape_string($_POST['name']);
        
$lname mysql_escape_string($_POST['lname']);
        
$uname mysql_escape_string($_POST['uname']);
        
$email1 mysql_escape_string($email1);
        
$email2 mysql_escape_string($email2);
        
$pass1 mysql_escape_string($pass1);
        
$pass2 mysql_escape_string($pass2);
        
        
$pass1 md5($pass1);
        
        
mysql_query("INSERT INTO 'users' ('id', 'name', 'lname', 'uname', 'email', 'pass') VALUES (NULL, '$name', '$lname', '$uname', '$email1', '$pass1')") or die(mysql_error());
        
        
        
        
        
        
        }else{
            echo 
"Sorry, your passwords do not match.<br />";
            exit();
        }
    }else{
        echo 
"Sorry your email's do not match<br /><br />";
    }
}else{ 

<<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br> />
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="text" name="pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
<input type="submit" value="Register" name="submit" />
</form>
EOT;

}

?>



Reply With Quote
Old February 2nd, 2013, 04:16 PM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,437 DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Month 3 Days 20 h 56 m 48 sec
Reputation Power: 9
the code looks ok, try removing "spaces" from before those lines to eliminate dodgy characters messing up your script.

Reply With Quote
Old February 2nd, 2013, 04:33 PM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by DavidMR
the code looks ok, try removing "spaces" from before those lines to eliminate dodgy characters messing up your script.



PHP Code:
<?php
require('config.php');
if(isset(
$_POST['submit'])){
    
//Perform the verification of the nation
    
$email1 $_POST['email1'];
    
$email2 $_POST['email2'];
    
$pass1 $_POST['pass1'];
    
$pass2 $_POST['pass2'];
    if(
$email1 == $email2){
        if(
$pass == $pass2){
            
//All good. Carry on.
        
$name mysql_escape_string($_POST['name']);
        
$lname mysql_escape_string($_POST['lname']);
        
$uname mysql_escape_string($_POST['uname']);
        
$email1 mysql_escape_string($email1);
        
$email2 mysql_escape_string($email2);
        
$pass1 mysql_escape_string($pass1);
        
$pass2 mysql_escape_string($pass2);
        
$pass1 md5($pass1);
        
mysql_query("INSERT INTO 'users' ('id', 'name', 'lname', 'uname', 'email', 'pass') VALUES (NULL, '$name', '$lname', '$uname', '$email1', '$pass1')") or die(mysql_error());
        }else{
            echo 
"Sorry, your passwords do not match.<br />";
            exit();
        }
   }else{
        echo 
"Sorry your email's do not match<br /><br />";
        }
}else{ 
<<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br> />
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="text" name="pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
<input type="submit" value="Register" name="submit" />
</form>
EOT;
}
?>

Reply With Quote
Old February 2nd, 2013, 04:39 PM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,437 DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Month 3 Days 20 h 56 m 48 sec
Reputation Power: 9
echo your query just before you run it? (its horrible coding practice to run a query with mysql_query without a check)

Reply With Quote
Old February 2nd, 2013, 05:02 PM
ZumTaxxx ZumTaxxx is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Location: Denmark
Posts: 13 ZumTaxxx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 45 sec
Reputation Power: 0
Quote:
Originally Posted by DavidMR
echo your query just before you run it? (its horrible coding practice to run a query with mysql_query without a check)


PHP Code:
<?php
require('config.php');
if(isset(
$_POST['submit'])){
    
//Perform the verification of the nation
    
$email1 $_POST['email1'];
    
$email2 $_POST['email2'];
    
$pass1 $_POST['pass1'];
    
$pass2 $_POST['pass2'];
    if(
$email1 == $email2){
        if(
$pass == $pass2){
            
//All good. Carry on.
        
$name mysql_escape_string($_POST['name']);
        
$lname mysql_escape_string($_POST['lname']);
        
$uname mysql_escape_string($_POST['uname']);
        
$email1 mysql_escape_string($email1);
        
$email2 mysql_escape_string($email2);
        
$pass1 mysql_escape_string($pass1);
        
$pass2 mysql_escape_string($pass2);
        
$pass1 md5($pass1);
        echo 
mysql_query("INSERT INTO 'users' ('id', 'name', 'lname', 'uname', 'email', 'pass') VALUES (NULL, '$name', '$lname', '$uname', '$email1', '$pass1')") or die(mysql_error());
        }else{
            echo 
"Sorry, your passwords do not match.<br />";
            exit();
        }
   }else{
        echo 
"Sorry your email's do not match<br /><br />";
        }
}else{ 
<<<EOT
<form action="register.php" method="POST">
First Name: <input type="text" name="name" /><br> />
Last Name: <input type="text" name="lname" /><br />
Username: <input type="text" name="uname" /><br />
Email: <input type="text" name="email1" /><br />
Confirm Email: <input type="text" name="email2" /><br />
Password: <input type="text" name="pass1" /><br />
Confirm Password <input type="password" name="pass2" /><br />
<input type="submit" value="Register" name="submit" />
</form>
EOT;
}
?>


Code:
Like this

Reply With Quote
Old February 3rd, 2013, 06:27 AM
DavidMR's Avatar
DavidMR DavidMR is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Galway
Posts: 1,437 DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level)DavidMR User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Month 3 Days 20 h 56 m 48 sec
Reputation Power: 9
like this? what?

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > forms - PHP registration and login form


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap