Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
simple contact form emailer not working
Old 03-13-2009, 05:28 PM simple contact form emailer not working
Webmaster Talker

Posts: 611
Trades: 0
hi, i made a simple contact form that doesnt post all the data in my email. any help greatly apprectiated. the part that doesnt show up is "phone" also, the receipt page echo is just echoing "your message has been sent to...etc" and its not echoing the $subject or $body.thank you. derek EDIT-nevermind, i got "phone" to work, but the $subject and $body still does not echo. (also, someone just told me that a hacker could change my code or variables. is there something i can do to stop this?)

here is the html for the form.

Code:
<form id="flowers_form" name="flowers_form" method="post" action="flowers_emailer.php">
     <div><label for="message">Send us a message</label><textarea name="message" id="message" cols="30" rows="10"></textarea>
     </div>
     <div><label for="name">Name</label><input name="name" id="name" type="text"></input></div>
     <div><label for="phone">Phone</label><input phone="phone" id="phone" type="text"></input></div>
     <div><label for="email">Email</label><input email="email" id="email" type="text"></input></div>
     <div>Select Location:<select name="location" id="location">
              <option id="location" name="location" value="nj_fortlee">NJ - Fort Lee</option>
         <option id="location" name="location" value="nj_jerseycity">NJ - Jersey City</option>
         <option id="location" name="location" value="nj_princeton">NJ - Princeton</option>
         <option id="location" name="location" value="nj_shorthills">NJ - Short Hills </option>
         <option id="location" name="location" value="nj_brid">NJ - Bridgewater</option>
         <option id="location" name="location" value="nj_eastbrunswick">NJ - East Brunswick</option>
         <option id="location" name="location" value="nj_newark">NJ - Newark</option>
         <option id="location" name="location" value="nj_iselin">NJ - Iselin</option>
         <option id="location" name="location" value="nj_lawrenceville">NJ - Lawrenceville</option>
         <option id="location" name="location" value="nj_mahwah">NJ - Mahwah</option>
         <option id="location" name="location" value="nj_morriston">NJ - Morristown</option>
         <option id="location" name="location" value="nj_mtlaurel">NJ - Mt. Laurel</option>
         <option id="location" name="location" value="nj_parsippany">NJ - Parsippany</option>
         <option id="location" name="location" value="nj_redbank">NJ - Red Bank</option>
         <option id="location" name="location" value="nj_roseland">NJ - Roseland</option>
         <option id="location" name="location" value="nj_saddlebrook">NJ - Saddle Brook</option>
         <option id="location" name="location" value="nj_piscataway">NJ - Piscataway</option>
         <option id="location" name="location" value="ny_nyc">NY - New York City</option>
         <option id="location" name="location" value="ny_rye">NY - Rye</option>
         <option id="location" name="location" value="ny_tarrytown">NY - Tarrytown</option>
         <option id="location" name="location" value="ny_whiteplains">NY - White Plains</option>
         <option id="location" name="location" value="ny_bohemia">NY - Bohemia</option>
         <option id="location" name="location" value="ny_hauppauqe">NY - Hauppauqe</option>
         <option id="location" name="location" value="ny_lakesuccess">NY - Lake Success</option>
         <option id="location" name="location" value="ny_melville">NY - Melville</option>
         <option id="location" name="location" value="ny_syosset">NY - Syosset</option>
         <option id="location" name="location" value="ny_uniondale">NY - Uniondale</option>
         <option id="location" name="location" value="ct_greenwich">CT - Greenwich</option>
         <option id="location" name="location" value="ct_stamford">CT - Stamford</option>
         <option id="location" name="location" value="ca_losangeles">CA - Los Angeles</option>
         <option id="location" name="location" value="ca_sanfrancisco">CA - San Francisco</option>
         <option id="location" name="location" value="fl_miami">FL - Miami</option>
         <option id="location" name="location" value="fl_orlando">FL - Orlando</option>
         <option id="location" name="location" value="fl_fortlauderdale">FL - Fort Lauderdale</option>
         <option id="location" name="location" value="fl_palmbeach">FL - Palm Beach</option>
         <option id="location" name="location" value="dc_washington">DC - Washington</option>
         <option id="location" name="location" value="pa_philadelphia">PA - Philadelphia</option>
         <option id="location" name="location" value="pa_allentown">PA - Allentown</option>
         <option id="location" name="location" value="russia_moscow">RUSSIA - Moscow</option>
         <option id="location" name="location" value="russia_stpetersburg">RUSSIA - St. Petersburg</option>
                  
            </select></div>
     <div><input name="submit" id="submit" value="submit" type="submit"></input></div>
    </form>
and here is the php for the form.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php 
if(isset($_POST['submit'])) { 
$to = "derekpainter1@hotmail.com"; 
$subject = "Flower Events Mailer"; 

foreach($_POST as $key => $value) {  /*loops through the POST array and uses the form values*/
  $$key = $value;
}
  
$body = "From: $name\n E-Mail: $email \n Message:  $message \n Location: $location \n Phone: $phone"; 
  
echo "Thank you for contacting Flower Events!"; 
mail($to, $subject, $body); 
} else { 
echo "blarg!"; 
} 
?> 

</body>
</html>

Last edited by silverglade; 03-13-2009 at 06:30 PM..
silverglade is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-13-2009, 06:31 PM Re: simple contact form emailer not working
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
on the php of the form, try this
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php 
if(isset($_POST['submit'])) { 
$to "derekpainter1@hotmail.com"
$subject "Flower Events Mailer"

foreach(
$_POST as $key => $value) {  /*loops through the POST array and uses the form values - This is very insecure and lazy.*/
  
$key $value// changed this line. their was two $'s
}
  
$body "From: $name\n E-Mail: $email \n Message:  $message \n Location: $location \n Phone: $phone"
  
echo 
"Thank you for contacting Flower Events!"
mail($to$subject$body); 
} else { 
echo 
"blarg!"

?> 

</body>
</html>
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE

Last edited by rogem002; 03-13-2009 at 06:32 PM..
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 03-13-2009, 06:54 PM Re: simple contact form emailer not working
Webmaster Talker

Posts: 611
Trades: 0
awesome thank you rogem002! the form works perfectly now except that the

mail($to, $subject, $body); dont echo to the screen, it stops at the $to variable.

Last edited by silverglade; 03-13-2009 at 07:04 PM..
silverglade is offline
Reply With Quote
View Public Profile
 
Old 03-14-2009, 11:40 AM Re: simple contact form emailer not working
Skilled Talker

Posts: 85
Name: Ilyes Rhouma
Trades: 0
Does mail($to,...,...) send the email ?
If yes what is not working ?
__________________
Want a cheap and custom programmer or writer ?
Please login or register to view this content. Registration is FREE

Are you
Please login or register to view this content. Registration is FREE
? Start
Please login or register to view this content. Registration is FREE
free and earning money !
Please login or register to view this content. Registration is FREE
Ilyes is offline
Reply With Quote
View Public Profile Visit Ilyes's homepage!
 
Old 03-15-2009, 12:40 AM Re: simple contact form emailer not working
Webmaster Talker

Posts: 611
Trades: 0
oh,.i thought mail() told it to echo the contents of the variable. but i guess i might be wrong. heh. not sure. maybe i will just type a manual echo message. derek
silverglade is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to simple contact form emailer not working
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.74675 seconds with 12 queries