StephenM
Members-
Posts
59 -
Joined
-
Last visited
StephenM's Achievements
Newbie (1/14)
7
Reputation
-
I am not sure what is wrong either but here are some suggestions of things to have a second look at: See at the end of your code, an extra bracket looks out of place and I wonder is it messing things up? exit(); }else{//IF THE EMAIL ADDRESS IS ALREADY REGISTERED echo '<p class="error">The email address is not acceptable because it is already registered</p>'; } } Another security issue consider is lack of filtering of the email variable although I don't think this is your current problem (you didn't use real escape string function here) // Check for an email address: if (empty($_POST['email'])) { $errors[] = 'You forgot to enter your email address.'; } else { $e = trim($_POST['email']); } And finally, it could really help to follow Larry's advice and see what the query is. To help that, you could temporarily remove the header and exit functions yourself so the data is echoed to the page and you can see it without the page moving off somewhere else. Perhaps something along these lines: if (empty($errors)) { // If everything is OK //DETERMINE WHETHER THE EMAIL ADDRESS HAS ALREADY BEEN REGISTERED $q = "SELECT user_id FROM users WHERE email = '$e'"; $result = mysqli_query ($dbcon, $q); echo '<h1>'; // TEMPORARY TO SEE QUERY - remove this line later echo $q; // TEMPORARY TO SEE QUERY - run this query in phpmyadmin and remove this line later echo '</h1>'; // TEMPORARY TO SEE QUERY - remove this line later if (mysqli_num_rows($result) == 0){//The mail address has not been registered already therefore... // Register the user in the users table $q = "INSERT INTO users (user_id, title, fname, lname, email, psword, registration_date, uname, class, addr1, addr2, city, county, pcode, phone, paid) VALUES (' ', '$title', '$fn', '$ln', '$e', SHA1('$p'), NOW(), '$uname', '$class', '$ad1', '$ad2', '$cty', '$cnty', '$pcode', '$ph', '$pd' )"; $result = @mysqli_query ($dbcon, $q); // Run the query. if ($result) { // If it ran OK. header ("location: register-thanks.php"); exit(); } else { // If it did not run OK // Error message: echo '<h2>System Error</h2> <p class="error">Registration failed because of a system error. We apologize for the inconvenience.</p>'; // Debugging message: echo '<p>' . mysqli_error($dbcon) . '<br><br>Query: ' . $q . '</p>'; } // End of if ($result) mysqli_close($dbcon); // Close the database connection // Include the footer and stop the script include ('footer.php'); exit(); } else { //IF THE EMAIL ADDRESS IS ALREADY REGISTERED echo '<p class="error">The email address is not acceptable because it is already registered</p>'; echo '<h2>Error!</h2> <p class="error">The following error(s) occurred:<br>'; foreach ($errors as $msg) { // Print each error. echo " - $msg<br>\n"; } echo '</p><h3>Please try again.</h3><p><br></p>'; }// End of if (empty($errors)) }
-
I can't find anything obvious wrong. In your login.php, what argument is inside the redirect_user() function. At the moment, you are being redirected to index.php. This is the default setting for the redirect_user() function. What you need to have is redirect_user('loggedin.php') Can you confirm what code you have running on the server for redirect_user()?
- 12 replies
-
- ch.12
- script 12.9
-
(and 2 more)
Tagged with: