Sending email issue

kim_foxx

Member
Messages
84
Reaction score
0
Points
6
I cant seem to get the users email to be sent to me... Whenever a user fill in the box i get their name and their message but not the email that they supplied... Can anyone see anything wrong with the code?

Thanks in advanced.


HTML:


<p align="left">Email:<br >
<input name="email" id="email" size="40" >


------------


<?php

function is_valid_email($from_email)
{
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si', $from_email);
}

$to_email = "XXXX@hotmail.com";
$subject = "secret";
$name.=$_POST['name']."\n" ;
$from_email.=$_POST['email']."\n" ;
$msg.=$_POST['message']."\n" ;

$message = "
Name:
$name
Email:
$email
Message:
$msg

";
 

AngusThermopyle

Active Member
Messages
319
Reaction score
52
Points
28
<?php

function is_valid_email($from_email)
{
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si', $from_email);
}

$to_email = "XXXX@hotmail.com";
$subject = "secret";
$name.=$_POST['name']."\n" ;
$from_email.=$_POST['email']."\n" ;
$msg.=$_POST['message']."\n" ;

$message = "
Name:
$name
Email:
$email
Message:
$msg

";

8) .
 

kim_foxx

Member
Messages
84
Reaction score
0
Points
6
Do i need to change the $from_email from the below code as well?
To be honest i dont even know what the below code does. I read on the forums awhile ago it is for protection...

function is_valid_email($from_email)
{
return preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si', $from_email);
 

as4s1n

New Member
Messages
174
Reaction score
4
Points
0
The preg_replace checks the input for a specific pattern of numbers/letters/characters. (I.E. yourEmail@email.com). That protects to make sure it is a valid email and to prevent any unwanted code (SQL injection).

To make it easier just change the $email to $from_email. You defined $from_email but called an undefined variable $email.
 
Last edited:
Top