tqla Posted June 5, 2007 Share Posted June 5, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/54330-solved-page-will-download-after-i-hit-submit/ Share on other sites More sharing options...
conker87 Posted June 5, 2007 Share Posted June 5, 2007 Can we have the code you're using? Quote Link to comment https://forums.phpfreaks.com/topic/54330-solved-page-will-download-after-i-hit-submit/#findComment-268682 Share on other sites More sharing options...
tqla Posted June 5, 2007 Author Share Posted June 5, 2007 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 info@xxx.com"; $ehead="From: info@xxx.com\r\n"; $subj = "Your new Member Account"; $mailsend=mail("$email","$subj","$emess","$ehead","From:$from\r\nReply-To:info@xxx.com"); header("Location: newmember.php"); } break; default: include("form.inc"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/54330-solved-page-will-download-after-i-hit-submit/#findComment-268690 Share on other sites More sharing options...
tqla Posted June 5, 2007 Author Share Posted June 5, 2007 I narrowed it down to this $mailsend=mail("$email","$subj","$emess","$ehead","From:$from\r\nReply-To:info@xxx.com"); 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? Quote Link to comment https://forums.phpfreaks.com/topic/54330-solved-page-will-download-after-i-hit-submit/#findComment-268725 Share on other sites More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 $mailsend=mail("$email","$subj","$emess","From:$from\r\nReply-To:info@xxx.com", "-f$from"); You were adding the headers twice, dunno why, but try the above replacement see if it works or not. Quote Link to comment https://forums.phpfreaks.com/topic/54330-solved-page-will-download-after-i-hit-submit/#findComment-268733 Share on other sites More sharing options...
tqla Posted June 5, 2007 Author Share Posted June 5, 2007 Thank you frost110! You fixed it! For some reason though the server didn't like the -f$from so I ended up using: $mailsend=mail("$email","$subj","$emess","From:$from\r\nReply-To:info@xxx.com"); Quote Link to comment https://forums.phpfreaks.com/topic/54330-solved-page-will-download-after-i-hit-submit/#findComment-268739 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.