PDA

View Full Version : Contact Form



malidia
April 25th, 2005, 03:49 PM
I have done this tutorial:

http://www.kirupa.com/web/php_contact_form.htm

and it's easy and i can do it, BUT! for some reason i can't get the php page to take the information from the contact form, send it to my email, and then go to a seperate confirmation page, i thought i had this figured out but apparently i don't.

so far i have



<?php

if(isset($_POST['submit'])) {

$to = "tblank@imagetechnologies.com";

$subject = "SUBSCRIBTION NOTIFICATION";

$name_field = $_POST['name'];

$email_field = $_POST['email'];

$company_field = $_POST['company'];

$option = $_POST['radio'];

$body = "From: $name_field\n E-Mail: $email_field\n Company: $company_field\n $option\n";

mail($to, $subject, $body);

header ("Location: http://www.imagetechnologies.com");



} else {

echo "ERROR: no data sent!";

}

?>



and when i put the information in the form it takes me to the url in the code, but the information does not get mailed to me, i am assuming the header command is a bad thing to put in the middle of the PHP code, but how then do i get it to send me the information and then go to a url of my choice?

any help would be fantastic

Divex
April 25th, 2005, 03:55 PM
I need Flash contact : /

Enigmatic
April 25th, 2005, 04:29 PM
<?php
if(isset($_POST['submit']))
{
$to = "tblank@imagetechnologies.com";
$subject = "SUBSCRIBTION NOTIFICATION";
$name_field = strip_tags($_POST['name']; '')
$email_field = strip_tags($_POST['email']; '')
$company_field = strip_tags($_POST['company']; '')
$option = stript_tags($_POST['radio']; '')
$body = "From: $name_field\n E-Mail: $email_field\n Company:

// Addtional headers
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name_field <$email_field>\r\n";

mail($to, $subject, $name_field, $email_field, $company_field, $option, $body, $headers);

//if the client browser does not ,give your thanks message here
echo "Get a better browser sloth man !";

//your thank you URL
header("Refresh:5; URL = http://www.yourDomain.com/thankyou.php");

exit;
}
?>

Give that a go and let us know.


Flash Email Form
http://www.kirupa.com/developer/actionscript/flash_php_email.htm

Hope that helps both parties.

malidia
April 26th, 2005, 10:03 AM
HEY! that works a lot better, thank you so much...u rule!

Enigmatic
April 26th, 2005, 05:45 PM
Glad to have been of some use :p:

I just took a quick look at the tutorial and couldnt see anything to do with validation [ I may have missed it in my haste ]. Does your script use validation at all because if not, it may be a good idea to look into it.

malidia
April 27th, 2005, 09:39 AM
cool, i think i might, i am new at php and it couldn't hurt at al

Enigmatic
April 27th, 2005, 01:59 PM
cool, i think i might, i am new at php and it couldn't hurt at al

Along with PHP validation, look into JavaScript validation as this si client side and will speed up the process.


<script language="JavaScript" type="text/JavaScript">
function checkForm()
{
var gname_field, gemail_field, gcompany_field, gbody;
with(window.document.contactform)
{
gname_field = name_field;
gemail_field = email_field;
gcompany_name = company_name;
gbody = body;
}
if(gname_field.value == '')
{
alert('Please enter your name!');
gname_field.focus;
return false;
}
if(gemail_field.value == '')
{
alert('Please enter your email!');
gemail_field.focus;
return false;
}
if(gcompany_name.value == '')
{
alert('Please enter your company name!');
gcompany_name.focus;
return false;
}
else if(gbody.value == '')
{
alert('Enter your message!');
gbody.focus;
return false;
}
else
{
return true;
}
}
</script>

Thats an example of JavaScript validation, I prefer that to PHP as I said before because it is client side and takes some of the load off the server.

Anywho, hope thats of some help & good luck.