View Full Version : Forms!!
sjc_unique
09-09-2002, 08:01 PM
ok, fairly new to php.
i have on my site a form for a mailing list.
<form action="mailto:mailinglist...@......co.uk" method="post" enctype="text/plain">
however, this means that their email client has to open up to send the info, and as most people use hotmail accounts this isnt all very useful.
i was wondering if there is a way of me recieving the information from a form without using this "action", and also without MySQL.
Thanks
SJC
_____________________
Just launched Contraban Site (http://www.mediresponse.co.uk/Contraban/index.php) !!!!! And it rocks!!!!
Nightfire
09-09-2002, 08:11 PM
<?
if(!isset($submit)){
?>
<form action="<?=$PHP_SELF?>" method="post">
<input type="text" name="name">
<input type="text" name="phone">
<input type="text" name="email">
<textarea rows="20" cols="20" name="bodytext">
<input type="submit" value="Submit" name="submit">
</form>
<?
}else{
$myemail = "me@mydomain.com";
$subject = "You have a message from $name";
$body = "$name has sent you the following information.
His/her phone number is: $phone
His/her email is: $email
He/she has to say:
$bodytext";
mail($myemail,$subject,$body,"From: $email");
}
?>
sjc_unique
09-09-2002, 09:17 PM
thanks Nightfire. i think i understand the coding, which is very handy for when i use the feature on my next site.
Am currently testing it and waiting for the email of the information i entered. i may post on here later tonight if i havent received it to see what the problem is! lol
Thanks
SJC
_______________________
Just launched Contraban Site (http://www.contraban.co.uk)
sjc_unique
09-09-2002, 09:29 PM
ok, nothing in my inbox as yet. however, when i click submit, the page then goes to my main 'home' page. I am not quite sure where in that code i have told it to do that.
Also once i am taken there (supposedly having given my details), and i hit refresh on the 'home' page, i get a message on the screen saying:
"The page cannot be refreshed without resending the information.
Click Retry to send the informatioin again,
or click Cancel to return to the page you were trying to view"
I sense a problem.....any help/suggestions?
SJC
If the email form is included through a url passed reference - eg index.php?page=email, you'd want to amend the action="" of the form tag to include the query string
<form action="<?=$PHP_SELF.$QUERY_STRING?>
Other than that potential glitch, the rest of nightfire's script should work fine - though you might want to do a bit of validating and submission manipulation before mailing.
sjc_unique
09-09-2002, 10:40 PM
ok, below is the code i have used. and it is now not working, as u can see at: http://www.mediresponse.co.uk/Contraban/index.php?aVar=mailing
<td>
<p>Please enter your Full Name in the first box and your email address in the second box:</p>
<?
if(!isset($submit)){
?>
<form action="<?=$PHP_SELF.$QUERY_STRING?>" method="post">
<input type="text" name="name">
<input type="text" name="email">
<input type="submit" value="Submit" name="submit">
</form>
<?
}else{
$myemail = "webmaster@mediresponse.co.uk";
$subject = "You have a message from $name";
$body = "$name has sent you the following information.
His/her email is: $email";
mail($myemail,$subject,$body,"From: $email");
}
?>
</td>
PLEASE HELP!!
THANKS
SJC
Oops, my mistake
$PHP_SELF.'?'.$QUERY_STRING
with the question mark slung in the middle.
sjc_unique
09-10-2002, 05:01 PM
thanks people. mucho appreciated. appears to be working.
btw, you said i might want to "do a bit of validating and submission manipulation before mailing".
What does that mean??
thanks
SJC
_________________________
Contraban Just Launched!! (http://www.contraban.co.uk)
Nightfire
09-10-2002, 05:10 PM
Just a nice simple one
<?
if(!isset($submit)){
?>
<form action="<?=$PHP_SELF.'?'.$QUERY_STRING?>" method="post">
<input type="text" name="name">
<input type="text" name="phone">
<input type="text" name="email">
<textarea rows="20" cols="20" name="bodytext">
<input type="submit" value="Submit" name="submit">
</form>
<?
}else{
if(!$name){
echo "You must enter your name";
}
elseif(!$phone){
echo "You must enter your phone number";
}
elseif(!$email){
echo "You must enter an email address";
}
elseif(!$bodytext){
echo "You must enter a comment";
}else{
$myemail = "me@mydomain.com";
$subject = "You have a message from $name";
$body = "$name has sent you the following information.
His/her phone number is: $phone
His/her email is: $email
He/she has to say:
$bodytext";
mail($myemail,$subject,$body,"From: $email");
}
}
?>
Might have a few errors in as it's been typed on the fly again
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.