| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Thu Jul 10, 2008 11:47 pm Post subject: [PHP]registering a user |
|
|
I'm trying to make php code to register a user and I think I have an error at one specific part of code.
| Code: |
<?php
$username = $_POST[username];
$password = $_POST[password];
$vpasswrods = $_POST[vpassword];
include('connect.php');
$usercheck = "SELECT * FROM accounts WHERE username = ".$username; //error here?
if(mysql_num_rows(mysql_query($usercheck, $con) = 1) {
echo "Username already exists!";
exit();
}
elseif(username = "") {
echo "Username is not filled in!";
exit();
}
elseif(password = "") {
echo "Password is not filled in!";
exit();
}
elseif(vpassword != password) {
echo "Verification password is not correct!";
exit();
}
mysql_close($con);
?>
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
thephoneguy Grandmaster Cheater
Reputation: 1
Joined: 17 Mar 2007 Posts: 873
|
Posted: Fri Jul 11, 2008 3:05 am Post subject: |
|
|
there is alot wrong with this for one you forgot to define the variables throughout with $ there are several parse errors ill work on it now and see if i can get it working for ya.
_________________
If you see me posting referring to an earlier conversation 9/10 times it was in the chatbox at baby .
 |
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Fri Jul 11, 2008 4:16 am Post subject: |
|
|
| Yeah ^, all the variables need $ before them whenever they are used.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Jul 11, 2008 8:20 am Post subject: |
|
|
| Code: |
<?php
$username = $_POST[username];
$password = $_POST[password];
$vpasswrods = $_POST[vpassword];
include('connect.php');
$usercheck = "SELECT * FROM accounts WHERE username = ".$username; //error here?
if(mysql_num_rows(mysql_query($usercheck, $con) = 1) {
echo "Username already exists!";
exit();
}
elseif($username = "") {
echo "Username is not filled in!";
exit();
}
elseif($password = "") {
echo "Password is not filled in!";
exit();
}
elseif($vpassword != $password) {
echo "Verification password is not correct!";
exit();
}
mysql_close($con);
?>
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri Jul 11, 2008 8:41 am Post subject: |
|
|
| I don't know PHP, but don't you need to use 2 equal signs? (==)
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Jul 11, 2008 8:43 am Post subject: |
|
|
Yea figured that out. Lol, during my tutorial I was tired so I only saw one equal sign during conditional statements, but when I look back at it it had two
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Fri Jul 11, 2008 8:45 am Post subject: |
|
|
You also declared "vpasswrods" and used it as "vpassword"
Edit: And why are you using if else? use if's only, wouldn't it be simpler to tell all the errors at once?
Last edited by Symbol on Fri Jul 11, 2008 8:47 am; edited 1 time in total |
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Jul 11, 2008 8:46 am Post subject: |
|
|
lol thx for pointing out my typo
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Fri Jul 11, 2008 9:01 am Post subject: |
|
|
$usercheck = "SELECT * FROM accounts WHERE username = $username";
^^ Wont that work?? or...
$usercheck = "SELECT * FROM accounts WHERE username=$username";
amrite?
_________________
|
|
| Back to top |
|
 |
Mussy69 Grandmaster Cheater
Reputation: 0
Joined: 09 Mar 2007 Posts: 842 Location: Sydney
|
Posted: Fri Jul 11, 2008 9:06 am Post subject: |
|
|
If your still having problems you can ask for help on MSN ( you have me ) because i think i might know th eproblems
_________________
|
|
| Back to top |
|
 |
|