php header function not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tharindu96
    New Member
    • Jan 2012
    • 16

    php header function not working

    the code below is not working can anyone help me?

    Code:
    									$query2 = "SELECT `username` FROM `users` WHERE `username` = '$new_username'";
    									$query2_run = mysql_query($query2);
    									if(mysql_num_rows($query2_run)==1) {
    										echo 'The username '.$new_username.' already exists.';
    									}else{
    										$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)."')";
    										if ($query2_run = mysql_query($query2)) {
    											header('Location: success.php');
    										}else{
    											echo 'Sorry, we could not register at this time. Please try again later.';
    										}
    									}
  • PsychoCoder
    Recognized Expert Contributor
    • Jul 2010
    • 465

    #2
    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

    Comment

    • tharindu96
      New Member
      • Jan 2012
      • 16

      #3
      After registering a user I want to redirect them to a page but the header function does not work.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        there could be output preventing the header to work. enable error reporting to see if that’s the case.

        Comment

        • tharindu96
          New Member
          • Jan 2012
          • 16

          #5
          found the answer
          i had to put "exit;" after the "header("Locati on: success.php")"

          Comment

          Working...