Can't get email confirmation to work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vedderwing
Forum Newbie
Posts: 1
Joined: Thu Nov 04, 2010 2:04 pm

Can't get email confirmation to work

Post by vedderwing »

I am a beginner to the PHP world of programming and I am having trouble getting the email confirmation to function after a form is submitted by an user. I am posting my code here and hopefully someone can tell me why it isn't working.

code:

Code: Select all

<?php
require('vwheader.php');
?>
  <div id="globalnav">
    <div id="pagebox">
      <h1 class="pagetitle">Contact Me</h1>
    </div>
    <div id="menu" align="center"><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('home','','portfolioimages/buttons/homeOVER.png',1)"><img src="portfolioimages/buttons/home.png" alt="home" name="home" width="75" height="30" border="0" id="home" /></a><a href="about.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('about','','portfolioimages/buttons/aboutOver.png',1)"><img src="portfolioimages/buttons/about.png" name="about" width="75" height="30" border="0" id="about" /></a><a href="resume.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('resume','','portfolioimages/buttons/resumeOVER.png',1)"><img src="portfolioimages/buttons/resume.png" alt="resume" name="resume" width="75" height="30" border="0" id="resume" /></a><a href="designs.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('designs','','portfolioimages/buttons/designsOVER.png',1)"><img src="portfolioimages/buttons/designs.png" alt="designs" name="designs" width="75" height="30" border="0" id="designs" /></a><a href="contact.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contact','','portfolioimages/buttons/contactOVER.png',1)"><img src="portfolioimages/buttons/contact.png" alt="contact" name="contact" width="75" height="30" border="0" id="contact" /></a></div>
  </div>
  <p>&nbsp;</p>
  <div id="pagecontent">
    <?php // start of show_form function, global vars: $first,$last,$related[]; local vars for form: $options

function show_form($first="",$last="",$email="",$designdetails="") {
  
  ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="intel" id="intel">
      <table width="70%" border="0" cellspacing="1" cellpadding="1" align="center">
        <tr>
          <th colspan="2">Please Fill in your Contact Information and Design Needs</th>
        </tr>
        <tr>
          <td width="50%" align="right" valign="top">First Name:</td>
          <td width="50%"><input name="first" type="text" id="first2" value="<? echo $first; ?>"></td>
        </tr>
        <tr>
          <td align="right" valign="top">Last Name:</td>
          <td><input name="last" type="text" id="last2" value="<? echo $last; ?>"></td>
        </tr>
        <tr>
          <td align="right" valign="top">Email:</td>
          <td><input name="email" type="text" id="email2" value="<? echo $email; ?>"></td>
        </tr>
        <tr>
          <td align="right" valign="top">Please Describe Your Design Needs: </td>
          <td valign="top"><textarea name="designdetails" cols="60" value="<?php echo $designdetails; ?>"></textarea></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit" value="Submit"></td>
        </tr>
      </table>
    </form>
    <?php 
} // end of show_form function

if($_SERVER['REQUEST_METHOD']!='POST') {

  show_form();

  } else {

  if ((empty($_POST['first'])) || (empty($_POST['last'])) || (empty($_POST['email'])) || (empty($_POST['designdetails']))){
  
    echo '<p align="center">You did not fill in all the fields, please try again!</p>';
  
    show_form($_POST['first'],$_POST['last'],$_POST['email'],$_POST['designdetails']);
  
    } else {
    
	echo '<p align="center">Thank you for considering Vedderwing Graphics for your Design Needs.</p><p align="center">An email was sent to you to confirm your contact information and your design needs.</p><p align="center">-Vedderwing Graphics Staff</p>';
	}
  }
if ($_SERVER['REQUEST_METHOD']=="POST")
{
	$first = $_POST['first'];
  $last = $_POST['last'];
    $email = $_POST['email'];
	$designdetails = $_POST['designdetails'];
	
	$to = "vedderwing9@yahoo.com " . $email;
  $from = "vedderwing9@yahoo.com";
  $subject = "Contact Form";
  
  $message .= "Contact Information and Design Needs\n\n";
  $message .= "$first $last\n";
  $message .= "Thank you again for considering Vedderwing Graphics for your design needs. \n\n";
  $message .=  "Here are the design details that you submitted: \n\n";
  $message .= "$designdetails\n\n";
  $message .="Upon review, one of our staff will be in contact with you to further discuss your design needs.\n\n";
  $message .= "Thank You,\n\n";
  $message .="Vedderwing Graphics\n";
    
  $mail_sent = mail( $to, $subject, $message, 'From: ' . $from);
  
	}

?>
    <p align="center">Reset this <a href="<?php echo $_SERVER['PHP_SELF']; ?>">form</a>.</p>
    <?php
require('vwfooter.php');
?>
Post Reply