alvin567 Posted July 19, 2012 Share Posted July 19, 2012 <?php //javascript-coder.com if(!empty($_REQUEST['adduser'])){ if($_POST["email"] && $_POST["password"] && $_POST["cpassword"]){ if($_POST["password"] == $_POST["cpassword"]){ $email = $_POST['email']; $password = $_POST['password']; if(validate_user($email,$password) == 1){ echo 'User Already Exist in the system'; }else{ add_user($email,$password); echo 'User successfully added into the system'; } }else{ echo 'Password doesn\'t match try again'; } } else{ echo 'Please ensure all values are filled up'; } } //w3schools,refer //airline system from netbeans //betterphp help function validate_user($email,$password){ //if the password is correct the move on todo others $result = mysql_query("Select * FROM user WHERE email = '$email'");//learn from betterphp $row = mysql_fetch_array($result); if ($row['email'] <> "") {//check if email already existed in the database return true;//email exist in the database }else{ return false;//email doesn't exist in the database } } function add_user($email,$password){ //password to be hashed in the database because the database it, $sql = "Insert into user ('email','password') VALUES ('aaaa', 'aaaa')"; mysql_query($sql); $user_id = mysql_insert_id();//return the user id by the previously generated columns return $user_id; } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted July 19, 2012 Share Posted July 19, 2012 Identifiers are not strings, they should not be within quotes. Quote Link to comment Share on other sites More sharing options...
alvin567 Posted July 19, 2012 Author Share Posted July 19, 2012 can you explain better? Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted July 19, 2012 Share Posted July 19, 2012 With 130+ posts, you should really know by now to do the following things: 1) Wrap your code in [ php ] and [/ php ] tags so it is properly displayed. We even have a button for it now. Highlight your code and click the "PHP" button in the toolbar. 2) Use error reporting and error handling, as well as the mysql_error() function to figure out errors on your own. Experts like thorpe don't just stare at non-functional code hoping they notice the error. The fact that thorpe was able to do so in this case doesn't mean that's how we normally debug something. Echo your own error, figure out what it means. 3) Form better questions. Or, in the case of this thread, form a sentence. You did nothing but paste a large block of unformatted code to a group of strangers. 4) Google the answers you receive. Thorpe's answer was perfect. If you don't know what a mysql identifier is, find out. If you had written a question, perhaps the answer you received would have been more complete. Quote Link to comment Share on other sites More sharing options...
alvin567 Posted July 19, 2012 Author Share Posted July 19, 2012 Ok,apologies,the identifier even though I removed the quotes it is still not working. I will try out the mysql_error() and php_error reporting features by myself. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.