Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 12-27-2010, 07:34 AM
stan1 stan1 is offline
Member
 
Join Date: 12-18-10
Posts: 41
iTrader: 0 / 0%
PHP send mail error

i am having some problem with my PHP form . I have created everything and its posting the details to my mailbox the problem however is that in the message area all it shows is $text , it doesn't show what the visitor typed into that area all it shows is $text

here is the form
Quote:
<html>
<head><title>contact us </title>
</head>
<body><form action="step2.php" method ="post">
Name<br/><input type="text" name="username" /><br/>
Email<br/><input type="text" name="email" /><br/>
Inquiry<br/><textarea row="7" cols="70" name="inquiry" /></textarea><br/>
<input type="submit"value="send your inquiry" /></form>
</body>
</html>

here is the PHP

Quote:
<?php

$name = $_POST['username'];
$email = $_POST['email'];
$text = $_POST['inquiry'];

//To, Subject, Message, Header
mai('myemail@mywebsite.com','Inquiry',$text,'From: '.

$name .'<' . $email . '>');
'>');

header('location: step3.html')

?>
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 12-27-2010, 08:01 AM
cbsmth's Avatar
cbsmth cbsmth is offline
v7n Mentor
 
Join Date: 08-17-10
Location: Mexico
Posts: 175
iTrader: 0 / 0%
Comment out the mail()-function and the header redirect to step 3, then use the following to debug your POST-data:

Code:
<?php echo nl2br(print_r($_POST, true)); ?>
Check if the inquiry is there for starters, and what it holds.

I'd also recommend adding in something as the following for error handling:

Code:
if( mail(args... ) ) { header('step3.html'); } else { echo 'Oh noes! Could not send.'; }
 
Reply With Quote
  #3  
Old 12-28-2010, 07:15 PM
buggie's Avatar
buggie buggie is offline
Contributing Member
 
Join Date: 12-16-10
Location: Poland
Posts: 53
iTrader: 0 / 0%
try to use this code. I'm using it and works perfect.

URL: /contact
HTML Code:
<form id="contacts-form" action="/contact/form" method="post"> <fieldset> <label>Name / Comapny:<br /> <input type="text" value="" name="nazwa"/> </label> <label>E-mail / Phone:<br /> <input type="text" value="" name="kontakt" /> </label> Message:<br /> <textarea cols="" rows="" name="wiadomosc"></textarea> <div class="alignright"><a href="#" class="button5" onclick="document.getElementById('contacts-form').submit()">Wyślij</a></div> </fieldset> </form>

URL: /contact/form
PHP Code:
<?php
$name 
$_POST['nazwa'];
$email $_POST['kontakt'];
$message $_POST['wiadomosc'];
$headers  "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=utf-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: Contact Form <Contact Form>\n";


$email_to "terefere@gmail.com";
$email_subject "Message from ....";
$email_message 
    
"Name / Company:   ".$name.
    
"\nPhone / E-mail:   ".$email.
    
"\nMessage:   ".$message;
  if(
mail($email_to$email_subject$email_message$headers)){
    echo 
"Email (".$email_subject.") has been sent.";
} else {
    echo 
"Email (".$email_subject.") wasn't sent.";
}

header'Location: /contact' ) ;
?>
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot send email to yahoo.com mail only. Help !!!!!! basketmen Web Hosting Forum 3 11-22-2010 01:54 AM
Best way to send mass e-mail? kade119 Web Design Lobby 7 08-25-2010 05:25 PM
How to check whether the mail has been successfully send using mail function in php? refilltuffy Coding Forum 5 06-07-2010 03:35 PM
my Outlook won't send e-mail shahab6 Tech Talk 7 09-03-2009 01:46 PM
qmail does not send e-mail keko Dedicated Servers 1 06-23-2006 12:09 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 04:54 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC