/    Sign up×
Community /Pin to ProfileBookmark

Forms Headache

Hi,

I hope someone can help or lead me in the right direction. I have like 6 Forms that need to process, each with different field names. Now, I’m looking to use a general script that will take fields and send them vial E-mail to correct e-mail addess. Example: Newsletter form with different fields, and now I would like a newsletter.php to process the data and send via e-mail:

[code=php]<?php
$Contact_FirstName = $_POST[‘Contact_FirstName’] ;
$Contact_LastName = $_POST[‘Contact_LastName’] ;
$Contact_MiddleInitial = $_POST[‘Contact_MiddleInitial’] ;
$Contact_StreetAddress = $_POST[‘Contact_StreetAddress’] ;
$Contact_Address2 = $_POST[‘Contact_Address2’] ;
$Contact_City = $_POST[‘Contact_City’] ;
$Contact_State = $_POST[‘Contact_State’] ;
$Contact_ZipCode = $_POST[‘Contact_ZipCode’] ;
$Contact_Country = $_POST[‘Contact_Country’] ;
$Contact_HomePhone = $_POST[‘Contact_HomePhone’] ;
$Contact_Email = $_POST[‘Contact_Email’] ;
$Receive_By_US_Mail = $_POST[‘Receive_By_US_Mail’] ;
$Receive_By_Email = $_POST[‘Receive_By_Email’] ;
$msg=”Your name: ” . $_POST[‘Contact_FirstName’] . “n”;
$msg=”Your email: ” . $_POST[‘Contact_Email’]. “n”;
$headers=”From: ” . $_POST[‘Contact_Email’];
mail(“[email protected]”, “Newsletter Sign In”,$msg, $headers);
?> [/code]

After I press the submit button, and I go to the destination e-mail nothing has arrived. Also, I’m doing this for site, and I’m working on it through a dedicated IP Address, since the domain name has been pointed yet to the hosting server…..I’ve also looking to add a re-direct code to take me to another page. I understand that one can use the mailto: in the form action, but this can be dangerous for spam……I would like to use the hard and secure method…..Thanks and God Bless…..

God Love U
[url]www.endtimestube.com[/url]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@SyCoNov 20.2008 — You've rewritten a load of POST variables in non POST variables for no reason, then done nothing with them and you've overwritten $msg var rather than .= concatenated to it.

Try to debug methodically.

First test mail is configured on you server by putting only this in a PHP script and running it.
[code=php]<?php
mail("[email protected]", "testing","message test");
?>[/code]

Then if that works you know mail is set up correctly if not contact your host.

Don't do this for no reason. Only rename a variable if you change or process it in some way. You'll need to know where the values came from.
[code=php]$Contact_FirstName = $_POST['Contact_FirstName'] ; [/code]

concatenate like this (notice the .= )
[code=php] $msg="Your name: " . $_POST['Contact_FirstName'] . "n";
$msg.="Your email: " . $_POST['Contact_Email']. "n";[/code]
Copy linkTweet thisAlerts:
@luke2125authorNov 21.2008 — Hi there,

Thanks for the response, I'm sorry but I'm confused, all of those variables come from the HTML Form, I'm trying to get those values from the html form (ex: Contact_First Name is the first value in the form) and display them in an E-mail......? Thanks and God Bless....

God Loves U

www.endtimestube.com
Copy linkTweet thisAlerts:
@SyCoNov 21.2008 — You've come here asking for help and I posted a few suggestions to try. I can't magically fix you problem. Your simple script has a lot of things wrong but i gave you the first things to try . You've not said whether they worked, so how am I or anyone to know what is happening. There not much I can say with out repeating my last post but anyway.

This doesn't do anything.

[code=php]$Contact_FirstName = $_POST['Contact_FirstName'] ; [/code]
$_POST['Contact_FirstName'] is a variable like any other it doesn't need to be renamed you can use it like any array value.

[code=php]
$foo='hello';//writes value hello to $foo
$foo=' and goodbye';//overwrites value 'and goodbye' to $foo
echo $foo;

//will only echo 'and goodbye'
[/code]


[code=php]
$foo='hello';//writes value hello to $foo
$foo.=' and goodbye';// .= adds (concatenates) to $foo value 'and goodbye'
echo $foo;

//will echo 'hello and goodbye'
[/code]


So

start a variable
[code=php]$msg='';[/code]
and concatenate to it.
[code=php]
$msg.="Your name: " . $_POST['Contact_FirstName'] . "n"; //notice the dot equals .=
$msg.="Your email: " . $_POST['Contact_Email']. "n";[/code]


All the other variables like this one $_POST['Contact_MiddleInitial'] ; also need to be included in the same way or they wont be in the message variable and so wont be in the email.

Programming is like building a machine, you have to be methodical.

Maybe you have another error somewhere? Maybe mail() isn't configured correctly. Google how to turn up error reporting to E_ALL with an ini flag setini() or search this forum it's posted a million times.

If you actually try the suggestions and post the results you can expect more help.

I suppose you could try praying to make it work. ?
Copy linkTweet thisAlerts:
@luke2125authorNov 21.2008 — Hi,

Thanks for the thorough explanation, I appreciated it.....Well, I don't pray for mathematical equations, afterall E=MC2 is not going to get me into heaven, but the Alpha and Omega will.....Or in other words, Jesus Christ, Yeshua!!!! ?

Thanks and God Bless....

God Loves U

www.endtimestube.com
Copy linkTweet thisAlerts:
@AvenueNov 21.2008 — Wow, as a PHP newbie I have to say that I learned a lot from this thread.

Thanks!!
×

Success!

Help @luke2125 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...