Page 1 of 1

[HELP] html +php form .echo ?

Posted: Wed Aug 24, 2005 2:27 am
by timothy XP
Hello , i am new here .
I am not a php guru but i am working on a simple html form that collects some data and then sends it to my e-mail . i have this part working ok . i do have a few problems .<
<problems list >
#1
1 when the data is sent to my mail it looks like so
( answers to questions )
yes&
100.00&
then the message here&
the " &" is after each answer ,how can i fix this .?

#2
after i have the data sent to me . i have echo to print on a new page .

Code: Select all

echo "Thank you for taking the survey\n";
echo "<a href=\"http://www.somesite.com/index.htm\">Back to main page</a>";
the problem is with this code ( echo ) is that there isnt a line break after "thanks for taking the survey" and then the link back to the site . how can i make a liine break even though you see i have \n in the code .

also does anyone have a link to help me with posting the form results on a new page ..
something like this
would you buy it ?
20% yes
80% no

i dont have a database so is it possible to display results without a database .?

cheers

Posted: Wed Aug 24, 2005 2:39 am
by AnarKy
for #2,
use print() or printf()
echo just echo's everything

Posted: Wed Aug 24, 2005 2:41 am
by lostinphp
im not pro too...
but a simple solution wud be to try using <br> instead of /n for line break. mite work

Posted: Wed Aug 24, 2005 2:46 am
by AnarKy
lostinphp wrote:im not pro too...
but a simple solution wud be to try using <br> instead of /n for line break. mite work
This would be a problem if displaying in a text box or in the email,
if HTML is not supported, or in a text file, etc.

Perhaps post your code, so we can have a look at it?

Posted: Wed Aug 24, 2005 2:48 am
by AnarKy
Perhaps post your code, so we can have a look at it?

Posted: Wed Aug 24, 2005 2:55 am
by timothy XP

Code: Select all

<?php
$to = "mail@newTophp.net";
$email = $email;
$subject = "$Survey";
$chat = "$chat&\n$price&\n$features&\n$textarea";
$header = "From: " . $HTTP_POST_VARS['email'] . " <" . $HTTP_POST_VARS['email'] . ">\n";
mail($to,$subject,$chat,$header);
print ("Thank you for taking the survey\n;<a href=\"http://www.somesite.com/index.htm\">Back to site</a>");

?>
also i have found that if i take away "&" then it doesnt post to my mail at all ..

as i said this may not even be the way about it ... but hey i managed to make it work .. so impleased about that ..
i newb ,,plz take it easy on me ..
tahnks guy s for the posts ..
.......................edit...............
i managed to get rid of the & in the emails i was reciving .. it wouldnt work before but when you add a line break and take away & then it works nicely .. but still no joy with having a line break in the print() part of the code ..
its still just 1 line ..
any suggestions .

Posted: Wed Aug 24, 2005 3:39 am
by AnarKy
I’m not sure what the & or \n problem is.
Could be that you may need to use \r\n instead of just \n

Not part of the problem, but you may wan to use
wordwrap() to make the actual mail look a bit nicer.

Posted: Wed Aug 24, 2005 7:24 am
by feyd

Code: Select all

$chat = "$chat&\n$price&\n$features&\n$textarea";
remove the &'s ;)

in your print, change \n to \n<br> or similar. Alternately, you could run nl2br().