Ok what I am trying to do is get this thing so that when someone fills it out, hits submit, the information entered is emailed to the target email address '$to'. My Form is in a website HTML file andlooks like this:
<FORM METHOD="GET" ACTION="formscript.php">
<P>
<B><SPAN class="required">*</SPAN>Site URL<INPUT TYPE=TEXT NAME="siteurl" SIZE="20" MAXLENGTH="256"></B></P>
</FORM>
<FORM>
<P>
<B><SPAN class="required">*</SPAN>Site Name<INPUT TYPE=TEXT NAME="sitename" SIZE="20" MAXLENGTH="256"></B></P>
<P>
<B>Button URL</B><INPUT TYPE=TEXT NAME="button" SIZE="20" MAXLENGTH="256"></P>
<P>
<B><SPAN class="required">*</SPAN>E-Mail<INPUT TYPE=TEXT NAME="email" SIZE="20" MAXLENGTH="256"></B><BR>
<BR>
<B>General Comments</B><BR>
<TEXTAREA NAME="comments" ROWS="10" COLS="50" MAXLENGTH="256">Type any additional comments here.</TEXTAREA>
<BR>
<INPUT TYPE=SUBMIT VALUE="Submit">
<INPUT TYPE=RESET VALUE="Start Over"></FORM>
My PHP script to go with it titled 'formscript.php' looks like this:
<?php
$email=$_GET['email'];
$comments=$_GET['comments'];
$to="webmaster@site.com";
$siteurl=$_GET['siteurl'];
$afbut_url=$_GET['button'];
$sitename=$_GET['sitename'];
$message="Someone has submitted a link for review.\n Their site URL is:\n$siteurl\n Their site's name is:\n$sitename\n The URL of their button is:\n$afbut_url\n Their email address is:\n$email\nThey left these comments:\n$comments\n";
$errors=0;
if (!trim($email))
{
echo "<BR><B>Your Email</B> is required.";
$errors++;
}
if (!trim($comments))
{
$comments="This person left no comments.";
}
if (!trim($siteurl))
{
echo "<BR><B>Your Site's URL</B> is required.";
$errors++;
}
if (!trim($sitename))
{
echo "<BR><B>Your site's name</B> is required.";
$errors++;
}
if ($errors > 0)
echo "<BR><BR><BR>Please use your browser's back button " .
"to return to the form, correct ";
if ($errors == 1)
echo "the error, ";
if ($errors > 1)
echo "the errors, ";
if ($errors > 0)
echo "and re-submit the form.";
if ($errors == 0)
{
echo "Your Affiliate Link has been sent to the webmaster for reviewing, thank you for the submission.";
mail($to,"Affiliate Submission",$message,"From: $email\n");
}
?>
When someone fills it out correctly, I expect to see 'Your Affiliate Link has been sent to the webmaster for reviewing, thank you for the submission.'. But I don't. Nothing happens and it doesn't send the email (I've tested it with a real email address). I've also tried making the HTML and PHP file into one big .php file and changing the form action to the name of the file it is in. In that case, it will just run the script the second someone goes to it and naturally give them all the error messages, before they even had a chance at filling it out. SOMEONE PLEASE HELP! Thanks.