
October 27th, 2005
09:23 PM
i do my crosswords in pen
Status: Offline!
Sending email from same page
I know how to use a form to send email, but I was wondering - How do I use one page for everything? I know it might have something to do with the isset function, but I'm really not sure where to start.
Any help would be greatly appreciated. 

October 27th, 2005
09:34 PM
Flying by the Seat of my Pants.
Status: Offline!
<?php
if(isset($_POST['to']))
{
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = $_POST['headers'];
mail($to, $subject, $message, $headers);
}
?>
Just change the isset() variable to a form name that you are posting and that shoudl work.
___________________
J
Last edited by jamiem, October 27th, 2005 09:34 PM (Edited 1 times)

October 27th, 2005
09:49 PM
i do my crosswords in pen
Status: Offline!
So if this is my HTML:
<form action="send.php" method="post">
<label for="textinput">Name:</label>
<br />
<input type="text" id="textinput" name="name" class="textinput" maxlength="25" />
<br />
<label for="passwordinput">Email</label>
<br />
<input type="text" id="passwordinput" name="email" class="textinput" maxlength="25" />
<br />
<br />
<label for="textareainput">Message:</label>
<br />
<textarea id="textareainput" name="message" class="textarea"></textarea>
<br />
<br />
<input type="submit" value="Submit" class="buttonSubmit" />
</form>
then I would change the isset() variable to 'submit', correct?
Last edited by bleedwithme, October 27th, 2005 10:23 PM (Edited 1 times)

October 27th, 2005
10:46 PM
Neverside Newbie
Status: Offline!
What I like to do is:
<?php
if (count($_POST)>0){
// do error checking and stuff, etc. If no errors, success page; else tell user the errors.
}
?>
I like to do really work through possible errors and hacks. From a user point of view, have a look at http://www.kgx.net.nz/contact.php and my work website http://www.kerrick.co.nz/contact.php (still improving this site).

October 28th, 2005
03:53 AM
thinking of something witty to put here
Status: Offline!
I do basically the same thing as kgx, but I think it is a bit more intuitive to do this:
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
}
?>

October 28th, 2005
10:39 AM
Apathy is bliss.
Status: Offline!
There's always:
<?php
if( !empty( $_POST ) ) {
//do process stuff here
}
?>
___________________
"At least I shall die as I have lived, completely surrounded by morons."

October 28th, 2005
12:50 PM
Lost in Berkeley, CA
Status: Offline!
out of topic but hilarious avatar kgx
___________________
There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.

October 28th, 2005
02:30 PM
Neverside Newbie
Status: Offline!

October 28th, 2005
07:06 PM
i do my crosswords in pen
Status: Offline!
Animated avatars aren't allowed. 

October 29th, 2005
02:18 AM
thinking of something witty to put here
Status: Offline!
Originally posted by illEATurHARTout:
Animated avatars aren't allowed. 
He's right. Please change your avatar to something that is not animated.
Last edited by Rad, October 29th, 2005 02:19 AM (Edited 1 times)