i have an enquiry email form which sends an email to peeps is it poss that every time an email is sent it adds a record to database increment by 1 each time <strong>Enquire about this holiday caravan:</strong> <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'){ $me = $_SERVER['PHP_SELF']; ?> </div> <form name="form1" method="post" action="<?php echo $me;?>"> <table width="600" border="0" cellspacing="0" cellpadding="2" align="center"> <tr> <td align="left"><span>Name:</span></td> <td align="left"><input type="text" name="Name"></td> </tr> <tr> <td align="left"><span>Telephone Number:</span></td> <td align="left"><input type="text" name="TelNo"></td> </tr> <tr> <td align="left"><span>Email:</span></td> <td align="left"><input type="text" name="Email"></td> </tr> <tr> <td align="left" valign="top"><span>Enquiry:</span></td> <td align="left"><textarea name="MsgBody" cols="30" rows="5"></textarea></td> </tr> <tr> <td align="left"><input type=hidden name=id value=<?echo $id ?>> <input type="submit" name="Submit" value="Send"></td> </tr> </table> </form> <?php } else { $id = $_POST['id']; $name = $_POST['Name']; $tele = $_POST['TelNo']; $fromemail = $_POST['Email']; $enquiry = $_POST['MsgBody']; error_reporting(0); mysql_connect("6", "c", "3") or die(mysql_error()) ; mysql_select_db("c") or die(mysql_error()) ; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM members WHERE username='$id'") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { $tomail = $info['email']; } $admin = "caravan.exchange@googlemail.com"; $recipient = $tomail; $subject = 'Caravan Hire'; $from = stripslashes($_POST['Name']); $telno = stripslashes($_POST['TelNo']); $email = stripslashes($_POST['Email']); $message = stripslashes($_POST['MsgBody']); $msg = "Message from: $from\n\nTelephone Number: $telno\n\nEmail: $email\n\nUsers Message:\n\n $message\n\n"; mail($recipient, $subject, $msg) ; mail($admin, $subject, $msg) ; if (mail($recipient, $subject, $msg)) { Header("Location: thanks.php"); exit(); } else echo "An unknown error occurred."; } ?> </tr> </table> </form> PHP: thanks Doug
if (mail($recipient, $subject, $msg)) { //Add your mysql_query() HERE Header("Location: thanks.php"); exit(); } PHP: If you need the SQL statement, give me more details about you DB