PlayBuddy
December 25, 2024, 10:52:30 PM

This week's Club Pogo challenges!
Phlinx II : Match 600 green stones this week! [Download Cheat]
Tri-Peaks Solitaire HD : Clear 75 peaks this week! [Download Cheat]
Sweet Tooth Town : Create 80 Sugar Swirls this week! [Download Cheat]

Main Menu

Re:PHP Formmail script

Started by JeffCoKid,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fatkid

OK I finally found my PHP script for mail...  ;D

Here it is...

<?
 
  $message= "";

  //steps through each field past through the post headers and compile them into a message string.
  for(reset($HTTP_POST_VARS); list($name, $value) = each($HTTP_POST_VARS);)
  {
      $message .= $name.": ".$value."\r\n";  // the "." concatanates strings together.
  }

  //send out the email.  PARAM1=Send email to.  PARAM2=Subject. PARAM3=Email body message. PARAM4=email headers (In this case specifying what it should do if someone attempts to reply to the email-it just sends it right back to apply@nfmprovo.com)   
  mail("anymail@anymail.com", "Subject goes here", $message, "From: applicant \r\nReply-To: anymail@anymail.com\r\n");

  //This is where you want to redirect to after the form has been submitted...
  header("Location: /index.html");
 
?>

fatkid

#21
I know the comments are a bit messy but I just wrote them out really quick for a buddy of mine...

Here's a breakdown of the code...

First line it clears out the $message value

Next it goes through your form and finds each header under name and value... Looking at your code you don't seem to have any inputed values, just names...  So you can either delete out the part of the php code for value or you may want to add value headers into your form...

What will happen is the code will grab the name header and call it what you have titled it... Color1, Color2, etc etc... Then if you have a value header, that is what the user inputs... Green, Blue, Red, etc etc...

Ok so back to the code... It goes through every place in the form that it finds a name or value header and records what they point to... It then concatanates them into a string and enters to a new line saving the string to $message... So in your email it will look something like this...

Color1 Green
Color2 Blue
Color3 Red

Next it moves onto the mail() code... As it says in the comments it goes:
mail("param1","param2",param3 (which is $message), param4 (who its from \r\n and who to reply to..

Then finally you have
header("Location: anyurl.com");
This is where the page goes after the submit button is hit...

JeffCoKid

#22
Yawwwnn... I would have gotten back to you sooner on this but I was napping.


Thanks a lot fatkid! I will take a look into this this evening. I will be away for a few hours... gotta go back to school tonight as its a work night for FBLA... and we reallllllly need to get our site going as it is due on the 28th lol and we have the basic design. (the design on jeffcokid.com is what we are using just for saving time... but when we go to nationals it will probably change.)

How would I insert input values into my form?

fatkid

<tr>
<td width="150" nowrap>Font Color One</td>
<td width="150">
<input type="text" name="Color1" value="" size="5" maxlength="6">
</tr>

Easy as pie.. Then whatever the use inputs into the text field will be record as the value of Color1

JeffCoKid

I figured it would be the value tag


Thanks again. I will hopefully get this working this evening.

Have a good one fatkid. I really appreciate all this.  ;D

ImRicherThanUAll

sry lol im not a real genius with computers but i did go to collage for csomthing lol... i forgot what it was tho lol

fatkid

you mean you went to college?

col·lage (k-läzh, k-)
n.
An artistic composition of materials and objects pasted over a surface, often with unifying lines and color.

http://dictionary.reference.com/search?q=collage

College is an institute for higher learning... ;-)  Guess you just partied those years right through... lol  ;D

DJ



ImRicherThanUAll

Those were the days but im confused how did i pull of a 3.6 all the way through lmao ;D ;D

JeffCoKid

ok, home for the evening.... no, havent been to college yet as I am a Junior in HS.

ImRicherThanUAll


JeffCoKid

Okay so I am a complete dumbass... I cannot get this script to work for the life of me. I just ran through my form and put in values (value="") and left it blank like that. Go ahead and laugh lol... I am just not any good at this crap.

- Jeff

JeffCoKid

Wait wait.... I am receiving the email with the correct information. I figured that one out. GENUIS!!!

lmao...

But now... the redirection... that's the problem.

JeffCoKid

Here is the code I am currently using....
_______________________________________

<?
 
 $message= "";

 //steps through each field past through the post headers and compile them into a message string.
 for(reset($HTTP_POST_VARS); list($name, $value) = each($HTTP_POST_VARS);)
 {
     $message .= $name.": ".$value."\r\n";  // the "." concatanates strings together.
 }

 //send out the email.  PARAM1=Send email to.  PARAM2=Subject. PARAM3=Email body message. PARAM4=email headers (In this case specifying what it should do if someone attempts to reply to the email-it just sends it right back to jeffcokid@bresnan.net)  
 mail("jeffcokid@bresnan.net", "Quill Signature Order", $message, "From: applicant \r\nReply-To: jeffcokid@bresnan.net\r\n");

 //This is where you want to redirect to after the form has been submitted...
 header("Location: http://www.jeffcokid.com/quillpay.htm");
 
?>

fatkid

<?php
header("Location: http://www.example.com/");
?>

Try adding the php tag to the <? ... From what I've looked at online it seems that, that is the only thing that is different from that script to the PHP manual...

fatkid

Or you can just comment out the header call and instead after the PHP ?> Start writing your HTML that you want displayed... It will also work that way...

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

 Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:

Shortcuts: ALT+S post or ALT+P preview