Re: [PHP-DB] PHP and mail forms

2004-02-02 Thread -{ Rene Brehmer }-
I wrote mine specially ... it runs with a preview phase which was pretty
tricky to put in ... but the to-value is hardcoded in the script, cuz it
just sends mail to [EMAIL PROTECTED] ... when the user fills in the
form the script checks it for errors, and then either bounce back to the
form if there are any errors, or to the preview if there's not (atleast I
think I kept the preview in there, not sure anymore, been a long while) 
and then on to a thank you message 

I control it all using hidden form fields ... pretty simple ... it's coded
to my old site-structure, before I started to use templates ... so it's a
bit difficult to peel it out and show it to you though  but will try if
requested...

FWIW

Rene

Fate would have it, that on Fri, 30 Jan 2004 09:41:11 -, Ricardo Lopes
wrote:

There are several ways to do this.
Some people like the approach:

if ($submit) { send_email(); }

or you can put a hidden field in your form, like op:

input name=op type=hidden id=op value=send /

and use:

if (isset($HTTP_GET_VARS['op'])  ($HTTP_GET_VARS['op'] == 'send'))
{
send_email();
}

and there are many others.
by the way in the code you wrote you have:

form method=post .

and then you use:

$id=$_GET['id'];  ---  if this is the same than $HTTP_GET_VARS['id'] this
wont work


Where does that mail function (is it a function?)  go?

The function sends an email, for more details consult the php manual.

-- 
Rene Brehmer
aka Metalbunny

http://metalbunny.net/
References, tools, and other useful stuff...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] PHP and mail forms

2004-01-30 Thread Ricardo Lopes
There are several ways to do this.
Some people like the approach:

if ($submit) { send_email(); }

or you can put a hidden field in your form, like op:

input name=op type=hidden id=op value=send /

and use:

if (isset($HTTP_GET_VARS['op'])  ($HTTP_GET_VARS['op'] == 'send'))
{
send_email();
}

and there are many others.
by the way in the code you wrote you have:

form method=post .

and then you use:

$id=$_GET['id'];  ---  if this is the same than $HTTP_GET_VARS['id'] this
wont work


Where does that mail function (is it a function?)  go?

The function sends an email, for more details consult the php manual.


- Original Message -
From: Phil Matt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, January 29, 2004 7:10 PM
Subject: [PHP-DB] PHP and mail forms


 Hello to all.

 I am trying to write a simple (at least I thought it was simple...)
Contact Us form that
 sends an email when it is submitted.

 The $to_name variable was passed from a previous page. I am sure that the
variable
 was passed, as I can echo it and it is being passed correctly - thanks to
this list!

 The problem I am having is this: I cannot quite figure out how an html
form handles this
 mail function when the to field is filled with an existing variable.

 This is what I've got: (I removed all of the table formatting to make it
clearer here)

 form name=mailer method=post action=? $_SERVER['PHP_SELF']; ?
 input name=from_name type=text id=from_name
value=?=$from_name?
 input name=from_email type=text id=from_email
value=?=$from_email?
 input name=subject type=text id=subject value=?=$subject?
size=60
 textarea name=message cols=55 rows=15
 id=message?=$message?/textarea

 input name=userid type=hidden id=userid value=?$to_name? /
   input type=submit name=Submit value=mail

 So, I think that this sets up the form for processing, AFAIK.

 Then, I added the stuff that pulls the email address associated with the
id in $to_name
 from the MySQL database, and adds the string for the proper domain. I've
left out the
 connection stuff for clarity:

 $id=$_GET['id'];
 $string=@somedomain.com;
 $result= mysql_query(SELECT * FROM mydatabase WHERE ID=$id,$db);
 while ($myrow = mysql_fetch_row($result)){
 $to_name=$myrow[3]$string; } ?

 I know that the thing that actually sends mail looks like this:

 mail($to_name, $from_name, $subject, $message, From:
$from_email\nX-Mailer: PHP/
 .. phpversion());

 But how do I get this all to happen when the user hits the submit button?
Where does
 that mail function (is it a function?)  go? I have read a lot of stuff on
the various PHP lists
 and sources, but I just cannot figure out this piece of the puzzle.

 TIA for your suggestions, and for your patience with my lack of knowledge
here.

 -- Phil Matt

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PHP and mail forms

