sending e-mail form!? Help!

sending e-mail form!? Help!

am 19.12.2007 04:31:24 von Majki Majk

Hi! I'm not managing to start this script. It's my first php script i'm
implementing. I'm not an php scripter, i am an html/css amater working on
society association.

I have apache server on my computer. I have inserted this php script into
my website folder which is emailform.php and the contact form part into
html/css document. But when trying to send e-mail on my computer to test the
script then a box for 'saving file' jumps out into the screen, so,....here
is the emailform.php script text. I think it's a bit long, but am not
competant to confirm that.


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">





Emailing Form Data










//This is a very simple PHP script that outputs the name of each bit of
information (that corresponds to the name attribute for that
field) along with the value that was sent with it right in the browser
window, and then sends it all to an email address (once you've added it to
the script).

if (empty($_POST)) {

print "

No data was submitted.

";

print "";

exit();

}

//Creates function that removes magic escaping, if it's been applied, from
values and then removes extra newlines and returns to foil spammers. Thanks
Larry Ullman!

function clear_user_input($value) {

if (get_magic_quotes_gpc()) $value=stripslashes($value);

$value= str_replace( "\n", '', trim($value));

$value= str_replace( "\r", '', $value);

return $value;

}



if ($_POST['comments'] == 'Please share any comments you have here')
$_POST['comments'] = '';

//Create body of message by cleaning each field and then appending each name
and value to it

$body ="Here is the data that was submitted:\n";

foreach ($_POST as $key => $value) {

$key = clear_user_input($key);

$value = clear_user_input($value);

if ($key=='extras') {


if (is_array($_POST['extras']) ){

$body .= "$key: ";

$counter =1;

foreach ($_POST['extras'] as $value) {

//Add comma and space until last element

if (sizeof($_POST['extras']) == $counter) {

$body .= "$value\n";

break;}

else {

$body .= "$value, ";

$counter += 1;

}

}

} else {

$body .= "$key: $value\n";

}

} else {

$body .= "$key: $value\n";

}

}

extract($_POST);

//removes newlines and returns from $email and $name so they can't smuggle
extra email addresses for spammers

$email = clear_user_input($email);

$name = clear_user_input($name);

//Create header that puts email in From box along with name in parentheses
and sends bcc to alternate address

$from='From: '. $email . "(" . $name . ")" . "\r\n" . 'Bcc:
youremail@yourdomain.com' . "\r\n";



//Creates intelligible subject line that also shows me where it came from

$subject = 'Bed Order from Web Site';

//Sends mail to me, with elements created above

mail ('youremail@yourdomain.com', $subject, $body, $from);



?>

Thanks for your order! We'll send your bed right away.







Re: sending e-mail form!? Help!

am 19.12.2007 05:15:50 von Steve

dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!

Re: sending e-mail form!? Help!

am 19.12.2007 10:20:05 von Jeff Gaines

On 19/12/2007 in message Steve wrote:

>dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!

Is that a Christmas joke or have you confused the two terms?

--
Jeff Gaines Damerham Hampshire UK
The facts, although interesting, are irrelevant

Re: sending e-mail form!? Help!

am 19.12.2007 10:39:53 von Majki Majk

"Jeff Gaines" wrote in message
news:xn0ff4k8y2knfuj000@news.individual.net...
> On 19/12/2007 in message Steve wrote:
>
>>dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!
>
> Is that a Christmas joke or have you confused the two terms?
>
> --
> Jeff Gaines Damerham Hampshire UK
> The facts, although interesting, are irrelevant

Sorry if something went wrong....:)
Heh, dude could You help me rather, i'm breaking down here...
Majki

Re: sending e-mail form!? Help!

am 19.12.2007 13:53:24 von Vanscot

Ok, first of all, dont reinvent the wheel, there are plenty of
mail script out there, but if you must/want to do so here
are some guidelines:

1 Avoid mixin logic, functions declarations and output: just like
you take apart html from css, you should take your functions
declaration
in one file, your script logic into another file and do the output in
a template or something like that.

2 Do you have _only_ apache installed?: if so, you need to instal php
as well.

3 Avoid "SuperScripts" that does all-what-you-need, use includes and
separated scripts.

4 Define (and on this case explain) your goal: I can say that you want
to send an email,
but maybe I'm wrong at that.

5 Try to ease your life, use (if you can) the pear, pecl or pecl4win.
(Just add a .php.net and browse).

I'll be waiting your reply so maybe we can crack this down.

