Current location: Hot Scripts Forums » Programming Languages » PHP » SQL with PHP, problem


SQL with PHP, problem

Reply
  #1 (permalink)  
Old 10-13-06, 04:55 PM
DenKain DenKain is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
SQL with PHP, problem

I am trying to implement a secure login/session for my website following this guid: http://tech.hostforadollar.com/index...k=verart&aid=3

I have to write my own "add a user form" because the author asumes we all know how. Well I have created one that in throry should work but does not work in implementation. I have two parts to my "add a user" form. The first is an HTML page that uses the post method to get my information to a PHP page that inserts the info into the database. When I try this I get an error on the PHP page: Parse error: parse error, unexpected $ in /home/content/s/a/t/user/html/adduseraction.php on line 14

I can't seem to find the unexpected $.

Here is the HTML page:
Code:
<html> 
<head><title>Login</title></head> 
<body> 

<form action="adduseraction.php" method="Post"> 
Email Address:<br /> 
<input type="Text" name="psEmail" /> 
<br /> 
Password:<br /> 
<input type="password" name="psPassword" /> 
<br /> 
<input type="submit" value="Add" /> 

</form> 

</body> 
</html>
Here is the PHP processing page (keep in mind I took out the server address, username and password to show it to you):
Code:
<?PHP
// Check if the information has been filled in 
if($psEmail == '' || $psPassword == '') { 
// No login information 
echo "blank entrys"; 
} else { 
// Authenticate user 
$hDB = mysql_connect('server', 'username', 'password'); 
mysql_select_db('database'); 
// Insert a row of information into the table
mysql_query("INSERT INTO tblUsers 
(iUser, sEmail, sPassword, sGUID, sData) VALUES(Null, '$psEmail', password('$psPassword'), Null, Null) ") 
or die(mysql_error());
?>
I just can't figure out whats wrong.
Reply With Quote
  #2 (permalink)  
Old 10-13-06, 05:08 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
There is no closing "}" to match the "} else {" opening one.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #3 (permalink)  
Old 10-13-06, 05:17 PM
DenKain DenKain is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
...wow...there are some days I feel like an idiot. Anyway that solved that problem but the processing PHP insists that the feilds are blank. Any ideas?
Reply With Quote
  #4 (permalink)  
Old 10-13-06, 05:29 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
If we assume that register_globals are off (which is not a bad assumption as php.net recommends that new code should not be written using them and they will disappear in future versions of PHP), then you need to setup your variables in the processing page like this -
PHP Code:

$psEmail $_POST['psEmail'];

$psPassword $_POST['psPassword']; 
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #5 (permalink)  
Old 10-13-06, 06:01 PM
DenKain DenKain is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you so much for helping me. I have a lot of tweaking to do with this (Logouts, time expiration, security levels, etc) and I have a feeling I may be asking for help again some time.
Reply With Quote
  #6 (permalink)  
Old 10-14-06, 09:51 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Never mind.............
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Split data in php from sql? ( usinf | ) ? NabZ PHP 1 04-03-06 03:51 PM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM
PHP script problem (please help) osmanmumtaz PHP 0 05-24-05 07:29 AM
sql problem da.bass PHP 2 05-24-05 05:00 AM
php variable problem ashishjha54 PHP 7 05-22-05 12:09 PM


All times are GMT -5. The time now is 05:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.