By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

php header function not working

P: 16
the code below is not working can anyone help me?

Expand|Select|Wrap|Line Numbers
  1.                                     $query2 = "SELECT `username` FROM `users` WHERE `username` = '$new_username'";
  2.                                     $query2_run = mysql_query($query2);
  3.                                     if(mysql_num_rows($query2_run)==1) {
  4.                                         echo 'The username '.$new_username.' already exists.';
  5.                                     }else{
  6.                                         $query2 = "INSERT INTO `users` VALUES ('".mysql_real_escape_string($new_email)."','".mysql_real_escape_string($new_username)."','".mysql_real_escape_string($new_passhash)."','".mysql_real_escape_string($new_firstname)."','".mysql_real_escape_string($new_lastname)."')";
  7.                                         if ($query2_run = mysql_query($query2)) {
  8.                                             header('Location: success.php');
  9.                                         }else{
  10.                                             echo 'Sorry, we could not register at this time. Please try again later.';
  11.                                         }
  12.                                     }
  13.  
Feb 1 '12 #1
Share this Question
Share on Google+
4 Replies


PsychoCoder
Expert Mod 100+
P: 465
It sure would be nice if you provided something other than "It doesnt work". What is it doing versus what you need it to do? Are you getting any errors, if so what are they? These are very helpful pieces of information
Feb 1 '12 #2

P: 16
After registering a user I want to redirect them to a page but the header function does not work.
Feb 1 '12 #3

Dormilich
Expert Mod 5K+
P: 8,639
there could be output preventing the header to work. enable error reporting to see if thatís the case.
Feb 1 '12 #4

P: 16
found the answer
i had to put "exit;" after the "header("Location: success.php")"
Feb 1 '12 #5

Post your reply

Sign in to post your reply or Sign up for a free account.