Jump to content

[SOLVED] Simple E-mail Form Question


svenny1

Recommended Posts

Hi i have followed a tutorial, and my e-mail form works fine, just i want to add more input boxes (which i can do) and then display them in the message of the e-mail. It is a form so a person can register with a clan for a gaming site.

 

Html Code - join.html

<form method="post" action="contact.php">
PSI: <input name="psi" type="text"><br>
E-Mail: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit">
</form>

 

PHP Code - contact.php

<?php
$to = "[email protected]";
$subject = "$psi wants to Join";
$psi = $_REQUEST['psi'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'];
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "$psi your application was sent successfully"; }
else
{print "Sorry $psi We encountered an error sending your mail"; }
?>

 

Basically i want the submitted form to print the email, psi number and the message into the message on the actual e-mail.

 

So the e-mail will pop up and say the following;

 

PSI number: 5768932

E-mail Address: [email protected]

Message: Hi i want to join your clan.

 

So my problem is i can't seem to get more than just the message to appear in the actual e-mail.

 

Many thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/112580-solved-simple-e-mail-form-question/
Share on other sites

Also, you need some form of validation on your user input because right now your form is wide open for injection.

 

<?php

$psi	= addslashes(strip_tags($_REQUEST['psi']));
$email	= addslashes(strip_tags($_REQUEST['email']));
$message	= addslashes(strip_tags($_REQUEST['message']));

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.