[HELP] html +php form .echo ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
timothy XP
Forum Newbie
Posts: 2
Joined: Wed Aug 24, 2005 2:11 am

[HELP] html +php form .echo ?

Post 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
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

Post by AnarKy »

for #2,
use print() or printf()
echo just echo's everything
lostinphp
Forum Commoner
Posts: 44
Joined: Wed Jul 27, 2005 5:10 am
Location: Paris,France.

Post by lostinphp »

im not pro too...
but a simple solution wud be to try using <br> instead of /n for line break. mite work
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

Post 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.
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

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

Post by AnarKy »

Perhaps post your code, so we can have a look at it?
timothy XP
Forum Newbie
Posts: 2
Joined: Wed Aug 24, 2005 2:11 am

Post 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 .
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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().
Post Reply