1.

Solve : Form submission - little thing?

Answer»

Hi guys.. i've made a form and am trying to get it to send it to my email..

I have this as the form:

Code: [Select]<form action="form.php" method="post">

<h3><font color="red">Please fill in this form correctly and honestly to join our community.</font></h3>
<font color="blue">First Name</font>:
<INPUT type="text" name=""
value="" size="40">
<br>
<font color="blue">Login Name</font>:
<input type="text" name=""
value="" size="40">
<br>
<input type="submit" value="send mail">

and in that it refers to a file called "form.php"

which i have made as this:

Code: [Select]<?php
$fname=$_POST['firstname'];/*thislineistextfieldname*/

//Declaratethenecessaryvariables
$mail_to="[emailprotected]";
$mail_from="[emailprotected]";
$mail_sub="FormData";


$mail_mesg=$fname;

//Checkforsuccess/failureofdelivery
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from/r/nReply-to:$mail_from"))
echo"<spanclass='textred'>YourApplicationhasbeensentsuccessfully!Wewillgetbacktoyouwithin24hours.Regards,Psy.</span>";
else
echo"<spanclass='textred'>Failedtosendyourapplication!<br>Thiswaseithercausedby&bull;aninternetfault,inwhichcase,tryagain.or&bull;Wearecarryingoutmaintenancework,inwhichcase,pleasetryagainlater.Thankyou.</span>";



?>

Now when i fill in the form and hit send, it sends an email to my account, which is great.. BUT.. all the email shows is the who it's to, who its from and the name. ie Form Data.

There is no form results sent in the email.. how do i get them there? and why does it not send to a hotmail account but will to a GMAIL account?

This is the email i get:

Code: [Select] Message text garbled?
from @ msn. com/r/nreply-to <myemail> hide details 23:15 (1 hour ago)
reply-to
@ msn. com/r/nreply-to <meemail>,
[emailprotected]
to [emailprotected]
date 26 Nov 2007 23:15
subject Form Data
mailed-by mail.jellybaby.net

