Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,147,759 members, 7,798,541 topics. Date: Tuesday, 16 April 2024 at 05:19 AM

What's Wrong With This Php Form Code Sef? - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / What's Wrong With This Php Form Code Sef? (862 Views)

Can You Solve This PHP Problem?? / Help To Correct This Php Mailer Code / @Yawa-ti-de:Please Help Me Check This PHP Mailer To See If The Script Is Correct (2) (3) (4)

(1) (Reply) (Go Down)

What's Wrong With This Php Form Code Sef? by feelme3(m): 2:44am On Aug 19, 2011
Please can anybody help me with this code. Am trying to process my form for the 1st time with php and its not going as I've been made to believe. I've submited the for three times but yet to recieve it in the specified email address. Please, am I missing something? Abeg, sombody please help.

the FORM
<script src="js/functions.js"></script>
<form method="post" action="sendmail.php" onSubmit="return validateForm(Array('FirstName', 'LastName', 'Email', 'WorkPhone'), this);" name="contact" id="contact">
<input type="hidden" name="Source" value="9" />
<div class="set" id="req-fields">
<h3>Required Info</h3>
<label for="FirstName" class="required">First name</label>
<input type="text" name="FirstName" class="text" /><br class="clear" />
<label for="LastName" class="required">Last name</label>
<input type="text" name="LastName" class="text" /><br class="clear" />
<label for="Email" class="required">Email</label>
<input type="text" name="Email" class="text" /><br class="clear" />
<label for="WorkPhone" class="required">Daytime phone</label>
<input type="text" name="WorkPhone" class="text" /><br class="clear" />
<div class="field-note">(to discuss your needs and make specific recommendations)</div>
<div class="clear"></div>
<div class="continue-arrow"></div>
</div>
<div class="set" id="opt-fields">
<h3>Helpful Info <span class="note">(optional)</span></h3>
<label for="BestTimeToContact">Best time to reach you</label>
<input type="text" name="BestTimeToContact" class="text" /><br class="clear" />

<label for="DepartureCity">Departure city</label>
<input type="text" name="DepartureCity" class="text" /><br class="clear" />

<label for="Destination">Destination</label>
<input type="text" name="Destination" class="text" /><br class="clear" />

<label for="TravelDates">When will you travel?</label>
<input type="text" name="TravelDates" class="text" /><br class="clear" />

<label for="NumberOfNights">How many nights?</label>
<select name="NumberOfNights">
<option>Please select</option>
<option value="1-2 Nights">1-2 Nights</option>
<option value="3-6 Nights">3-6 Nights</option>
<option value="7-9 Nights">7-9 Nights</option>
<option value="10-14 Nights">10-14 Nights</option>
<option value="Over 14 Nights">Over 14 Nights</option>
</select><br class="clear" />

<label for="PerPersonBudget">Your per-person budget</label>
<select name="PerPersonBudget">
<option>Please select</option>
<option value="under $1000">under $1000</option>
<option value="$1001 - $1500">$1001 - $1500</option>
<option value="$1500 - 2500">$1500 - 2500</option>
<option value="$2501 - $5000">$2501 - $5000</option>
<option value="$5000+">$5000+</option>
</select><br class="clear" />

<!-- <label for="TravelStyle">Your travel style</label>
<select name="TravelStyle">
<option>Please select</option>
<option value="Deluxe/luxury">Deluxe/luxury</option>
<option value="Good Quality/moderate">Good Quality/moderate</option>
<option value="Budget/basic">Budget/basic</option>
</select><br class="clear" />-->

<label for="HowHeardAbout">How did you hear about us?</label>
<select name="HowHeardAbout" class="wide">
<option>Please select</option>
<option value="Amtrak.com">Amtrak.com</option>
<option value="AOL">AOL</option>
<option value="CNBC">CNBC</option>
<option value="CruiseCritic">CruiseCritic</option>
<option value="Cruiseline referral">Cruiseline referral</option>
<option value="Email Specials">Email Specials</option>
<option value="Friend/Customer referral">Friend/Customer referral</option>
<option value="Google">Google</option>
<option value="Google Ad Words">Google Ad Words</option>
<option value="Magazine">Magazine</option>
<option value="Mailer">Mailer</option>
<option value="MSN">MSN </option>
<option value="Newspaper">Newspaper</option>
<option value="NorthWest Airlines">Northwest Airlines</option>
<option value="NWA.com">NWA.com</option>
<option value="NWA Worldsperks Visa">NWA Worldsperks Visa</option>
<option value="Radio/TV">Radio/TV</option>
<option value="TravelZoo">TravelZoo</option>
<option value="US Bank">US Bank</option>
<option value="Yahoo">Yahoo</option>
<option value="Other Search Engine">Other Search Engine</option>
<option value="Other">Other</option>
</select><br class="clear" />

<label for="Comments" class="comments">Anything else you'd like us to know about this trip so we can best meet your needs</label>
<textarea name="Comments"></textarea><br class="clear" />
<div class="clear"></div>
<div class="continue-arrow"></div>
</div>
<div id="submit-box">
<div id="captcha">
<img src="form/captcha.php" alt="" /><br/>
Please enter the code shown above: <input MAXLENGTH="8" SIZE="8" name="userstring" type="text" value=""/>
</div>
<button type="submit">Contact Us!</button>
</div>
</form>

