Click to See Complete Forum and Search --> : Another line or a new mailing.php ?


PERFECTGREENEYE
08-26-2005, 08:11 AM
hi everybody.
i need some help here please. i always design first my forms in frontpage and after i bind them to my php file. now in this case i have designed two forms. a simple one with 3 boxes:
NAME
EMAIL
SUGGESTION
i have wrote the mailing.php for it like this:
-----------------
<?php

// your email address
$youremail = "adminatbicestertown.co.uk";
// field validation
if ($email=="" || $comments=="" || $name=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// email validation
if(!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$', $email)) {
print ("Your email address does not appear to be valid. Please go back and try again.");
exit;
}
// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Feedback Form";
$message = "$comments";
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent to Bicester Town.");
}
?>
---------------------

The second form it's same like above form but contains a few more fields(boxes)

BUSINESS NAME
CONTACT PERSON
PHONE
EMAIL
WEB
DETAILS

i have not made the php yet for this one as i have a few questions before.

1) Can i use the above php code for the same job? if yes, what do i have to do? To add a few more fields? Or i have to design a new php file with a different name?

thank you very much for your time and understanding.

bokeh
08-26-2005, 10:00 AM
That's the first time I've heard someone use 'design' and 'frontpage' in the same sentence.

Also your regex stops legal email addresses. Six character TLDs are legal for example.

Regarding your question, you could do it either way but I would use a separate script for each.

PERFECTGREENEYE
08-26-2005, 11:50 AM
That's the first time I've heard someone use 'design' and 'frontpage' in the same sentence This is a good one! :)
Unfortunately the project that I am working now has been started in front page. When I join them was already 40% done so I just ...u know...follow the sheep. I prefer dreamweaver and in fact I can say that I am a lot better than in fp. when is about php I am a real beginner.

q1: what is a regex :confused:
q2: when I have made that mailing.php I had a simple mailing tutorial. (In fact was already done. I have just changed the email address.) In this case, with multiple fields...I have no idea how it can be done. Can you point me a tutorial or something like that to give me a better idea?
Thank you very much

bokeh
08-26-2005, 01:01 PM
I can't read your code posted like that so:<?php

// your email address
$youremail = "adminatbicestertown.co.uk";
// field validation
if ($email=="" || $comments=="" || $name=="")
{
print ("All fields are required! Please go back and try again.");
}
else {
// email validation
if(!eregi('^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$', $email)) {
print ("Your email address does not appear to be valid. Please go back and try again.");
exit;
}
// send email
$headers = "From: \"$name\" <$email>\n";
$subject = "Feedback Form";
$message = "$comments";
mail ("$youremail", "$subject", $message, $headers);
print ("Thank you $name, your email has been sent to Bicester Town.");
}
?>

This is the regex^([._a-z0-9-]+[._a-z0-9-]*)@(([a-z0-9-]+\.)*([a-z0-9-]+)(\.[a-z]{2,3})?)$You should change the final 3 to a 6 but there may be other errors.

If you post the form I will make the script for you.

cobrasniper555
08-27-2005, 03:35 PM
I'm new with PHP, but shouldn't the line:print ("Thank you $name, your email has been sent to Bicester Town."); beprint ("Thank you ".$name", your email has been sent to Bicester Town."); . Because of the variable "$name" be connected with the period to the sentence.

bokeh
08-27-2005, 05:35 PM
I'm new with PHP, but shouldn't the line:print ("Thank you $name, your email has been sent to Bicester Town."); beprint ("Thank you ".$name", your email has been sent to Bicester Town."); . Because of the variable "$name" be connected with the period to the sentence.That is not necessary when the variable is in a double quoted string literal. Also your 'correction' is missing a period.