Jump to content

PHP form problem - a newbie question


drog1998

Recommended Posts

HI there,

 

i'm using a flash and php form.

 

The problem lie in the PHP I only seem to get the field titles (Name and telephone) coming through and not the data they contain.

 

Could somebody tell me what i'm doing wrong?

 

<?php
$sendTo = "myemail@gmail.com";
$subject = "An enquiry";

$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];
$message = "telephone: ".$strtelephone."\r\n";
$message .= "message: ".$strmessage."\r\n";

mail($sendTo, $subject, $message, $headers);

?>

 

thank you

Link to comment
Share on other sites

ok no problem.

 

All i get through are the words...

 

telephone:

message:

 

What I want to happen is for my website to send the data from the fields labeled telephone and message in a website.

 

so in a perfect world come thorough looking something like this...

 

telephone: 9999 9999

message: hi drog1998

 

thanks again

 

Link to comment
Share on other sites

The examples you have been using are obviously VERY old code that relied on register globals being on. This has been off by default for over 7 years.

 

The data you require will be within the $_POST array. eg $_POST['strtelephone'] & $_POST['strmessage'].

Link to comment
Share on other sites

i couldn't get that to work  :(

 

have i got the syntax right?

 

<?php
$sendTo = "drog1998@gmail.com";
$subject = "An enquiry";
$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-path: " . $_POST["email"];
$message = "telephone: ". $_POST['strtelephone']"\r\n";
$message .= "message: ". $_POST['strmessage']"\r\n";
mail($sendTo, $subject, $message, $headers);

?>

Link to comment
Share on other sites

Still nothing with this code.

 

<?php
$sendTo = "drog1998@gmail.com";
$subject = "An enquiry";
$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";
// next include a replyto
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-path: " . $_POST["email"];
$message = "telephone: ". $_POST['strtelephone']"\r\n";
$message .= "message: ". $_POST['strmessage']"\r\n";
mail($sendTo, $subject, $message, $headers);

echo "<pre>";
echo "GET:";
print_r($_GET);
echo "POST:";
print_r($_POST);
echo "</pre>";

?>

Link to comment
Share on other sites

Define: still nothing?

 

What output did you get?

 

You are expecting someone who is not standing right next to you to help you with what your code is doing. If you don't state or post what results you did get, no one can possibly help you.  :psychic:

 

Based on your symptom of 'still nothing' it is likely that your form is invalid and isn't sending anything to your form processing code.

Link to comment
Share on other sites

You do have a few syntax errors in there now too... these two lines.....

 

$message = "telephone: ". $_POST['strtelephone']"\r\n";
$message .= "message: ". $_POST['strmessage']"\r\n";

 

should be....

 

$message = "telephone: ". $_POST['strtelephone'] . "\r\n";
$message .= "message: ". $_POST['strmessage'] . "\r\n";

Link to comment
Share on other sites

ok what i meant by nothing was that i'm still getting an email through with just the words.

 

telephone:

message:

 

here's the code again which i updated with thorpes corrections

 

<?php
$sendTo = "drog1998@gmail.com";
$subject = "An enquiry";

$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];
$message = "telephone: ". $_POST['strtelephone'] . "\r\n";
$message .= "message: ". $_POST['strmessage'] . "\r\n";

mail($sendTo, $subject, $message, $headers);

?>

 

any suggestions?

Link to comment
Share on other sites

LOL, the two lines of code that thorpe pointed out with errors in them would have prevented your php code from executing at all. If you received emails while using the code that contained those two errors, then the code you are actually using on your server is not the code you have been posting.

 

I'm thinking that using a page with a flash form on it would probably not show any output from the php code. If you are receiving some of the form data in the email but not those two values, it is either due to your form not sending the data to the php code or due to a field name mis-match.

 

What is the actual code of your form page and what are the exact (keeping in mind that computers only do exactly what their code tells them to do and a spelling error or capitalization difference would prevent this from working) field names it is sending?

 

I seriously recommend getting this to work with a HTML form first, then do any extras like using a flash form.

 

Also, if this is gong to be used for real (not just an assignment in a programming class), you MUST validate, in your form processing code, any of the form data that is being put into the header field to prevent hackers from sending their email through your mail server.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.