Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,194,016 members, 7,953,034 topics. Date: Thursday, 19 September 2024 at 09:37 AM

My Fellow Webmasters, Help Please !! - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / My Fellow Webmasters, Help Please !! (729 Views)

Fellow Webmasters Please Review This Website... / Good Day My Fellow Webmasters Come In If You Have Paypal Fund For Sale / Fellow Webmasters, How Do You Charge Clients For Social Media Management? (2) (3) (4)

(1) (Reply) (Go Down)

My Fellow Webmasters, Help Please !! by geniusng(m): 7:44am On Sep 07, 2012
I was using PHP Mail() Function to configure but my host disable the function saying it is unsafe and told me to use SMTP instead which I have never used.

I got this code and it is working, the only issue I have is that it has 4 field only, Subject, name, email and comment
And I want to add phone and address but to no avail. Can anyone tell me what to do?

I have added phone and address but it does not deliver.

<?php
require_once "Mail.php";

$from = "Abuja Properties <mail@abujaproperties.com>";
$to = "Abuja Properties <calvarylove2002@yahoo.com>";
$username = "mail@abujaproperties.com";
$password = "mypasswordhere";
$host = "mail.abujaproperties.com"; // replace this with your domain's SMTP address.


$email = $_POST['email'] ;
$name = $_POST['name'] ;
$comments = $_POST['comments'];

$message .= "\n\n ";
$message .= $name;
$address = $_POST['address'] ;
$telephone = $_POST['telephone'];
$subject = $_POST['subject'];



/*The message is assembled for sending */
$name = $_POST['name'] ;
$subject = $_POST['subject'];
$message = $_POST['address'];
$message = $_POST['telephone'];
$message = $_POST['comments'];
$message .= "\n\n ";
$message .= $name . "\n";
$message .= $_POST['email'];


$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));

$mail = $smtp->send($to, $headers, $message);

if (PEAR::isError($mail))
{
echo("<p>" . $mail->getMessage() . "</p>"wink;
}
else
{
/*This is were you redirect your customers after he/she feels out the form.*/
header("Location: thankyou.php"wink;
}
?>
Re: My Fellow Webmasters, Help Please !! by hostingnaija: 7:59am On Sep 07, 2012
Hello! Try the following:

/*The message is assembled for sending */
$name = $_POST['name'] ;
$subject = $_POST['subject'];
$message = $_POST['address'];
$message .= $_POST['telephone'];
$message .= $_POST['comments'];
$message .= "\n\n ";
$message .= $name . "\n";
$message .= $_POST['email'];


Also, consider somer refactoring of the code, i will try to help you out with this later within today.
Good luck and tell us if it worked!
Re: My Fellow Webmasters, Help Please !! by geniusng(m): 7:54am On Sep 08, 2012
Thanks a million !! It worked but if put Address|Telephone|Message in one

50 Nnobi Street, Surulere, Lagos 2843747484848 testing

Stanislaus Okwor
calvarylove@yahoo.com

Thanks
Re: My Fellow Webmasters, Help Please !! by DualCore1: 8:02am On Sep 08, 2012
Learn PHP, the basics at least.
Re: My Fellow Webmasters, Help Please !! by geniusng(m): 8:08am On Sep 08, 2012
Yes, I got it finally
I added . "\n" before the closing of Address, telephone and comments

like this:
/*The message is assembled for sending */
$name = $_POST['name'] ;
$subject = $_POST['subject'];
$message = $_POST['address'] . "\n";
$message .= $_POST['telephone']. "\n";
$message .= $_POST['comments']. "\n";
$message .= "\n\n ";
$message .= $name . "\n";
$message .= $_POST['email'];

And they jump to the next line. I can see you added dot (.) before equal to sign (.=)
What does that mean? Thanks
Re: My Fellow Webmasters, Help Please !! by geniusng(m): 8:14am On Sep 08, 2012
When I was using PHP Mail() Function, I was able to have the result like this:

Name: Stanislaus Okwor
Address: 20 Nnobi Street, Surulere, Lagos
Phone: 08033398769
Email: info@codedwebmaster.com
Comments: Enquiry about web design and hosting.....

Please How can I achieve it here.

Thanks
Re: My Fellow Webmasters, Help Please !! by DualCore1: 12:40pm On Sep 08, 2012
geniusng: When I was using PHP Mail() Function, I was able to have the result like this:

Name: Stanislaus Okwor
Address: 20 Nnobi Street, Surulere, Lagos
Phone: 08033398769
Email: info@codedwebmaster.com
Comments: Enquiry about web design and hosting.....

Please How can I achieve it here.

Thanks


the dot (.) before the "=" site in PHP means concatenation (joining together) of a variable.

if I have a variable like this
$name = "Samuel";

and I add this

$name .= " Peters";

Now the variable $name is holding "Samuel Peters".

About having the mail displayed the way you want.
For the $message .= $_POST['telephone']. "\n"; for intance, make the following change:
$message .= "Comments: ".$_POST['telephone']. "\n";


Apply that to the rest.
Re: My Fellow Webmasters, Help Please !! by guru01(m): 2:30pm On Sep 08, 2012
Thank you @Dual core for helping out smiley
Re: My Fellow Webmasters, Help Please !! by geniusng(m): 1:30am On Sep 10, 2012
Thank you so much.
Re: My Fellow Webmasters, Help Please !! by talk2me006(m): 7:11am On Sep 10, 2012
hostingnaija: Hello! Try the following:

/*The message is assembled for sending */
$name = $_POST['name'] ;
$subject = $_POST['subject'];
$message = $_POST['address'];
$message .= $_POST['telephone'];
$message .= $_POST['comments'];
$message .= "\n\n ";
$message .= $name . "\n";
$message .= $_POST['email'];


Also, consider somer refactoring of the code, i will try to help you out with this later within today.
Good luck and tell us if it worked!
uhh! hostingnaija. i trust u nw. i know u always there to help fellow webmaster.
thanks jare.

(1) (Reply)

I Want To Create A Forum On Onlinebusiness / 5 Page Website For Educational Consulting Firm / MTN Nigeria Re-package VTU Service

(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. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.