...

View Full Version : What's wrong with this??



Renroc
02-08-2006, 07:08 AM
Could someone please tell me what is wrong with this code?? I new to PHP so please be gentle...
Renroc

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','firstname');
pt_register('POST','lastname');
pt_register('POST','emailaddress');
if($firstname=="" || $lastname=="" || $emailaddress=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$emailaddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="firstname: ".$firstname."
lastname: ".$lastname."
emailaddress: ".$emailaddress."
";
$message = stripslashes($message);
mail("me@somewhere.com","Form Submitted at Some Web Page website",$message,"From: Us");
$make=fopen("admin/data.dat","a");
$to_put="";
$to_put .= $firstname."|".$lastname."|".$emailaddress."
";
fwrite($make,$to_put);

header("Refresh: 0;url=http://some url/page.htm");
?><?php
}
?>

thesavior
02-08-2006, 07:18 AM
Try this:


<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','firstname');
pt_register('POST','lastname');
pt_register('POST','emailaddress');
if($firstname=="" || $lastname=="" || $emailaddress=="" )
{
$errors=1;
$error.="<li>
You did not enter one or more of the required fields. Please go back and try again.
</li>";
}
elseif(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$emailaddress))
{
$error.="<li>
Invalid email address entered
</li>";
$errors=1;
}
elseif($errors==1)
{
echo $error;
}
else
{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="firstname: ".$firstname."
lastname: ".$lastname."
emailaddress: ".$emailaddress."
";
$message = stripslashes($message);
mail("me@somewhere.com","Form Submitted at Some Web Page website",$message,"From: Us");
$make=fopen("admin/data.dat","a");
$to_put = $firstname."|".$lastname."|".$emailaddress;
fwrite($make,$to_put);
header("Location: http://www.example.com/");
}
?>

If that doesn't work, what errors are you getting, and on what line?

Renroc
02-08-2006, 07:32 AM
Thanks for your help, I found the mistake... If I have any more problems I'll post again.
Thanks again
Renroc



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum