e-mail form through php script

ajnv60

New Member
Messages
1
Reaction score
0
Points
0
Dear X10Hosting,

I'm trying to e-mail a form through the following simple "send_form_email.php" script:

<?php
$to = "ajnv60@ekijsa.x10hosting.com";
$subject = "Contact Us";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

where the form input is collected through

<form method="post" action="send_form_email.php">
Name: <input name="name" type="text"><br>
<br>
E-mail: <input name="email" type="text"><br>
<br>
Message: <textarea name="message" rows="15" cols="40"></textarea> <br>
<br>
<input value="Submit" type="submit"> </form>

Entering form data runs smoothly, but when I hit the submit button the "send_form_email.php" script is shown and the e-mail is not sent.

Does this functionality work at X10Hosting, and if it does, can you please tell me what I'm doing wrong?

Thanks!
 

Zubair

Community Leader
Community Support
Messages
8,766
Reaction score
305
Points
83
***Moved to Programming Help***
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
What's the URL for the page? You should always include a link to a live page.

If you're seeing the PHP code in the page source, then PHP isn't processing the page.

You've got an injection vulnerability via the "email" form input. An attacker can inject arbitrary headers into the message, using it to send spam. Always sanitize user input.
 
Last edited:
Top