7 Replies - 854 Views - Last Post: 29 April 2009 - 01:33 PM Rate Topic: -----

#1 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Email form

Posted 28 April 2009 - 03:19 PM

for some weird reason, i tried to send a email to myself and it said successful, but once i open up the test email. its blank? can someone help me

Here's the form

<form name="form1" method="post" action="send_contact.php">
<table cellpadding='0px' cellspacing='0px' width='100%'>
<tr background='images/registerbg.gif '>
<td>Subject: *</td>
<td><input name="subject" type="text" id="subject" size="50"><br></td>
</tr>

<tr bgcolor='#c0c0c0'>
<td>Detail: *</td>
<td><textarea name="detail" cols="50" rows="4" id="detail"></textarea><br></td>
</tr>

<tr background='images/registerbg.gif '>
<td>Name: *</td>
<td><input name="name" type="text" id="name" size="50"><br></td>
</tr>

<tr background='images/registerbg.gif '>
<td>Email: *</td>
<td><input name="customer_mail" type="text" id="customer_mail" size="50"><br></td>
</tr>

<tr background='images/registerbg.gif '>
<td>Submit: *</td>
<td><input type="submit" name="Submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"><br></td>
</tr>

<tfoot bgcolor='#b0b0b0'>
<td colspan="6">x</td>
</tfoot>

</form>


Here's the php

<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";

// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='aiitexx@hotmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>


Is This A Good Question/Topic? 0
  • +

Replies To: Email form

#2 noname_clark  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 75
  • Joined: 22-October 08

Re: Email form

Posted 28 April 2009 - 03:32 PM

your problem is that you are not sending the variables to the php page, your form is a "post" form, meaning it sends the variables through the internet rather than the "get" form which sends it through the string url.

instead of:
$subject ="$subject";
use:
$subject=$_POST['subject'];
and do this for all your variables.

so basically, $subject, $detail, $name, and $email were all blank variables, and thats why it sent a blank email to you
Was This Post Helpful? 0
  • +
  • -

#3 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Re: Email form

Posted 28 April 2009 - 03:51 PM

alright, so now the email-sender + subject shows up in my email, but the message doesn't


<?php
// Contact subject
$subject=$_POST['subject'];
// Details
$message="$detail";

// Mail of sender
$mail_from=$_POST['customer_mail'];
// From
$header="from: $name <$mail_from>";

// Enter your email address
$to ='aiitexx@hotmail.com';

$send_contact=mail($to,$subject,$message,$header);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>



i tried to do what you told me to in the $send_mail but that gave me an error.
Was This Post Helpful? 0
  • +
  • -

#4 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: Email form

Posted 28 April 2009 - 04:26 PM

Try the same for $message, or you could have made them all GET... just a thought.

This post has been edited by musya: 28 April 2009 - 04:26 PM

Was This Post Helpful? 0
  • +
  • -

#5 noname_clark  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 75
  • Joined: 22-October 08

Re: Email form

Posted 28 April 2009 - 10:32 PM

View Postmusya, on 28 Apr, 2009 - 03:26 PM, said:

Try the same for $message, or you could have made them all GET... just a thought.


exactly, do a $message=$_POST['detail'];

no, don't use GET. it would be a mess.... a huge mess for this situation....
explination:
basically, GET puts all the data entered into the form at the end of the url string. so the user would type in the info they want to send to you and it would take them to a url like: mail.php?message=hello%20I%20am%20sending%20this%20message%20to%20you
the internet browser (all browsers) will convert all spaces with "%20" when it gets inserted into the url string
there is no problem with this until you use the GET statement until you want to actually get the data.
so you would use the GET statement to get the message, and it would email it to you as "hello%20I%20am%20sending%20this%20message%20to%20you" and not convert all the %20 back into spaces, and it makes it really hard to read.
Was This Post Helpful? 0
  • +
  • -

#6 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: Email form

Posted 28 April 2009 - 10:52 PM

Yea is messier and more visible, but it was just an option.
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil  Icon User is offline

  • Dic Head
  • member icon

Reputation: 5163
  • View blog
  • Posts: 26,835
  • Joined: 10-May 07

Re: Email form

Posted 28 April 2009 - 11:08 PM

View Postnoname_clark, on 28 Apr, 2009 - 04:32 PM, said:

instead of:
$subject ="$subject";
use:
$subject=$_POST['subject'];
and do this for all your variables.

I prefer to throw the post value into strip_tags().
Was This Post Helpful? 0
  • +
  • -

#8 noname_clark  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 75
  • Joined: 22-October 08

Re: Email form

Posted 29 April 2009 - 01:33 PM

ok, so just simply strip the tags:
$subject=$_POST['subject'];
$subject=strip_tags($subject);



that should strip all the tags for $subject, do that for all of them.

if you want to allow cretain tags, just do:

$subject=$_POST['subject'];
$subject=strip_tags($subject,'<p><a>');


that one would allow "<p>" tags and "<a>" tags to stay in the variable $subject
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1