PDA

View Full Version : Is this right?


thickandthin
04-24-2003, 03:24 AM
It is for a mail script and it tells you your errors...

<?php
$errors=0;
$error="<img src="images/following.gif">";
if($Name=="" || $Subject=="" || $EmailAddress=="" || $Comments=="" ){
$errors=1;
$error.="<img src="images/sorry.gif">";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$Name."
Company Name: ".$CompanyName."
Subject: ".$Subject."
Email Address: ".$EmailAddress."
Website Address: ".$WebsiteAddress."
Comments: ".$Comments."
";
mail("webmaster@activedesigner.com","Form Submitted at your website",$message,"From: phpFormGenerator");
header("Refresh: 0;url=http://sent.html");
}
?>

duniyadnd
04-24-2003, 07:54 AM
I didn't check every single part, but the first two lines with errors regarding your backslashes missing:



$errors=0;
$error="<img src=\"images/following.gif\">";
if($Name=="" || $Subject=="" || $EmailAddress=="" || $Comments=="" ){
$errors=1;
$error.="<img src=\"images/sorry.gif\">";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$Name."
Company Name: ".$CompanyName."
Subject: ".$Subject."
Email Address: ".$EmailAddress."
Website Address: ".$WebsiteAddress."
Comments: ".$Comments."
";
mail("webmaster@activedesigner.com","Form Submitted at your website",$message,"From: phpFormGenerator");
header("Refresh: 0;url=http://sent.html");
}

thickandthin
04-25-2003, 02:00 AM
It works now and everything and I recive the mail with the contents inside but when they press submit with all the right information, it says this

Warning: Cannot modify header information - headers already sent by (output started at /home2/activede/public_html/process.php:7) in /home2/activede/public_html/process.php on line 51

thickandthin
04-25-2003, 02:03 AM
try it yourself at:
http://www.activedesigner.com/index.php?page=contact.html

duniyadnd
04-25-2003, 03:33 AM
Three quick questions:

1. What's on line 7 and above in the file: process.php

2. What's on line 51 and above (two lines) in the file: process.php

3. What version of PHP do you use?

Duniyadnd

thickandthin
04-25-2003, 03:38 AM
process.php and im not sure which php i use, btw i get the email but it still brings up that error