2004-01-30 Thread Phil Matt
Ricardo Lopes wrote: 

 There are several ways to do this. 
 Some people like the approach: 
  
 if ($submit) { send_email(); } 
  
 or you can put a hidden field in your form, like op: 
  
 input name=op type=hidden id=op value=send / 
  
 and use: 
  
 if (isset($HTTP_GET_VARS['op'])  ($HTTP_GET_VARS['op'] == 'send')) 
 { 
 send_email(); 
 } 

Thanks again, Ricardo. I now have the form communicating with the server. 

I think that I might have an error in my script: 

Where I join together the value of the passed variable ($myrow[3]) and the string  
containing the domain ( $string=@somedomain.com)  I used: 

 $to_name=$myrow[3]$string 

If the passed variable's value is, for instance, smith, then does my $to_name 
become: 

[EMAIL PROTECTED] 

On hitting the submit button, I see the server being called and data being sent, but  
nothing is being received. I'm just wondering if I've appended those two things 
correctly. 

TIA for your continued assistance. 

Cheers --- Phil 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] PHP and mail forms

2004-01-30 Thread Ricardo Lopes
I would recomed you to use:

$to_name=$myrow[3].$string;  -- Notice the dot . and no 

instead of:

$to_name=$myrow[3]$string;

 On hitting the submit button, I see the server being called and data being
sent, but
 nothing is being received. I'm just wondering if I've appended those two
things correctly.

If you mean the server sends the email but it isnt recived in the other
server i can't help you i dont use the mail function, in this kind of
questions you should use the other mailing list instead of this, this is
only from database questions related to php.

Good luck.

BTW i guess there are other function you could use for sending email instead
of mail consult the php documentation to know more.

- Original Message -
From: Phil Matt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, January 30, 2004 4:18 PM
Subject: [PHP-DB] PHP and mail forms


 Ricardo Lopes wrote:

  There are several ways to do this.
  Some people like the approach:
 
  if ($submit) { send_email(); }
 
  or you can put a hidden field in your form, like op:
 
  input name=op type=hidden id=op value=send /
 
  and use:
 
  if (isset($HTTP_GET_VARS['op'])  ($HTTP_GET_VARS['op'] == 'send'))
  {
  send_email();
  }

 Thanks again, Ricardo. I now have the form communicating with the server.

 I think that I might have an error in my script:

 Where I join together the value of the passed variable ($myrow[3]) and
the string
 containing the domain ( $string=@somedomain.com)  I used:

  $to_name=$myrow[3]$string

 If the passed variable's value is, for instance, smith, then does my
$to_name become:

 [EMAIL PROTECTED]

 On hitting the submit button, I see the server being called and data being
sent, but
 nothing is being received. I'm just wondering if I've appended those two
things correctly.

 TIA for your continued assistance.

 Cheers --- Phil

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] PHP and mail forms

2004-01-29 Thread Phil Matt
Hello to all.

I am trying to write a simple (at least I thought it was simple...) Contact Us form 
that 
sends an email when it is submitted.

The $to_name variable was passed from a previous page. I am sure that the variable 
was passed, as I can echo it and it is being passed correctly - thanks to this list!

The problem I am having is this: I cannot quite figure out how an html form handles 
this 
mail function when the to field is filled with an existing variable.

This is what I've got: (I removed all of the table formatting to make it clearer here)

form name=mailer method=post action=? $_SERVER['PHP_SELF']; ?
input name=from_name type=text id=from_name value=?=$from_name?
input name=from_email type=text id=from_email value=?=$from_email?
input name=subject type=text id=subject value=?=$subject? size=60
textarea name=message cols=55 rows=15 
id=message?=$message?/textarea

input name=userid type=hidden id=userid value=?$to_name? /
  input type=submit name=Submit value=mail

So, I think that this sets up the form for processing, AFAIK.

Then, I added the stuff that pulls the email address associated with the id in 
$to_name 
from the MySQL database, and adds the string for the proper domain. I've left out the 
connection stuff for clarity:

$id=$_GET['id'];
$string=@somedomain.com;
$result= mysql_query(SELECT * FROM mydatabase WHERE ID=$id,$db);
while ($myrow = mysql_fetch_row($result)){
$to_name=$myrow[3]$string; } ?

I know that the thing that actually sends mail looks like this:

mail($to_name, $from_name, $subject, $message, From: $from_email\nX-Mailer: PHP/ 
.. phpversion());   

But how do I get this all to happen when the user hits the submit button? Where does 
that mail function (is it a function?)  go? I have read a lot of stuff on the various 
PHP lists 
and sources, but I just cannot figure out this piece of the puzzle.

TIA for your suggestions, and for your patience with my lack of knowledge here.

-- Phil Matt

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php