On Dec 19, 6:39 am, "Majki Majk" wrote:
> "Jeff Gaines" wrote in message
>
> news:xn0ff4k8y2knfuj000@news.individual.net...
>
> > On 19/12/2007 in message Steve wrote:
>
> >>dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!
>
> > Is that a Christmas joke or have you confused the two terms?
>
> > --
> > Jeff Gaines Damerham Hampshire UK
> > The facts, although interesting, are irrelevant
>
> Sorry if something went wrong....:)
> Heh, dude could You help me rather, i'm breaking down here...
> Majki

Re: sending e-mail form!? Help!

am 19.12.2007 14:13:16 von Courtney

Vanscot wrote:
> Ok, first of all, dont reinvent the wheel, there are plenty of
> mail script out there, but if you must/want to do so here
> are some guidelines:
>
> 1 Avoid mixin logic, functions declarations and output: just like
> you take apart html from css, you should take your functions
> declaration
> in one file, your script logic into another file and do the output in
> a template or something like that.
>
> 2 Do you have _only_ apache installed?: if so, you need to instal php
> as well.
>
> 3 Avoid "SuperScripts" that does all-what-you-need, use includes and
> separated scripts.
>
> 4 Define (and on this case explain) your goal: I can say that you want
> to send an email,
> but maybe I'm wrong at that.
>
> 5 Try to ease your life, use (if you can) the pear, pecl or pecl4win.
> (Just add a .php.net and browse).
>
> I'll be waiting your reply so maybe we can crack this down.
>
> On Dec 19, 6:39 am, "Majki Majk" wrote:
>> "Jeff Gaines" wrote in message
>>
>> news:xn0ff4k8y2knfuj000@news.individual.net...
>>
>>> On 19/12/2007 in message Steve wrote:
>>>> dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!
>>> Is that a Christmas joke or have you confused the two terms?
>>> --
>>> Jeff Gaines Damerham Hampshire UK
>>> The facts, although interesting, are irrelevant
>> Sorry if something went wrong....:)
>> Heh, dude could You help me rather, i'm breaking down here...
>> Majki
>


Try this one


It pretty much works..

Her is the relevant stylesheet.,

/Styles/Style.css
=================

..S1 {

font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
vertical-align: middle;
text-align: center;
word-spacing: normal;
line-height: 10pt;
font-style: normal;
font-weight: bold;
font-variant: normal;
color: white

}

..S2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
vertical-align: middle;
text-align: center;
word-spacing: normal;
line-height: 10pt;
font-style: normal;
font-weight: bold;
font-variant: normal;
color: #000080;

}

..S3 {

font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
text-align: center;
vertical-align: middle;
word-spacing: normal;
line-height: 10pt;
font-style: normal;
font-weight: bold;
font-variant: normal;
color: #800000;
}
..button1
{
background-image: url("../images/button2.gif");
background-repeat: no-repeat;
background-position: center center;
text-align: center;
vertical-align: middle;
}
..button2
{
background-image: url("../images/button1.gif");
background-repeat: no-repeat;
background-position: center center;
text-align: center;
vertical-align: middle;
}


And the PHP code.

Contact.php
===========


?>

title





$from=$_POST['from_address'];
$to=$_POST['target_email'];
$body=$_POST['message_body'];
$subject=$_POST['subject'];
/*echo "From: ".$from."
";
echo "To: ".$to."
";
echo "Subject: ".$subject."
";
echo $body."
"; */
if((strlen($from))>0) // have a valid mail
{
mail($to,$subject,$body,"From: ".$from."\r\nReply-To:".$from."\r\n","-f
postmaster@mysite.org");
}
?>











Send us an email




Enter your E-Mail address:




Enter The Subject:




Enter your message here:



onmouseover="this.className='button2'">
onmouseover="this.className='s2'"
onclick="this.className='s3';sendmail();">Send Mail





The only bits missing are the button images. These are done in a
graphics program, and I would post them, but they are binaries.

Re: sending e-mail form!? Help!

am 19.12.2007 14:35:06 von Rob

On Dec 19, 12:53 pm, Vanscot wrote:
> Ok, first of all, dont reinvent the wheel, there are plenty of
> mail script out there, but if you must/want to do so here
> are some guidelines:
>
> 1 Avoid mixin logic, functions declarations and output: just like
> you take apart html from css, you should take your functions
> declaration
> in one file, your script logic into another file and do the output in
> a template or something like that.
>
> 2 Do you have _only_ apache installed?: if so, you need to instal php
> as well.
>
> 3 Avoid "SuperScripts" that does all-what-you-need, use includes and
> separated scripts.
>
> 4 Define (and on this case explain) your goal: I can say that you want
> to send an email,
> but maybe I'm wrong at that.
>
> 5 Try to ease your life, use (if you can) the pear, pecl or pecl4win.
> (Just add a .php.net and browse).
>
> I'll be waiting your reply so maybe we can crack this down.
>
> On Dec 19, 6:39 am, "Majki Majk" wrote:
>
>
>
> > "Jeff Gaines" wrote in message
>
> >news:xn0ff4k8y2knfuj000@news.individual.net...
>
> > > On 19/12/2007 in message Steve wrote:
>
> > >>dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!
>
> > > Is that a Christmas joke or have you confused the two terms?
>
> > > --
> > > Jeff Gaines Damerham Hampshire UK
> > > The facts, although interesting, are irrelevant
>
> > Sorry if something went wrong....:)
> > Heh, dude could You help me rather, i'm breaking down here...
> > Majki- Hide quoted text -
>
> - Show quoted text -