The sendmail php code
<?php
 $FirstName = $_REQUEST['FirstName'] ;
 $LastName = $_REQUEST['LastName'] ;
 $Email = $_REQUEST['Email'] ;
 $WorkPhone = $_REQUEST['WorkPhone'] ;

 mail( "edyfriendslink@yahoo.com", "Feedback Form Results", $FirstName, $WorkPhone, $Email );
 header( "Location: http://www.multiterrain.com/thankyou.html" );
?>
Re: What's Wrong With This Php Form Code Sef? by Nobody: 9:18pm On Aug 19, 2011
Caramba! I tested the code using my offline email simulator - some kinda preview thinggy i made some years back:
= the result:
edyfriendslink@yahoo.com
From:
Subject:
Feedback Form Results 074687 Tony
074687 Tony

That shows that the From is missing, i suspect it is because you are not using a proper email header.
viz-a-viz


After making a modification to the sendmail:

<?php
$FirstName = $_REQUEST['FirstName'] ;
$LastName = $_REQUEST['LastName'] ;
$Email = $_REQUEST['Email'] ;
$WorkPhone = $_REQUEST['WorkPhone'] ;

$headers = "From: $Email" . "\r\n" .
"Reply-To: $Email" . "\r\n" .
'X-Mailer: PHP/' . phpversion();


mail( "edyfriendslink@yahoo.com", "Feedback Form Results", "$FirstName, $WorkPhone, $Email",$headers);
//header( "Location: http://www.multiterrain.com/thankyou.html" );
?>

The result - still on my offline simulator - is this

edyfriendslink@yahoo.com
From:
caramba@hotpop.com
Subject:
Feedback Form Results
Tony, 074687, caramba@hotpop.com
Re: What's Wrong With This Php Form Code Sef? by Nobody: 9:34pm On Aug 19, 2011
Ohhh Boy,

See codes shaaa.
Re: What's Wrong With This Php Form Code Sef? by feelme3(m): 3:24pm On Aug 20, 2011
caramba DHTML grin
I always tell people you are the wizard. Kai!

I got it working with the snippet you added. But, how do I make the appropriate ID names show with the FORM msg?

E.g.
FIRST NAME: XXXXX
LAST NAME: XXXXX
PHONE: 080XXXXXX etc

I know say you are a very busy man so don't even start telling me about it wink

Thanks man!
Re: What's Wrong With This Php Form Code Sef? by Nobody: 10:57pm On Aug 20, 2011
<?php
$FirstName = $_REQUEST['FirstName'] ;
$LastName = $_REQUEST['LastName'] ;
$Email = $_REQUEST['Email'] ;
$WorkPhone = $_REQUEST['WorkPhone'] ;

$headers = "From: $Email" . "\r\n" .
"Reply-To: $Email" . "\r\n" .
'X-Mailer: PHP/' . phpversion();

$message="

<table>
<tr><td>First Name:</td><td>$FirstName</td></tr>
<tr><td>Last Name:</td><td>$lastName</td></tr>
<tr><td>E-mail:</td><td>$Email</td></tr>
<tr><td>Work Phone:</td><td>$workPhone</td></tr>
</table>
";


mail( "edyfriendslink@yahoo.com", "Feedback Form Results","$message",$headers);
//header( "Location: http://www.multiterrain.com/thankyou.html" );
?>

No time to test this, but it should work just fine.
Re: What's Wrong With This Php Form Code Sef? by feelme3(m): 2:08pm On Aug 21, 2011
@dhtl, good afternoon and hope your Sunday is going great (except ofcos me trying to disturb your nap)

Ok, I tried the code and below is the output I received.

Feedback Form Results

Hide Details
FROM:
edyfriendslink@yahoo.com
TO:
edyfriendslink@yahoo.com
Message flagged Sunday, August 21, 2011 1:50 PMMessage body


<table>
<tr><td>First Name:</td><td>Edet</td></tr>
<tr><td>Last Name:</td><td></td></tr>
<tr><td>E-mail:</td><td>edyfriendslink@yahoo.com</td></tr>
<tr><td>Work Phone:</td><td></td></tr>
</table>

I was hoping it would break into new lines without the table tags showing. Do you think I can embed css in place of the table to achieve the result?

And, I was thinking, can u make a recommendation of a good php tutorial for a beginner where I can start off?

Thanks.
Re: What's Wrong With This Php Form Code Sef? by Nobody: 3:31pm On Aug 21, 2011
Sorry, i have forgotten that these days, the tags breakdown and all those nonsense.
In real life, i dont use the mail function directly again - i will use all them phpwrappers.

I think you can download it from:
http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1/
Re: What's Wrong With This Php Form Code Sef? by feelme3(m): 8:35pm On Aug 21, 2011
*dhtml:

Sorry, i have forgotten that these days, the tags breakdown and all those nonsense.
In real life, i dont use the mail function directly again - i will use all them phpwrappers.

I think you can download it from:
http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/PHPMailer%20v5.1/

Ok, will check it out,
Re: What's Wrong With This Php Form Code Sef? by WebSurfer(m): 4:42am On Aug 22, 2011
wink wink wink wink wink wink

(1) (Reply)

Technology News Website For Sale. / Please Is Smartwebng A Genuine Webhost? / Best NG Online Payment Solution

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