This is a discussion on "Registration script" within the PHP Forum section. This forum, and the thread "Registration script are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Registration script
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Registration script
I have the following code that I think should work, the process is SET VARIABLES -> CHECK FOR PASSWORD MATCH -> CHECK USERNAME EXISTANCE -> INSERT INTO DATABASE. Can somebody please look over my code and point me in the right direction. Ta
|
|
|
|
|||
|
Re: Registration script
Thanks for spotting the uname error, but that wouldnt have stopped the record inserting into the database, which is the problem i am having, didnt really explain properly before.
I cant get the INSERT to actually do the insert job. I think I have the correct syntax but it just wont insert. |
|
||||
|
Re: Registration script
Quote:
The problem here is that the code does not have a sufficient framework to correct something -- there are too many fundamental errors. You really need to get a book and do a little more basic study in php/mysql, especially in the area of using php to extract information from a database and putting together a functional module. I'll try to do a basic rewrite for a few lines off the top of my head for you, hopefully that will help you: $query ="SELECT users_uname, password FROM newusers WHERE users_uname='$user'"; $check = mysql_query($query); $num = mysql_num_rows($check); if ($num == 0) { echo 'We\'re sorry, but that name is not in our system. Please check your spelling and try again, or if you have not registered, go to our <a href="./register.php">Registration Page</a>.'; exit(); } elseif ($num > 1) { echo 'Somehow, that user name has gotten into our system more than once. We apologize for the error, but unfortunately, you will have to register again under a different user name. Please go to <a href="./register.php">Registration Page</a>.'; exit(); } else { $row = mysql_fetch_row($check); if $row[1] (!==$pass) { $echo 'The password you entered does not match the password in our system. Police have been called, please put down your weapon and lie face down on the floor. yada yada yada'; exit(); } else { echo "Welcome back, $user." [[test and insert info....]] } } I'm sure there's a glitch or two in that, but it's at least in a basic functional format for comparing a post against a SQL return. There are several other different ways to accomplish the same thing -- the "or die" method, using && and || to set different variables in the context of "if" clauses, would be two I have seen -- and then writing all the text, etc. . The point is, you have to treat the SQL return correctly to extract the information you want, and then write the PHP to treat all the various cases to completion. Hope this helps. |
|
|||
|
Re: Registration script
I totally understand the logic of what you have written. however...this is for the registration page. the user puts all the details in, username pass address etc, it then checks to make sure the username DOESNT exist already that the passwords match. These two areas work and are not the problem. The insert function is the only one that doesnt work. I will refer to my PHP book and let you know if i sort it out. Thanks for your help so far.
Dan |
|
|||
|
Re: Registration script
I now have it working. see below for code. The main error was I was calling the wrong database DOH! but tidied up the code a little.
|
|
|||
|
Re: Registration script
doh, just looked code i put in its wrong see below:
|
![]() |
| Tags |
| login, php, problem, register |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Registration form | deepujbhat | Other Programming Languages | 4 | Aug 2nd, 2007 12:57 |
| Cheap domain registration | LorEye | Hosting & Domains | 18 | Apr 2nd, 2007 15:12 |
| registration form in php | ksuguy24 | Flash & Multimedia Forum | 5 | Jul 11th, 2006 21:17 |
| Login / Registration help | Noobie | PHP Forum | 1 | Apr 14th, 2006 14:01 |