PDA

View Full Version : Problems with php script



José
03-29-2006, 10:15 PM
Hello!
Where can I find a solution or information about this "permanent" message:
"Warning: Cannot modify header information - headers already sent by (output started at /home/hlrelps/public_html/upload.php:10) in /home/hlrelps/public_html/upload.php on line 17", using my form???
The "problem starts when I start introducing a validation field in my script. I think that something is wrong with the comand:
header("Location: upload.html") ;

Thank you!

navaldesign
03-30-2006, 04:29 AM
Hello!
Where can I find a solution or information about this "permanent" message:
"Warning: Cannot modify header information - headers already sent by (output started at /home/hlrelps/public_html/upload.php:10) in /home/hlrelps/public_html/upload.php on line 17", using my form???
The "problem starts when I start introducing a validation field in my script. I think that something is wrong with the comand:
header("Location: upload.html") ;

Thank you!

Your problem is in line 10 not 17. You usually get such kind of errors when you mix html and php. If you have used a validation script from the ones presented on this forum, and on the other hand you combined it with some html for the thankyou message, it is quite possible that you will get some errors. If you wish, upload here your script so we can have a look.

José
03-30-2006, 07:31 AM
<?PHP
@$Email = addslashes($_POST['Email']);
if (strlen($Email) == 0 )
{
header("Location: error.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
header("Location: error.html");
exit;
}
$email = $HTTP_POST_VARS[email];
$mailto = "$Email,webmaster@vaccontrol.com";
$mailsubj = "Contacto efectuado em VacControl";
$mailhead = "From: webmaster@vaccontrol.com";
reset ($HTTP_POST_VARS);
$mailbody = "Os seguintes campos foram preenchidos:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>>

This is the script that I'm working, I need 1 "Thankyou page" and 2 errors pages: one for e-mail validation and another for name validation. That's all.
Thank you for help

navaldesign
03-31-2006, 08:48 PM
<?PHP
@$Email = addslashes($_POST['Email']);
if (strlen($Email) == 0 )
{
header("Location: error1.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
header("Location: error2.html");
exit;
}
$Email = $HTTP_POST_VARS[Email]; DELETE THIS LINE
$mailto = "webmaster@vaccontrol.com"; CORRECT THIS LINE
$mailsubj = "Contacto efectuado em VacControl";
$mailhead = "From: $Email\n"; INSERT THIS LINE
$mailhead = "From: webmaster@vaccontrol.com (webmaster@vaccontrol.com)"; DELETE THIS LINE
reset ($HTTP_POST_VARS);
$mailbody = "Os seguintes campos foram preenchidos:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("Location: thankyou_page.html"); INSERT THIS LINE FOR YOUR THANKYOU PAGE
?>> DELETE THE SECOND ">"



Create and publish your two error pages "error1" and "error2" and the "thankyou_page"

José
03-31-2006, 09:52 PM
Thank you. I report to you as soon as possible.

navaldesign
04-01-2006, 05:04 AM
You can use this script:

<?php
// Receiving variables
@$Nome = addslashes($_POST['Nome']);
@$Apelido = addslashes($_POST['Apelido']);
@$Organismo = addslashes($_POST['Organismo']);
@$Comentários = addslashes($_POST['Comentários']);
@$Email = addslashes($_POST['Email']);
// Validation
if (strlen($Email) == 0 )
{
header("Location: error1.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $Email))
{
header("Location: error2.html");
exit;
}
//Sending Email to form owner
$pfw_header = "From: $Email\n"
. "Reply-To: $Email\n";
$pfw_subject = "Os seguintes campos foram preenchidos";
$pfw_email_to = "webmaster@vaccontrol.com";
$pfw_message = "Os seguintes campos foram preenchidos\n"
. "--------------------------------------------------\n"
. "Nome: $Nome\n"
. "Apelido: $Apelido\n"
. "Organismo: $Organismo\n"
. "Comentários: $Comentários\n"
. "Email: $Email\n";
*****($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;
header("Location: thankyou_page.html");
?>

Create the "error1", about empty email field, "error2" for non truelike email, , and "thankyou_page" and publish them. Copy this code and paste it in notepad. Go to "Save as", choose File type "All Files", and save it as "contact.php". Upload it on your server.

Set your form encoding type in "multipart / form data" .

You're done!

José
04-01-2006, 12:51 PM
Thank you again!!!
It's working...Ok!
I think that I have used this script, but the "publishing methode" was incorrect. A this time, I use the BV FTP tool. Usualy I try "publish" with the "BV web builder" and i received an error msg when testing whit IE browser.
Thank you!