Jump to content

Entry Level Problem


nagger

Recommended Posts

Guys,

 

Just trying to get into PHP but I am struggling with the following:

 

When setting up a php mail form I can get all working.  My problem is that I can't get the form to send both the fillers name and email and display it in the body of the received email.

 

In the HTML age I have

<form action="process.php" method="post">
Name: <input type="text" name="name" size="20" maxlength="20" /><br />
Email: <input type="text" name="email" size="30" maxlength="30" /><br />
<input type="hidden" name="sub" value="XXXXX" /><br />
<input type="submit" name="submit" value="Send" />
</form>

 

And in the php page I have

Thanks <?php
@extract($_POST);
$name = stripslashes($name);
$email = stripslashes($email);
mail('[email protected]',$sub,$email,"From: $name <$email>");
echo $_POST["name"];
?>

, We will drop you a line shortly.

 

Any thoughts?

Link to comment
https://forums.phpfreaks.com/topic/70879-entry-level-problem/
Share on other sites

  • 1 year later...

you can try this:

 

<?PHP

if (isset($_POST['submit']))

{

$name = "";

$email = "";

if (isset($_POST['name'])) $name = $_POST['name'];

if (isset($_POST['email'])) $email = $_POST['email'];

$Body .= "Name: $name\n";

$Body .= "Email: $email\n";

if (mail('[email protected]','Mail from website',$Body,"From: $email"))

echo 'mail has been sent<br>';

else

echo 'mail could not be sent<br>';

}

?>

 

<form method="POST">

Name: <input type="text" name="name" size="20" maxlength="20" /><br />

Email: <input type="text" name="email" size="30" maxlength="30" /><br />

<input type="submit" name="submit" value="Send" />

</form>

 

 

Link to comment
https://forums.phpfreaks.com/topic/70879-entry-level-problem/#findComment-667782
Share on other sites

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.