Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,000 members, 7,817,961 topics. Date: Sunday, 05 May 2024 at 12:03 AM

Pls Help Resolve This Codes Issue - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Pls Help Resolve This Codes Issue (1249 Views)

Webmasters Help Resolve This. / Complete Tutorials On Designing A Wapka.m0bi Site.(codes/scripts Etc) / Easyphp (swamp Server) Refuses To Start Pls Help Me Resolve This (2) (3) (4)

(1) (Reply) (Go Down)

Pls Help Resolve This Codes Issue by switchmax8: 12:56pm On Jul 15, 2009
HELLO FELLAS,
FIND BELOW THIS CODES I AM TRYING TO USE IT FOR A CONTACT PAGE BUT,WHENEVER SOMEONE SEND ME EMAIL THE RESULT ALWAYS COMES OUT IN STRAIGHT LINE INSTEAD OF EACH DETAILS TO BREAK INTO DIFFERENT STAGES.I WANT TO KNOW THE FAULT OR ADDITIONAL INFO THAT WILL BE ADDED TO MAKE IT WORK.I WILL REALLY APPRECIATE URGENT RESPONSE TO MY EMAIL wealthyemah@yahoo.com

<?php
if($_POST['name']==""wink{
print "You cannot leave the Name empty";
exit();
}
if($_POST['arrival']==""wink{
print "You cannot leave the Arrival empty";
exit();
}
if($_POST['apartment']==""wink{
print "You cannot leave the Apartment date empty";
exit();
}
else{
$message=
"Full Name:".$_POST['name']. "Arrival Date:".$_POST['arrival']. "Departure Date:".$_POST['departure']. "Country:".$_POST['country']. "Email Address:".$_POST['Email']. "Phone Number:".$_POST['phone']. "Apartment Name:".$_POST['apartment']. "Your Message:".$_POST['Message'];
$to = "admin@mayfairapartmentrentals.com\r\n";
$subject = "contact form\r\n";
$from = "Apartment Rentals\r\n";
$headers = "From: $from\r\n";
mail($to,$subject,$message,$headers);
print "<h3>Thanks,You will be contacted soon<h3>";
}
?>
Re: Pls Help Resolve This Codes Issue by kolitos007: 2:41pm On Jul 15, 2009
Ok why don't you just put "\r\n" that is your line break, cus you using plain txt.
Re: Pls Help Resolve This Codes Issue by yawatide(f): 3:02pm On Jul 15, 2009
Expanding on kolitos' suggestion:

if($_POST['apartment']==""wink{
print "You cannot leave the Apartment date empty[b]\r\n[/b]";
exit();
}

OR

if($_POST['apartment']==""wink{
print "You cannot leave the Apartment date empty[b]
[/b]";
exit();
}

OR
With #1 being preferred.  As always with my code examples, please verify for yourself that it contains no run-time errors.

Good luck!
Re: Pls Help Resolve This Codes Issue by quadrillio(m): 3:40pm On Jul 15, 2009
Warning - while you were reading 2 new replies have been posted. You may wish to review your post.


that was what I got wen I tried to solve it,

any way jus replace your \n wit


I believe u can do that.
Re: Pls Help Resolve This Codes Issue by kolitos007: 3:43pm On Jul 15, 2009
Good point yawa-ti-de, but I don't think its a good idea to use "<br>" as this mail($to,$subject,$message,$headers); Always defaults as plain text so "
" will just show as a html tag, wont' be converted
Re: Pls Help Resolve This Codes Issue by yawatide(f): 4:29pm On Jul 15, 2009
kolitos, one thing I like about myself is that I always allow myself some wiggle room in whatever I do in life wink

Observe again, my first post:


With #1 being preferred. As always with my code examples, please verify for yourself that it contains no run-time errors.

So in essence, assuming the poster was so stubborn as to go with #2, he would see the html for which I can't be held to blame as I issued a warning about the poster verifying that my code is correct (I am posting from work, a jsp environment, so I can't test my php code and what I write half the time is from my head).

Yes, For the errors part, the BR tags are fine. For the sending email part, the BR tags aren't.

Thanks
Re: Pls Help Resolve This Codes Issue by kolitos007: 4:37pm On Jul 15, 2009
sorry was not referring to you was referring to quadrillio
Re: Pls Help Resolve This Codes Issue by yawatide(f): 6:28pm On Jul 15, 2009
My bad kolitos, for assuming it was me. Next time, for ppl like me who aren't that sharp, please put down the name of the person you are referring to, so as to avoid collateral damage tongue
Re: Pls Help Resolve This Codes Issue by switchmax8: 7:03pm On Jul 15, 2009
Thanks yawatide and co but,you people have not really give me an idea to what am trying to resolve.Once again i said when someone fill in the contact form instead of the details to come out in stages like.
Full names.kola yawatide
address:45 adekola strret,
country:nigeria
sex:male
but it will come out in a straight line like this Full names.kola yawatide address:45 adekola strret,country:nigeria sex:male the whole details will be muddle up i hope you guys get me right now.Kindly look at the codes and tell me what is wrong with it.


else{
$message=
"Full Name:".$_POST['name']. "Arrival Date:".$_POST['arrival']. "Departure Date:".$_POST['departure']. "Country:".$_POST['country']. "Email Address:".$_POST['Email']. "Phone Number:".$_POST['phone']. "Apartment Name:".$_POST['apartment']. "Your Message:".$_POST['Message'];
$to = "admin@mayfairapartmentrentals.com\r\n";
$subject = "contact form\r\n";
$from = "Apartment Rentals\r\n";
$headers = "From: $from\r\n";
mail($to,$subject,$message,$headers);
print "<h3>Thanks,You will be contacted soon<h3>";
}
?>
Re: Pls Help Resolve This Codes Issue by yawatide(f): 7:49pm On Jul 15, 2009
au contraire mon frere, we did, albeit not in the way u wanted it to appear

"Full Name:".$_POST['name']."\r\n". "Arrival Date:".$_POST['arrival']. "Departure Date:".$_POST['departure'].

By the way, if I were you, I would:
1) Think about assigning your POSTs to vars for readability
2) use REQUEST, as opposed to POST for "hackability" reasons.

Make sense?
Re: Pls Help Resolve This Codes Issue by nitation(m): 8:15pm On Jul 15, 2009
@ Poster,

I have decided to watch the out come of this thread! But my question is this; How do you expect a new line arrangement when you're concatenating the vars[] in a single line. I mean, it shows you have downloaded this script or you skimmed the book/online article you were reading about PHP.

If not, try this:

$msg .=  "<strong>FullName:</strong> &nbsp;&nbsp;\t$_POST['name']\n";


I know Kolitos will still slap my post about "<strong></strong>" and &nbsp;&nbsp; with reference to his earlier post that and I quote:

Good point yawa-ti-de, but I don't think its a good idea to use "<br>" as this mail($to,$subject,$message,$headers); Always defaults as plain text so "
" will just show as a html tag, wont' be converted



This will solve it

$headers .= "MIME-Version: 1.0\n";

Note that I used .= after $headers as it concatenates the $header variables

Run back if error persist.

- nitation
Re: Pls Help Resolve This Codes Issue by switchmax8: 9:31pm On Jul 15, 2009
Yawatide thanks one million times i really appreciate with the little info you gave me i was able to sit and solve the solution you got what i asked for though the info you supplied gave me insight on what to do.
Oneluv
Re: Pls Help Resolve This Codes Issue by nitation(m): 9:33pm On Jul 15, 2009
Good to know that you have it right.

- nitation
Re: Pls Help Resolve This Codes Issue by yawatide(f): 9:39pm On Jul 15, 2009
no problem. By the way, most answers aren't necessarily meant to answer your questions directly but to make you go back and think and, as in your case, rethink the problem and work a solution on your own. This makes the solution yours and most likely, you will never forget it. That is why I seldom post code and prefer to use english.

It certainly beats copy and paste wink
Re: Pls Help Resolve This Codes Issue by nitation(m): 10:18pm On Jul 15, 2009
true talk @ Yawa

- nitation
Re: Pls Help Resolve This Codes Issue by Nobody: 6:45am On Jul 16, 2009
Interesting. At times like this, i prefer to just read 'cos the solution has been posted already.
Re: Pls Help Resolve This Codes Issue by kolitos007: 7:06am On Jul 16, 2009
yawa-ti-de:

au contraire mon frere, we did, albeit not in the way u wanted it to appear

By the way, if I were you, I would:
1) Think about assigning your POSTs to vars for readability
2) use REQUEST, as opposed to POST for "hackability" reasons.

Make sense?

@yawa-ti-de perfect solution, simple and easy to understand well done.
Re: Pls Help Resolve This Codes Issue by lojik(m): 10:04pm On Jul 16, 2009
U've gotten more than enuf solution but just wanna add some points.

if($_POST['name']==""wink could also be written as if(empty($_POST['name'])) or if(!isset($_POST['name']))

you might like to read up "isset()" and "empty()" as you might need them someday when your codes gets kinda complex.

(1) (Reply)

Chat Script And Smf Collapsing / This Is Why You Don't Buy Templates / Pls Help... Google Adsense Reject My Application

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 36
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.