Firstly, I'd like to say that I'm NOT trying to have a go at
you......but, I think you're comments are completely wrong in this
case.

This guy is obviously a complete noob to PHP (and possibly
programming), and throwing him into MVC is not the way to learn the
basics.

As a first attempt, the way he's going about the script is fine and
will allow him to learn, and more importantly, debug the problems.

Rob.

Re: sending e-mail form!? Help!

am 19.12.2007 14:44:25 von Rob

On Dec 19, 3:31 am, "Majki Majk" wrote:
> Hi! I'm not managing to start this script. It's my first php script i'm
> implementing. I'm not an php scripter, i am an html/css amater working on
> society association.
>
> I have apache server on my computer. I have inserted this php script into
> my website folder which is emailform.php and the contact form part into
> html/css document. But when trying to send e-mail on my computer to test the
> script then a box for 'saving file' jumps out into the screen, so,....here
> is the emailform.php script text. I think it's a bit long, but am not
> competant to confirm that.
>
> >
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
>
>
>
>
> Emailing Form Data
>
>
>
>
>
>
>
> >
> //This is a very simple PHP script that outputs the name of each bit of
> information (that corresponds to the name attribute for that
> field) along with the value that was sent with it right in the browser
> window, and then sends it all to an email address (once you've added it to
> the script).
>
> if (empty($_POST)) {
>
> print "

No data was submitted.

";
>
> print "";
>
> exit();
>
> }
>
> //Creates function that removes magic escaping, if it's been applied, from
> values and then removes extra newlines and returns to foil spammers. Thanks
> Larry Ullman!
>
> function clear_user_input($value) {
>
> if (get_magic_quotes_gpc()) $value=stripslashes($value);
>
> $value= str_replace( "\n", '', trim($value));
>
> $value= str_replace( "\r", '', $value);
>
> return $value;
>
> }
>
> if ($_POST['comments'] == 'Please share any comments you have here')
> $_POST['comments'] = '';
>
> //Create body of message by cleaning each field and then appending each name
> and value to it
>
> $body ="Here is the data that was submitted:\n";
>
> foreach ($_POST as $key => $value) {
>
> $key = clear_user_input($key);
>
> $value = clear_user_input($value);
>
> if ($key=='extras') {
>
> if (is_array($_POST['extras']) ){
>
> $body .= "$key: ";
>
> $counter =1;
>
> foreach ($_POST['extras'] as $value) {
>
> //Add comma and space until last element
>
> if (sizeof($_POST['extras']) == $counter) {
>
> $body .= "$value\n";
>
> break;}
>
> else {
>
> $body .= "$value, ";
>
> $counter += 1;
>
> }
> }
> } else {
>
> $body .= "$key: $value\n";
>
> }
> } else {
>
> $body .= "$key: $value\n";
>
> }
> }
>
> extract($_POST);
>
> //removes newlines and returns from $email and $name so they can't smuggle
> extra email addresses for spammers
>
> $email = clear_user_input($email);
>
> $name = clear_user_input($name);
>
> //Create header that puts email in From box along with name in parentheses
> and sends bcc to alternate address
>
> $from='From: '. $email . "(" . $name . ")" . "\r\n" . 'Bcc:
> yourem...@yourdomain.com' . "\r\n";
>
> //Creates intelligible subject line that also shows me where it came from
>
> $subject = 'Bed Order from Web Site';
>
> //Sends mail to me, with elements created above
>
> mail ('yourem...@yourdomain.com', $subject, $body, $from);
>
> ?>
>
>

Thanks for your order! We'll send your bed right away.


>
>
>
>

I think the problem is with your HTML page - please post the contents
here.

Re: sending e-mail form!? Help!

am 19.12.2007 15:28:51 von Steve

