Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP page/file for this form?
Old 12-19-2007, 09:41 AM PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
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.
Joe3000 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-19-2007, 04:05 PM Re: PHP page/file for this form?
Truly's Avatar
Ultra Talker

Posts: 322
Trades: 0
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!
Truly is offline
Reply With Quote
View Public Profile
 
Old 01-15-2008, 09:10 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
Thanks.

Its working now.
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-22-2008, 10:52 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
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..
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-22-2008, 11:00 AM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE

Last edited by dansgalaxy; 01-22-2008 at 11:37 AM..
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-22-2008, 11:13 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
Thanks.

Worked a treat.

Can you edit my email out of your reply just incase a spam monster eats it?

Cheers
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-22-2008, 11:22 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
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..
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-22-2008, 11:39 AM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
can u post the email it generates? (without personal info obviously)
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-22-2008, 11:52 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
0207 318 45770207 318 4577

IP Address: xxxxxx
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-22-2008, 12:15 PM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-24-2008, 04:53 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
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.
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-24-2008, 12:07 PM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-24-2008, 12:12 PM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
Thanks.

I filled in all the fields, in telephone I entered 07932 123456 and it returned this:

07932 12345607932 123456
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-24-2008, 01:33 PM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
can i see the form?

and full scripts?
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-25-2008, 06:47 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
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>
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-25-2008, 11:29 AM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-25-2008, 11:41 AM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
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.
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-25-2008, 02:56 PM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
So this has stopped doubling it?
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 01-25-2008, 04:10 PM Re: PHP page/file for this form?
Ultra Talker

Posts: 316
Trades: 0
Only on the echo on a blank page, not in the email.
Joe3000 is offline
Reply With Quote
View Public Profile
 
Old 01-26-2008, 12:50 PM Re: PHP page/file for this form?
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
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 <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to PHP page/file for this form?

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 4.39914 seconds with 12 queries