Jump to content

Where do I put my email address?


SebbieHE

Recommended Posts

Hello. Please could someone tell me where to put MY email address so that when they send the message, I receive the email?

 

 

<?php

$owner_email = $_POST["owner_email"];

$headers = 'From:' . $_POST["email"];

$subject = 'A message from your site visitor ' . $_POST["name"];

$messageBody = "";

 

if($_POST['name']!='nope'){

$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['email']!='nope'){

$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}else{

$headers = '';

}

if($_POST['state']!='nope'){

$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['phone']!='nope'){

$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['fax']!='nope'){

$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['message']!='nope'){

$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";

}

 

if($_POST["stripHTML"] == 'true'){

$messageBody = strip_tags($messageBody);

}

 

try{

if(!mail($owner_email, $subject, $messageBody, $headers)){

throw new Exception('mail failed');

}else{

echo 'mail sent';

}

}catch(Exception $e){

echo $e->getMessage() ."\n";

}

?>

Link to comment
Share on other sites

The form code is below.

 

 

 

 

<form action="send_form.php" id="ContactForm">

<div class="success"> Contact form submitted! I will be in touch soon.</div>

<fieldset class="left">

<div class="block">

<label class="name">

<span class="title1">Name:</span>

<span class="bg"><input type="text" value="" class="input"></span>

<span class="error">*This is not a valid name.</span> <span class="empty">*This field is required.</span> </label>

<label class="email">

<span class="title1">Email:</span>

<span class="bg"><input type="email" value="" class="input"></span>

<span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span></label>

 

<label class="phone">

<span class="title1">Phone:</span>

<span class="bg"><input type="tel" value="" class="input"></span>

<span class="error">*This is not a valid number.</span> <span class="empty">*This field is required.</span> </label>

</div>

 

<div class="block">

<label class="message">

<span class="title1">Message:</span>

<span class="bg"><textarea rows="1" cols="2"></textarea></span>

<span class="error">*The message is too short.</span> <span class="empty">*This field is required.</span> </label>

</div>

<div class="formButtons">

<div class="formBtn">

<a href="#" data-type="submit" class="moreButton">Send</a>

</div>

<div class="formBtn">

<a href="#" data-type="reset" class="moreButton">Clear</a>

</div>

</div>

</fieldset>

</form>

Link to comment
Share on other sites

The actual latest code:

 

 

<?php

$owner_email = $_POST["sebbieharrisonevans@gmail.com"];

$headers = 'From:' . $_POST["email"];

$subject = 'A message from your site visitor ' . $_POST["name"];

$messageBody = "";

 

if($_POST['name']!='nope'){

$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['email']!='nope'){

$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}else{

$headers = '';

}

if($_POST['state']!='nope'){

$messageBody .= '<p>State: ' . $_POST['state'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['phone']!='nope'){

$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['fax']!='nope'){

$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";

$messageBody .= '<br>' . "\n";

}

if($_POST['message']!='nope'){

$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";

}

 

if($_POST["stripHTML"] == 'true'){

$messageBody = strip_tags($messageBody);

}

 

try{

if(!mail($owner_email, $subject, $messageBody, $headers)){

throw new Exception('mail failed');

}else{

echo 'mail sent';

}

}catch(Exception $e){

echo $e->getMessage() ."\n";

}

?>

Link to comment
Share on other sites

See, that's a lot more useful. Could have saved 5 or so posts.

 

 

 

 

$_POST is an array. When you do $_POST['field_name'] you are looking for the value of the $_POST array at the field_name key.

$owner_email = $_POST["sebbieharrisonevans@gmail.com"]; is looking for a posted field with the name of your email address. 

 

 

 

 

If you had error reporting on and set to show notices, you'd see this is wrong.

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.