PHP page/file for this form?
12-19-2007, 09:41 AM
|
PHP page/file for this form?
|
Posts: 316
|
I have lost my mail.php file.
Would anyone be able to tell me what needs to go into it?
This is the form I am using in my webpage:
HTML Code:
<form action="mail.php" method="post">
<div align="center">
<div align="left"><span >name: </span></div>
<div align="left">
<input name="name" type="text" class="text-box" size="50" maxlength="50">
</div>
<div align="left"><span>email: </span></div>
<div align="left">
<input name="email" type="text" class="text-box" size="50" maxlength="50">
</div>
<div align="left"><span >subject: </span></div>
<div align="left">
<input name="subject" type="text" class="text-box" size="50" maxlength="50">
</div>
<div align="left"><span>message:</span></div>
<div align="left">
<textarea name="text" cols="47" rows="6" class="text-box" id="text" ></textarea>
</div>
<div align="center">
<input name="submit" type="submit" class="button" onClick="MM_validateForm
('name','','R','email','','RisEmail','subject','','R','text','','R');return
document.MM_returnValue" value="send">
<input name="Reset" type="reset" class="button" value="reset">
</div>
</div>
</form>
Many thanks.
|
|
|
|
12-19-2007, 04:05 PM
|
Re: PHP page/file for this form?
|
Posts: 322
|
Well you can have all sorts of stuff in there depending on what exactly you want. Heres one example:
PHP Code:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$_POST['name']. " <". $_POST['email'].">\r\n";
if(@mail("admin@randomsite.com","RandomSite-UserSubmit: ".$_POST['title'], $message,$headers))
{
echo('<p>Your email has been sucessfully submitted! Thank you for contacting us.</p>');
} else {
echo('<p>Your email unfortunately could not be send. Please try again in a little bit.</p>');
}
The first 2 headers just leave there for information for the email program thats receiving it. The third header contains subject information, so in this case its being sent to the administrator of the site and its going to say "RandomSite-" and then have whatever the subject is that the user entered. In this script I have $message declared higher up because its loaded with html and stuff and I wanted to keep it pretty but you can do that however you want. And finally it just tells the users that the email was sent or returns an error if it wasnt sent.
Its important to note that it will return the message that the email has been sent even if no one receives the email, it just means that the server sent the email, not that it was received.
Hope that helps!
|
|
|
|
01-15-2008, 09:10 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
Thanks.
Its working now.
|
|
|
|
01-22-2008, 10:52 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
I want to add another field to my form but its not working out for me.
I want another text box called 'telephone' for them to enter their number.
I've added it to the top bit but where I try to put it further down it message up the email I receive.
Ideally I would like it to be the first line of the email.
PHP Code:
<?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes($subject); $telephone = stripslashes($telephone); $text = stripslashes($text);
$text .= "\n\nIP Address: " . $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $text .= " or Proxy Reports: " . $_SERVER['HTTP_X_FORWARDED_FOR'];} $text .= "\n\nUser Agent: " . stripslashes($_SERVER['HTTP_USER_AGENT']); mail('X@gmail.com',$subject,$text,"From: $name <$email>"); header("location:mailsent.htm");?>
Thanks.
Last edited by Joe3000; 01-22-2008 at 11:13 AM..
|
|
|
|
01-22-2008, 11:00 AM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
PHP Code:
<?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes($subject); $telephone = stripslashes($telephone); $text = $telephone; $text .= stripslashes($text); $text .= "\n\nIP Address: " . $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $text .= " or Proxy Reports: " . $_SERVER['HTTP_X_FORWARDED_FOR'];} $text .= "\n\nUser Agent: " . stripslashes($_SERVER['HTTP_USER_AGENT']); mail('EMAIL_TO@SENDTO.com',$subject,$text,"From: $name <$email>"); header("location:mailsent.htm");?>
that should do it.
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
Last edited by dansgalaxy; 01-22-2008 at 11:37 AM..
|
|
|
|
01-22-2008, 11:13 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
Thanks.
Worked a treat.
Can you edit my email out of your reply just incase a spam monster eats it?
Cheers
|
|
|
|
01-22-2008, 11:22 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
Actually, its repeating the telephone number twice and not including the text box message.
Any ideas?
Last edited by Joe3000; 01-22-2008 at 11:23 AM..
|
|
|
|
01-22-2008, 11:39 AM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
can u post the email it generates? (without personal info obviously)
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
01-22-2008, 11:52 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
0207 318 45770207 318 4577
IP Address: xxxxxx
|
|
|
|
01-22-2008, 12:15 PM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
can you try commenting out the mail() function and just add echo $telephone
so we can see what part is making it show twice 
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
01-24-2008, 04:53 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
I'm not sure how to do that.
I did this:
PHP Code:
<?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes(Reflexology); $telephone = stripslashes($telephone); $text = $telephone; $text .= stripslashes($text); $text .= "\n\nIP Address: " . $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $text .= " or Proxy Reports: " . $_SERVER['HTTP_X_FORWARDED_FOR'];} $text .= "\n\nUser Agent: " . stripslashes($_SERVER['HTTP_USER_AGENT']); //mail('x@gmail.com',echo $telephone,$subject,$text,"From: $name <$email>"); header("location:mailsent.htm");?>
and it still displayed the phone number twice.
|
|
|
|
01-24-2008, 12:07 PM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
try this:
<SPAN style="COLOR: #000000">
PHP Code:
<?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes(Reflexology); $telephone = stripslashes($telephone); echo $telephone; /*$text = $telephone; $text .= stripslashes($text); $text .= "\n\nIP Address: " . $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $text .= " or Proxy Reports: " . $_SERVER['HTTP_X_FORWARDED_FOR'];} $text .= "\n\nUser Agent: " . stripslashes($_SERVER['HTTP_USER_AGENT']); mail('x@gmail.com',echo $telephone,$subject,$text,"From: $name <$email>"); header("location:mailsent.htm");*/ ?>
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
01-24-2008, 12:12 PM
|
Re: PHP page/file for this form?
|
Posts: 316
|
Thanks.
I filled in all the fields, in telephone I entered 07932 123456 and it returned this:
07932 12345607932 123456
|
|
|
|
01-24-2008, 01:33 PM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
can i see the form?
and full scripts?
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
01-25-2008, 06:47 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
mail.php:
PHP Code:
<?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes(Reflexology); $telephone = stripslashes($telephone); echo $telephone; /*$text = $telephone; $text .= stripslashes($text); $text .= "\n\nIP Address: " . $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $text .= " or Proxy Reports: " . $_SERVER['HTTP_X_FORWARDED_FOR'];} $text .= "\n\nUser Agent: " . stripslashes($_SERVER['HTTP_USER_AGENT']); mail('x@gmail.com',echo $telephone,$subject,$text,"From: $name <$email>"); header("location:mailsent.htm");*/ ?>
HTML Code:
<form action="mail.php" method="post">
<div align="center">
<div align="left"><span >Your name: </span></div>
<div align="left">
<input name="name" type="text" class="text-box" size="47%" maxlength="50">
</div>
<div align="left"><span>Your e-mail address: </span></div>
<div align="left">
<input name="email" type="text" class="text-box" size="47%" maxlength="50">
</div>
<div align="left"><span >Your telephone number: </span></div>
<div align="left">
<input name="telephone" type="text" class="text-box" size="47%" maxlength="50">
</div>
<div align="left"><span>Your message:</span></div>
<div align="left">
<textarea name="text" cols="35%" rows="6" class="text-box" id="text" ></textarea>
</div>
<div align="left">
<input name="submit" type="submit" class="button" onClick="MM_validateForm('name','','R','email','','RisEmail','subject','','R','text','','R');return document.MM_returnValue" value="send">
<input name="Reset" type="reset" class="button" value="reset">
</div>
</div>
</form>
|
|
|
|
01-25-2008, 11:29 AM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
the only think i can think of is the javascript validation maybe or the extract function? :s
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
01-25-2008, 11:41 AM
|
Re: PHP page/file for this form?
|
Posts: 316
|
Right, I've taken the js validation off and done the echo and when entering '0799898' in the telephone number box '0799898' is displayed on a blank page.
|
|
|
|
01-25-2008, 02:56 PM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
So this has stopped doubling it?
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
01-25-2008, 04:10 PM
|
Re: PHP page/file for this form?
|
Posts: 316
|
Only on the echo on a blank page, not in the email.
|
|
|
|
01-26-2008, 12:50 PM
|
Re: PHP page/file for this form?
|
Posts: 6,521
Name: Dan
Location: Swindon
|
okay without the JS validation try this code:
PHP Code:
<?php @extract($_POST); $name = stripslashes($name); $email = stripslashes($email); $subject = stripslashes(Reflexology); $telephone = stripslashes($telephone);
$text = $telephone; $text .= stripslashes($text); $text .= "\n\n IP Address: " . $_SERVER['REMOTE_ADDR']; if ($_SERVER['HTTP_X_FORWARDED_FOR']) { $text .= " or Proxy Reports: " . $_SERVER['HTTP_X_FORWARDED_FOR']; } $text .= "\n\nUser Agent: " . stripslashes($_SERVER['HTTP_USER_AGENT']); mail('x@gmail.com',echo $telephone,$subject,$text,"From: $name <$email>"); header("location:mailsent.htm"); ?>
</SPAN>
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
|
|
|
|
|
« Reply to PHP page/file for this form?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|