ThanksPut this in the third line in form.php: print "$fname";
Does it print out anything?
It doesn't look as if you have the body specified (e.g. body of e-mail being sent). Unfortunately I'm not that familiar with PHP (I'm a Perl guy), but I'd assume it would need some type of body message section.

Try reviewing this page and see if it helps.

http://email.about.com/cs/phpemailtips/qt/et031202.htmQuote

Put this in the third line in form.php: print "$fname";
Does it print out anything?
No lol.

yeah it seems like i need a body i'll try that page thanks.i tried this:

Code: [Select]<?php
$fname=$_POST['firstname'];/*thislineistextfieldname*/
print"$fname";
//Declaratethenecessaryvariables
$mail_to="[emailprotected]";
$mail_from="[emailprotected]";
$mail_sub="FormData";
$body="Hi,\n\nHowareyou?";


$mail_mesg=$fname;

//Checkforsuccess/failureofdelivery
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from"))
echo"<spanclass='textred'>YourApplicationhasbeensentsuccessfully!Wewillgetbacktoyouwithin24hours.Regards,Psy.</span>";
else
echo"<spanclass='textred'>Failedtosendyourapplication!<br>Thiswaseithercausedby&bull;aninternetfault,inwhichcase,tryagain.or&bull;Wearecarryingoutmaintenancework,inwhichcase,pleasetryagainlater.Thankyou.</span>";



?> but it didn't work! it was basically copied from the site lol.. i also tried it with the $body = "Hi,\n\nHow are you?"; replaced as $mail_body ="Hi,\n\nHow are you?" but no lolright if i enter this:

Code: [Select]<?php
$fname=$_POST['Name'];

//Declaratethenecessaryvariables
$mail_to="[emailprotected]";
$mail_from="[emailprotected]";
$mail_sub="Enquiry";
$mail_mesg="hihowareyou";

//Checkforsuccess/failureofdelivery
if(mail($mail_to,$mail_sub,$mail_mesg,"From:$mail_from"))
echo"<spanclass='textred'>YourApplicationhasbeensentsuccessfully!Wewillgetbacktoyouwithin24hours.Regards,Psy.</span>";
else
echo"<spanclass='textred'>Failedtosendyourapplication!<br>Thiswaseithercausedby&bull;aninternetfault,inwhichcase,tryagain.or&bull;Wearecarryingoutmaintenancework,inwhichcase,pleasetryagainlater.Thankyou.</span>";



?> i get the message "Hi, how are you" naturally.. so where it says "mail_mesg=" i need something that will collect the data that was entered into the forms I decided to check out the code on my xampp server and found out the obvious. In your html form, you don't have any names for your text boxes!
Name your text boxes and try it again.nope still blank lolmake sure you're calling the same variable in your php file. If you named your text box "Name", then make sure you call it with $_POST['Name'];
that worked. cheers guys!TWO things:

The proper way to do an IF statement:

if(CONDITION) {

statement here

} else {

other statement

}


Also, using quotes.

Instead of double quotes:
echo " blah blah blah";

use single quotes:

echo 'blah blah blah';

EXCEPT!! when you echo a variable.
If you want to echo a line that has a variable in it, than you use double quotes.

echo "$variable";


Quote from: Astoria on December 12, 2007, 11:38:04 PM
Two things:

The proper way to do an IF statement:

if(condition) {

statement here

} else {

other statement

}


Also, using quotes.

Instead of double quotes:
echo "<span> blah blah blah</span>";

use single quotes:

echo '<span>blah blah blah</span>';

EXCEPT!! when you echo a variable.
If you want to echo a line that has a variable in it, than you use double quotes.

echo "$variable";

Have you ever done any programming at all?
There's several ways to set up an if statement. You don't need the curly brackets for a one line if, else, for, or while, and it doesn't matter how it's formatted. every interpreter and compiler ignores white space anyway.
Quotes don't matter either!
Besides, the original poster already resolved his problem, why'd you bring it back up? Quote from: michaewlewis on December 13, 2007, 01:17:52 PM
Quote from: Astoria on December 12, 2007, 11:38:04 PM
Two things:

The proper way to do an IF statement:

if(condition) {

statement here

} else {

other statement

}


Also, using quotes.

Instead of double quotes:
echo "<span> blah blah blah</span>";

use single quotes:

echo '<span>blah blah blah</span>';

EXCEPT!! when you echo a variable.
If you want to echo a line that has a variable in it, than you use double quotes.

echo "$variable";

Have you ever done any programming at all?
There's several ways to set up an if statement. You don't need the curly brackets for a one line if, else, for, or while, and it doesn't matter how it's formatted. every interpreter and compiler ignores white space anyway.
Quotes don't matter either!
Besides, the original poster already resolved his problem, why'd you bring it back up?

I was trying to help...
It's a bad habit not to do your if/else staements without curly brackets, THAT'S WHY I brought it back up.
And FYI, yes I've done tons of programming, and from what I've seen, quotes have cause ppl's lots of headaches.

And in the scripts that he posted, he didn't resolve my tips.It's a bad habit to think that everyone has to conform to your own coding style.
The guy wasn't trying to make his code look pretty, he was trying to fix his code. Your comments didn't help him solve anything.
Quote from: michaewlewis on December 14, 2007, 10:57:46 AM
It's a bad habit to think that everyone has to conform to your own coding style.
The guy wasn't trying to make his code look pretty, he was trying to fix his code. Your comments didn't help him solve anything.


No, you're wrong. It's a bad habit to code scripts in a way that can lead to many mistakes.
I'm not trying to force my coding on anyone, and his problems were already solved when I made that post.

All I am trying to say is that it's better to be safe than sorry.
But apparently that's not ALLOWED on this forum...at least in your opinion.


Discussion

No Comment Found