Jump to content

[SOLVED] Page will download after I hit submit.


tqla

Recommended Posts

Hi. I have a registration form that works well. It updates my DB and also sends the new member an email. The problem is that when the member fills out the registration form and hits enter the page does it's thing and then tries to download to the desktop. I get a download window alert that asks what I would like to do with "index.php". What can cause this?

Yes. Thanks. The top part is a login that works fine. The bottom part is the reg form. It calls form.inc for the fields. It works fine but for some reason the page tries to download itself to your computer after clicking submit. 

 

The registration form starts after the "break;" tag. (case "new")

 

<?php
                               
  switch (@$_GET['do'])                                   
  {
    case "login":                                         
    
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $_SESSION['PrevUrl'] = $accesscheck;
  session_register('PrevUrl');
}

if (isset($_POST['fusername'])) {
  $loginUsername=$_POST['fusername'];
  $password=$_POST['fpassword'];
  $MM_fldUserAuthorization = "status";
  $MM_redirectLoginSuccess = "memberarea.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_Auth, $Auth);
  	
  $LoginRS__query=sprintf("SELECT loginName, password, status FROM Member WHERE loginName='%s' AND password='%s'",
  get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $Auth) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'status');
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      



    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}

    break;                                                

    case "new":                                           
      foreach($_POST as $field => $value)                 
      {
        if ($field != "fax")                              
        {
          if ($value == "")                               
          {
            unset($_GET['do']);
            $message_new = "<p><font color=#ff0000>Required information is missing. Please try again.</font></p>";
            include("form.inc");
            exit();
          }
        }
        if (ereg("(Name)",$field))                        
        {
         /*if (!ereg("^[A-Za-z' -]{1,50}$",$value)) 
         {
           unset($_GET['do']);
           $message_new = "$field is not a valid name. 
                            Please try again.";
           include("form.inc");
           exit();
         }*/
        }
        $$field = strip_tags(trim($value));               
      } // end foreach
      if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip))      
      {
        unset($_GET['do']);
        $message_new = "<p><font color=#ff0000>$zip is not a valid zip code. 
                        Please try again.</font></p>";
        include("form.inc");
        exit();
      }
      if (!ereg("^[0-9)(xX -]{7,20}$",$phone))            
      {
        unset($_GET['do']);
        $message_new = "<p><font color=#ff0000>$phone is not a valid phone number. 
                        Please try again.</font></p>";
        include("form.inc");
        exit();
      }
      if ($fax != "")                                    
      {
        if (!ereg("^[0-9)(xX -]{7,20}$",$fax)) 
        {
          unset($_GET['do']);
          $message_new = "<p><font color=#ff0000>$fax is not a valid phone number. 
                           Please try again.</font></p>";
          include("form.inc");
          exit();
        }
      }
      if (!ereg("^.+@.+\\..+$",$email))                  
      {
        unset($_GET['do']);
        $message_new = "<p><font color=#ff0000>$email is not a valid email address. 
                         Please try again.</font></p>";
        include("form.inc");
        exit();
      }                                                  
      /* check to see if login name already exists */

$connection = mysql_connect($hostname_Auth, $username_Auth, $password_Auth) 
or die ("Couldn't connect to server.");
$db = mysql_select_db($database_Auth, $connection)
or die ("Couldn't select database."); 

      $sql = "SELECT loginName FROM Member 
                WHERE loginName='$newname'";
      $result = mysql_query($sql)
                or die(mysql_error());
      $num = mysql_numrows($result);
      if ($num > 0)                                      
      {
        unset($_GET['do']);
        $message_new = "<p><font color=#ff0000>$newname already used. Select another
                         Member ID.</font></p>";
        include("form.inc");
        exit();
      }
      else                                               
      {   
        $today = date("Y-m-d");                          
        $sql = "INSERT INTO Member (loginName,createDate,
                  password,firstName,lastName,street,city,
                  state,zip,phone,fax,email) VALUES
                ('$newname','$today','$newpass',
                 '$firstName', '$lastName','$street','$city',
                 '$state','$zip','$phone','$fax','$email')";
        mysql_query($sql);                                              
        /* send email to new member */                   
        $emess = "A new Member Account has been setup. ";
        $emess.= "Your new username and password are: ";
        $emess.= "\n\n\tUsername: $newname\n\t Password: $newpass\n\n";
        $emess.= "If you have any questions or problems,";
        $emess.= " email [email protected]";
        $ehead="From: [email protected]\r\n";     
        $subj = "Your new Member Account";
        $mailsend=mail("$email","$subj","$emess","$ehead","From:$from\r\nReply-To:[email protected]");
        header("Location: newmember.php");              
      }
    break;                                               

    default:                                             
        include("form.inc");
  }

?>


I narrowed it down to this

 

        $mailsend=mail("$email","$subj","$emess","$ehead","From:$from\r\nReply-To:[email protected]");

 

When I remove it it works as expected (of course it doesn't send an email) but the page doesn't try and download itself. Any iderrrzz?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.