/////////////////////////////////Begin Registration///////////////////////////
// Validate users input
if(!empty($_POST))
{
// Check email is a valid email address
if(isset($_POST['email'])) if(!ereg("^([a-zA-Z0-9_\.\-]+)@((\[[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,}|[0-9]{1,})(\]?)$", $_POST['email'])) $eg_error['email'] = "Invalid email";
// Check email has a value
if(empty($_POST['email'])) $eg_error['email'] = "Enter email";
// Check nickname has a value
if(empty($_POST['nickname'])) $eg_error['nickname'] = "Enter nickname";
// Check fname has a value
if(empty($_POST['fname'])) $eg_error['fname'] = "Enter first";
// Check lname has a value
if(empty($_POST['lname'])) $eg_error['lname'] = "Enter last name";
// Check confirm_email has a value
if(empty($_POST['confirm_email'])) $eg_error['confirm_email'] = "confirm email";
// Check project_name has a value
if(empty($_POST['project_name'])) $eg_error['project_name'] = "Enter project name";
// Check confirm_email is a valid email address
if(isset($_POST['confirm_email'])) if(!ereg("^([a-zA-Z0-9_\.\-]+)@((\[[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,}|[0-9]{1,})(\]?)$", $_POST['confirm_email'])) $eg_error['confirm_email'] = "Invalid email";
// Check if any errors were returned and run relevant code
if(empty($eg_error))
{
// Conditional statement
if(@$_POST['email'] != @$_POST['confirm_email'])
{
$ecom = "entered email addresses did not match";
}
else
{
$eg_text_2 = "[f] [l]";
$eg_text_2 = str_replace("[f]", @$_POST['fname'], $eg_text_2);
$eg_text_2 = str_replace("[l]", @$_POST['lname'], $eg_text_2);
$eg_text_1 = "<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n<title></title>\n</head>\n<body>\n<p align=\"center\"><b><font size=\"5\" color=\"#000080\">New Registration Request</font></b></p>\n<hr size=\"1\">\n<table border=\"0\" width=\"100%\" id=\"table1\">\n <tr>\n <td width=\"25%\" align=\"right\"><font color=\"#800000\"><b>Nickname :</b></font></td>\n <td>{nick_name}</td>\n </tr>\n <tr>\n <td width=\"25%\" align=\"right\"><font color=\"#800000\"><b>Full Name :</b></font></td>\n <td>{full_name}</td>\n </tr>\n <tr>\n <td width=\"25%\" align=\"right\"><font color=\"#800000\"><b>Email :</b></font></td>\n <td>{email}</td>\n </tr>\n <tr>\n <td width=\"25%\" align=\"right\"><font color=\"#800000\"><b>Project Name :</b></font></td>\n <td>{project_name}</td>\n </tr>\n <tr>\n <td width=\"25%\" align=\"right\"><font color=\"#800000\"><b>IP Address :</b></font></td>\n <td><?=$_SERVER[REMOTE_ADDR]?></td>\n </tr>\n</table>\n</body>\n</html>";
$eg_text_1 = str_replace("{nick_name}", @$_POST['nickname'], $eg_text_1);
$eg_text_1 = str_replace("{full_name}", $eg_text_2, $eg_text_1);
$eg_text_1 = str_replace("{email}", @$_POST['email'], $eg_text_1);
$eg_text_1 = str_replace("{project_name}", @$_POST['project_name'], $eg_text_1);
// Check required values have been passed to email
if(!empty($_POST['email']))
{
// Send email
mail("mail@site.com", "New Registration Request", $eg_text_1, "From: ".@$_POST['email']."\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=utf-8\r\n");
}
$eg_text_3 = "Dear {nam}\n\nThank you for your registration. We will response as soon as possible.\nif you have comment or question, you can send it from here:\n\nhttp://www.site.com/contest/contactus.php\n\nRegards\n--------------------------------\nMMB Contest 2006 Team";
$eg_text_3 = str_replace("{nam}", $eg_text_2, $eg_text_3);
// Check required values have been passed to email
if(!empty($_POST['email']))
{
// Send email
mail(@$_POST['email'], "Thank you for your MMB contest registration", $eg_text_3, "From: mail@site.com\r\n");
}
// Go to page
header("Location: registration_success.php");
exit;
}
}
}
/////////////////////////////////End Registration///////////////////////////
It works ok until it wants to redirect user to registration success page. instead of showing that page i get blank page!
what is wrong with header() function?
Thanks in advance.
Last edited by nico_swd; 10-05-06 at 06:48 AM.
Reason: Please use [php] wrappers when posting PHP code.
It is highly likely that your code is outputting something to the browser prior to the header(...) statement which will prevent the header from being sent to the browser. Add the following line of code after your opening <?php tag and see if there are any errors reported -
PHP Code:
error_reporting(E_ALL);
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Thanks mab for your reply. I did as you said and got this info:
Warning: Cannot modify header information - headers already sent by (output started at /home/parsianp/public_html/contest_2006/index.php:1) in /home/parsianp/public_html/contest_2006/index.php on line 58
I suspect that there is a newline or a space before the opening <. Check to make sure that it is the first thing in the file.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???