Page 1 of 1

problem with mail form in template

Posted: Wed Aug 30, 2006 9:34 am
by maciek4
I bought a template from templatemonster. It has a flash banner and pages in html. When I added the mail form I changed one of the files from i_frame5.html to i_frame5.php and when I click on submit it automatically redirects me to the main page instead of showing the text message "thank you for submitting the form".

I don't know javascript, is it possible that this is causing it to go back to main page when submit is clicked?

Code: Select all

<script language="JavaScript" type="text/JavaScript">
		function load_content () {
			if (parent.document.getElementById('main_div')) {
				parent.document.getElementById('main_div').innerHTML=document.getElementById('inner_frame').innerHTML;
			}
			if (!parent.document.getElementById('main_div')) {
			window.location=('index.html') ;
			}
		}
	</script>
then there is

<body onload="load_content()">
<div id="inner_frame">

Posted: Wed Aug 30, 2006 9:56 am
by maciek4
here is the whole code. The texts are in Polish I am from Poland

Code: Select all

<?php

$mailTo = "mr@lerkins.com";
$subject = "Wiadomo¶æ ze strony http://www.unistor.pl";
    
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-2">
	<title></title>
	<link href="style.css" rel="stylesheet" type="text/css">
		<script language="JavaScript" type="text/JavaScript">
		function load_content () {
			if (parent.document.getElementById('main_div')) {
				parent.document.getElementById('main_div').innerHTML=document.getElementById('inner_frame').innerHTML;
			}
			if (!parent.document.getElementById('main_div')) {
			window.location=('index.html') ;
			}
		}
	</script>
</head>
<body  onload="load_content()">
<div id="inner_frame">
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:343px; border-left:1px solid #393E3D;">
					<tr>
						<td width="100%" bgcolor="#D0D6C6">
							<table cellpadding="0" cellspacing="0" border="0" width="100%" style="height:100%;">
								<tr><td align="center"><div style="margin-top:15px;"><img src="images/topic5.jpg" alt=""></div><div style="margin-top:25px; margin-bottom:25px;">
								
							<?
							
							   						if(isset($_POST) && !empty($_POST)) {
    foreach($_POST as $key => $item) {
        $$key = $item;
    }
}

if(!isset($sendmail)) {
    $sendmail = "no";
    $mailSended = false;
    
    $name = "";
    $mail = "";
    $tresc = "";
	
}

$name_error = false;
$mail_error = false;

if($sendmail == "yes")
{

    $error = false;

    if(!$name) {
        $name_error = true;
        $error = true;
    }
    
    if(!ereg ("[a-zA-Z]{1,}\@[a-zA-Z]{1,}", $mail)) { $sendmail = false; $mail_error = true; }
    
    if(!$error) {
        $mailBody = "Imiê i Nazwisko: ".$name."\n";
	    $mailBody .= "E-mail: ".$mail."\n";
	    $mailBody .= "Wiadomo¶æ: ".$tresc."\n";
	    
	$headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/plain; charset=iso-8859-2' . "\r\n";

        mail($mailTo, $subject, $mailBody, $headers);
        $mailSended = true;
        
        } else {
        $mailSended = false;
    }
}

?>

<?
    if($mailSended == true) {
?>


<b style="color:F0AA6E;" class="tah12">Dziêkujemy za wype³nienie formularza.  <br><br>Skontaktujemy siê z pañstwem w ci±gu 3 roboczych dni.</b>

<?
    } else {
?>
<br>
	Pola z gwiazdk± * musz± byæ uzupe³nione przed wys³aniem.
	<br><br>
<?  if($sendmail == "yes") { ?> <b style='color:red;' class='tah12'>Wszystkie wymagane informacje nie zosta³y poprawnie wype³nione.<br>Pola zaznaczone kolorem czerwonym powinny byæ poprawione. <br>Prosze spróbowaæ ponownie.</b> <? } ?>
									<form method="post" id="form" action="iframe_5.php"><input type="hidden" name="sendmail" value="yes"><table cellpadding="0" cellspacing="0" border="0">
								
	<tr>
	<td height="40"><? if($sendmail == true && $name_error == true) {?>
		<font color="red"><b>*Imiê i Nazwisko:</b></font>
	<?} else {?>
		
	*Imiê i Nazwisko:<?}?><br><input name="name" type="text" value="<?=$name;?>"></td></tr>
	<tr><td height="40"><? if($sendmail == true && $mail_error == true) {?>
		<font color="red"><b>*E-mail:</b></font>
	<?} else {?>
		
	*E-mail:<?}?><br><input name="mail" type="text" value="<?=$mail;?>"></td></tr>
	<tr><td height="40">*Tre¶æ:<br><textarea name="tresc" rows="3" cols="3"><?=$tresc;?></textarea></td></tr>
	<tr><td align="right" style="padding-top:2px; "><span>
	
	<a href="#" onclick="document.getElementById('form').reset()">Wyma¿</a><img src="images/spacer.gif" width="30" height="1" alt="">
	<!--<a href="iframe_5.php"><input type="image" onclick="document.getElementById('form').reset()" border="0" width="62" height="22" src="images/clear_2.gif"></a>
	<input type="image" border="0" width="62" height="22" src="images/send_2.gif">-->
	<a href="iframe_5.php" onclick="document.getElementById('form').submit()">Wy¶lij</a></span></div></td></tr>
</table></form>	<? } ?>
</td>
								</tr>
								
							</table>
						</td>
		
						<td height="100%">
							<table cellpadding="0" cellspacing="0" border="0" width="131" style="height:100%;" class="bg_box_2">
								
								<tr><td bgcolor="#C57C15">
<img src="images/formularz.jpg"  alt="">
							</table>
						</td>
					</tr>
				</table>
</div>
</body>
</html>