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('info@mydomain.com',$sub,$email,"From: $name <$email>");
echo $_POST["name"];
?>

, We will drop you a line shortly.

 

Any thoughts?

Link to comment
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@domain.co.za','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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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