Jump to content

How to submit a php form to database and email


flashbangpro

Recommended Posts

I have searched books, videos, and other forums on how to do this without any luck getting mine to work properly. The form is inserted into database fine, but I don't receive the email notification.

 

Here is the code

 

<html>
<body>
<ul>
<li><a href="vehicle_list.php" title="">SEVICE ORDER LIST</a></li>
<li><a href="index.php">LOG OUT</a></li>
      </ul>
</div>
<h1>Vehicle Repair Form</h1>
    <section>
       <section>
         <form method="post" name="form1" action="vehicle_info.php">
           <table align="center">
             <tr valign="baseline">
               <th nowrap align="right">Vehicle Name:</th>
              <td>
                 <input type="text" name="name" value="" size="32">
             </tr>
		 <tr valign="baseline">
               <th nowrap align="right">Vehicle Number:</th>
              <td>
                 <input type="text" name="number" value="" size="32">
             </tr>
		 <tr valign="baseline">
               <th nowrap align="right">Vehicle Vin Number:</th>
              <td>
                 <input type="text" name="vin_number" value="" size="32">
             </tr>
             <tr valign="baseline">
               <th nowrap align="right">Location:</th>
              <td>
                 <input type="text" name="location" value="" size="32">
             </tr>
             <tr valign="baseline">
               <th nowrap align="right">Status:</th>
              <td>
              <input type="text" name="status" value="" size="32">
             </tr>
             <tr valign="baseline">
               <th nowrap align="right">RTS:</th>
              <td>
                 <input type="text" name="rts" value="" size="32">
             </tr>
             <tr valign="baseline">
               <th nowrap align="right">Odometer Reading:</th>
              <td>
                 <input type="text" name="odomread" value="" size="32">
             </tr>
             <tr valign="baseline">
               <th nowrap align="right">Date Of Odometer Reading:</th>
               <td><input type="text" name="odomdate" value="" size="32"></td>
             </tr>
               
		   </tr>
		 <tr valign="baseline">
               <th nowrap align="right">Issue Being Reported:</th>
		   <td><select name="issues_reported" >
		   <option value="Engine">Engine</option>
		   <option value="Transmission">Transmission</option>
		   <option value="Differential">Differential</option>
		   <option value="Electrical">Electrical</option>
		   <option value="Tires">Tires</option>
		   <option value="Brakes">Brakes</option>
		   <option value="HVAC">HVAC</option>
		   <option value="Lighting">Lighting</option>
		   <option value="Accident">Accident</option></select></td>
             </tr>
              <tr valign="baseline">
               <th nowrap align="right">Issue Comments:</th>
              <td>
     	   <textarea name="issue_comments" rows="3" cols="27"></textarea>
             </tr>
		 <tr valign="baseline">
               <td nowrap align="right"> </td>
               <td><input type="submit" value="Insert record"></td>
             </tr>
           </table>
           <input type="hidden" name="MM_insert" value="form1">
         </form>
	 <a href="vehicle_list.php">Cancel</a>
         <p> </p>
       </section>
  <!-- end .content --></h2>
    </section>
<?php
// The message
$message = "Vehicle Was Added To Database";

// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);

// Send
mail('[email protected], 'Vehicle update', $message);
?>
</body>
</html>

 

I got the mail code from http://php.net/manual/en/function.mail.php

 

Greatly appreciate all advice.

Most likely because your e-mail is being blocked by your provider as spam, due to missing headers and stuff. I recommend using a helper class/library for this, like PHPmailer. Will help you send a proper e-mail address without having to study the RFC and mail headers in detail.

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.