Funk-woo10
Feb 7th 2008, 4:59 am
Hi all I am making up a bais contact form, however whe I submit the form I need the results to be displayed on the same page as the form.
At the mo its takes me to another page. How so I get it to do that ?
I assume its a if statement, where you "post to self" in the form action ?
Here is my two bits of code - Thanks.
Form:
<form method="post" action="www.mysite.com/contact">
<fieldset>
<legend>Contact us</legend>
<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<b>Your Name:</b> <br /><input type="text" name="visitor" size="35" />
<br /> <br />
<b>Your Email:</b> <br /><input type="text" name="visitormail" size="35" />
<br /> <br />
<b>Subject:</b><br />
<select name="attn" size="1" />
<option value=" Advertising ">Advertising </option>
<option value=" Press ">Press </option>
<option value=" Report a bug ">Report a bug </option>
<option value=" Account help ">Account help </option>
<option value=" Other (explain below) ">Other (explain below) </option>
</select>
<br /><br />
<b>Mail Message:</b>
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br /><br />
<input type="submit" value="Send Mail" />
<br />
</fieldset>
</form>
php part
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
mail("email@hotmail.com", $subject, $message, $from);
?>
<fieldset>
<legend>Message sent</legend>
<p>Thanks <?php echo $visitor ?> we will respond to the e-mail your provided ( <?php echo $visitormail ?> )</p>
<p><b>Subject:</b> <?php echo $attn ?></p>
<p><b>Message:</b> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?></p>
<p><b>Date sent:</b> <?php echo $todayis ?> <b> - from IP address :</b><?php echo $ip ?></p>
<br /><br />
<a href="***"> Next Page </a>
</fieldset>
At the mo its takes me to another page. How so I get it to do that ?
I assume its a if statement, where you "post to self" in the form action ?
Here is my two bits of code - Thanks.
Form:
<form method="post" action="www.mysite.com/contact">
<fieldset>
<legend>Contact us</legend>
<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
<b>Your Name:</b> <br /><input type="text" name="visitor" size="35" />
<br /> <br />
<b>Your Email:</b> <br /><input type="text" name="visitormail" size="35" />
<br /> <br />
<b>Subject:</b><br />
<select name="attn" size="1" />
<option value=" Advertising ">Advertising </option>
<option value=" Press ">Press </option>
<option value=" Report a bug ">Report a bug </option>
<option value=" Account help ">Account help </option>
<option value=" Other (explain below) ">Other (explain below) </option>
</select>
<br /><br />
<b>Mail Message:</b>
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br /><br />
<input type="submit" value="Send Mail" />
<br />
</fieldset>
</form>
php part
<?php
$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];
if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}
$todayis = date("l, F j, Y, g:i a") ;
$attn = $attn ;
$subject = $attn;
$notes = stripcslashes($notes);
$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";
$from = "From: $visitormail\r\n";
mail("email@hotmail.com", $subject, $message, $from);
?>
<fieldset>
<legend>Message sent</legend>
<p>Thanks <?php echo $visitor ?> we will respond to the e-mail your provided ( <?php echo $visitormail ?> )</p>
<p><b>Subject:</b> <?php echo $attn ?></p>
<p><b>Message:</b> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?></p>
<p><b>Date sent:</b> <?php echo $todayis ?> <b> - from IP address :</b><?php echo $ip ?></p>
<br /><br />
<a href="***"> Next Page </a>
</fieldset>