"Jeff Gaines" wrote in message
news:xn0ff4k8y2knfuj000@news.individual.net...
> On 19/12/2007 in message Steve wrote:
>
>>dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!
>
> Is that a Christmas joke or have you confused the two terms?

lol...no, that was me posting replies at a late hour having missed sleeping
much the night before. :)

merry xmas though. ho, ho, ho (the cheery kind, not the slutty, derogatory
type)

Re: sending e-mail form!? Help!

am 20.12.2007 02:41:10 von Majki Majk

>
> I think the problem is with your HTML page - please post the contents
> here.

@Rob hey! Here is the html content...




Vasi Kontaktni Detalji


















Komentari













AND THE .CSS PART....

/* KONTAKT FORMA*/

form {
font-size: 1.4em;
width: 25em;
}


/* fieldset styling */
fieldset {
margin: 1em 0; /* space out the fieldsets a little*/
padding: 1em;
border : 1px solid #ccc;
}

/* legend styling */
legend {
font-weight: bold;
}

#comments_form {
margin-left: 55px ;
margin-top: -35px;
}


/* style for labels */
label {
display: block;
}

/* style for required labels */
label .required {
font-size: 0.75em;
color:#760000;
}

input {
width: 200px;
}


input.radio, input.submit {
width: auto;
}

/* style form elements on focus */
input:focus, textarea:focus {
background: #ffc;
}

input.radio {
float: left;
margin-right: 1em;
}

textarea {
width: 300px;
height: 100px;
}

/* Hack to make sure the floated radio buttons
sit next to the labels correctly in IE/Mac*/

/* This is the style I want IE/Mac to see */
input.radio + label {
text-indent: 2em;
}

/* Using the commented backslash filter, I'm resetting
the above rule for everything other than IE5/Mac \*/
input.radio + label {
text-indent: 0;
}

/* End the hack */

Re: sending e-mail form!? Help!

am 20.12.2007 02:53:39 von Majki Majk

"Vanscot" wrote in message
news:ce1a942c-7e87-488e-ad5c-74dfcdea5adf@c4g2000hsg.googleg roups.com...
> Ok, first of all, dont reinvent the wheel, there are plenty of
> mail script out there, but if you must/want to do so here
> are some guidelines:
>
> 1 Avoid mixin logic, functions declarations and output: just like
> you take apart html from css, you should take your functions
> declaration
> in one file, your script logic into another file and do the output in
> a template or something like that.
>
> 2 Do you have _only_ apache installed?: if so, you need to instal php
> as well.
>
> 3 Avoid "SuperScripts" that does all-what-you-need, use includes and
> separated scripts.
>
> 4 Define (and on this case explain) your goal: I can say that you want
> to send an email,
> but maybe I'm wrong at that.
>
> 5 Try to ease your life, use (if you can) the pear, pecl or pecl4win.
> (Just add a .php.net and browse).
>
> I'll be waiting your reply so maybe we can crack this down.
>
> On Dec 19, 6:39 am, "Majki Majk" wrote:
>> "Jeff Gaines" wrote in message
>>
>> news:xn0ff4k8y2knfuj000@news.individual.net...
>>
>> > On 19/12/2007 in message Steve wrote:
>>
>> >>dude, DON'T crosspost. multipost if you must, but DON'T crosspost!!!
>>
>> > Is that a Christmas joke or have you confused the two terms?
>>
>> > --
>> > Jeff Gaines Damerham Hampshire UK
>> > The facts, although interesting, are irrelevant
>>
>> Sorry if something went wrong....:)
>> Heh, dude could You help me rather, i'm breaking down here...
>> Majki
>

Hi!
1.ok! Didn't understand you quite right, but basically i do. I have some
instructions about sending an e-mail over php in some book, but all that
seems too complicate for managing in very short time. I would like to
publish webpage in two days...so that's the catch.
2.I have easy php 2.0 which is a package containing php5
3.ok
4.Yeah, i would like to get a mail over the internet so people of this
borough can contact me with the ideas, complaints, whatever they want to
say....
5. Didn't understand, i'm a beginner so :) If you ment perl, uff, that's
even more complicated than this, i find php scripting from my amater point
of view, friendly using.

With Regard,
Majki

Re: sending e-mail form!? Help!

am 20.12.2007 07:30:50 von Majki Majk

When webpage is on internet than there's no that save popup out into the
screen, but i don't receive the message onto my mailbox !

MAjki

Re: sending e-mail form!? Help!

am 20.12.2007 07:36:48 von Majki Majk

I definitely have a problem with discerning which part of php code is
important for changing so it to works. And what parts i may play with and so
on...all those strings, comands, ...uff, i hope i never become a programmer,
yeah right =)