<!DOCTYPE HTML PUBLIC "-//W30//DTD WWW HTML 2.0//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="imagetoolbar" CONTENT="no">
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<TITLE>Active Designer</TITLE>
<STYLE TYPE="text/css">
body {
background-color:#7F7F7F;
font-size: 10pt;
font-family: verdana;
color: #FFFFFF
}
td {
font-size: 10pt;
font-family: verdana;
color: #FFFFFF
}
</STYLE>
</HEAD>
<BODY MARGINWIDTH="0" MARGINHEIGHT="0" TOPMARGIN="0" LEFTMARGIN="0">
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="600" ALIGN="CENTER">
<TR>
<TD VALIGN="BOTTOM" ALIGN="CENTER" WIDTH="600" HEIGHT="50"><IMG SRC="images/top_bar.gif" WIDTH="600" HEIGHT="50" ALT=""></TD>
</TR>
<TR>
<TD VALIGN="CENTER" ALIGN="LEFT" WIDTH="100%" HEIGHT="100" BGCOLOR="#D3D3D3" STYLE="BORDER-LEFT:1PX SOLID BLACK;BORDER-TOP:1PX SOLID BLACK;BORDER-RIGHT:1PX SOLID BLACK;"><IMG SRC="images/logo.gif" WIDTH="300" HEIGHT="100" ALT=""></TD>
</TR>
<TR>
<TD VALIGN="CENTER" ALIGN="CENTER" WIDTH="600" HEIGHT="20" BGCOLOR="#003663" STYLE="BORDER-LEFT:1PX SOLID BLACK;BORDER-RIGHT:1PX SOLID BLACK;"><MAP NAME="nav"><AREA HREF="/index.php?page=main.html" ALT="" SHAPE=RECT COORDS="0,0,75,30"><AREA HREF="/index.php?page=services.html" ALT="" SHAPE=RECT COORDS="75,0,162,30"><AREA HREF="/index.php?page=hosting.html" ALT="" SHAPE=RECT COORDS="162,0,251,30"><AREA HREF="/index.php?page=portfolio.html" ALT="" SHAPE=RECT COORDS="251,0,336,30"><AREA HREF="/index.php?page=contact.html" ALT="" SHAPE=RECT COORDS="336,0,455,30"></MAP><IMG SRC="images/nav_bar.gif" WIDTH=598 USEMAP="#nav" border=0></TD>
</TR>
<TR>
<TD VALIGN="TOP" ALIGN="CENTER" WIDTH="100%" HEIGHT="260" BGCOLOR="#003663" STYLE="BORDER-LEFT:1PX SOLID BLACK;BORDER-RIGHT:1PX SOLID BLACK;"><?php
$errors=0;
$error="<br><img src=\"images/following.gif\"><br><br>";
if($Name=="" || $Subject=="" || $EmailAddress=="" || $Comments=="" ){
$errors=1;
$error.="<img src=\"images/sorry.gif\" style=\"border:1px solid red;\">";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$Name."
Company Name: ".$CompanyName."
Subject: ".$Subject."
Email Address: ".$EmailAddress."
Website Address: ".$WebsiteAddress."
Comments: ".$Comments."
";
mail("webmaster@activedesigner.com","Active Designer Customer!!",$message,"From: ActiveDesigner.com");
header("Refresh: 0;url=/index.php?page=sent.html");
}?><br><br><br><br><br><br><a href="javascript:history.go(-1)"><img src="images/goback.gif" border=0 alt=""></a></TD>
</TR>
<TR>
<TD VALIGN="CENTER" ALIGN="CENTER" BGCOLOR="#D3D3D3" STYLE="BORDER-LEFT:1PX SOLID BLACK;BORDER-RIGHT:1PX SOLID BLACK;BORDER-TOP:1PX SOLID BLACK;BORDER-BOTTOM:1PX SOLID BLACK;" WIDTH="100%" HEIGHT="20"><IMG SRC="images/copy.gif" BORDER="0" WIDTH="300" HEIGHT="20" ALT=""></TD>
</TR>
<TR>
<TD VALIGN="BOTTOM" ALIGN="CENTER" WIDTH="600" HEIGHT="50"><IMG SRC="images/bottom_bar.gif" WIDTH="600" HEIGHT="50" ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>

duniyadnd
04-25-2003, 04:23 AM
Try this change:

header("Refresh: 0;url=http://sent.html");
to
header("Location: 0;url=http://sent.html");

Duniyadnd

Spookster
04-25-2003, 05:33 AM
thickandthin,

I have already warned you once in a previous thread about using improper subject titles for your threads.

http://www.codingforums.com/showthread.php?s=&threadid=18156

Read our posting guidelines as I stated before.

http://www.codingforums.com/postguide.htm

thickandthin
04-25-2003, 07:28 PM
sorry I thought I was allowed to do it I mean I was giving a subject, I mean its not like I said HELP or somethin...

Spookster
04-25-2003, 07:53 PM
Originally posted by thickandthin
sorry I thought I was allowed to do it I mean I was giving a subject, I mean its not like I said HELP or somethin...

A proper subject could have been "Need help with Mail Script" or "Mail Script Errors" or "Need Suggestions on Mail Script".

As for your error you can only send headers before you output anything to the browser. That means no HTML code, no echo statements in PHP, not even a space. So basically your header code is going to need to be place before any of your other code.

thickandthin
04-26-2003, 04:51 AM
I dont get it waht do i have to do

thickandthin
04-26-2003, 05:02 AM
Okay I get it now but 2 problems, okay it takes a long time for it to refresh, because so they think that they are getting an error, and also that its at the top not where i want the content to be.