fife Posted February 15, 2011 Share Posted February 15, 2011 Sorry I wouldn't know what to call this question. Right I have this query if(isset($_POST['insert_club'])){ //Process data for validation $name = trim($_POST['name']); $cat = trim($_POST['cat']); $memberID = trim($_POST['memberID']); $validationID = trim($_POST['validationID']); $creation_date = trim($_POST['CreationDate']); $new_cat = trim($_POST['newCat']); //perform validations $errors = array(); if(empty($name)) { $errors[] = "Please enter a name for your club"; } //Check if there were errors if(count($errors)===0) { // Prepare data for db insertion $name = mysql_real_escape_string($name); $cat = mysql_real_escape_string($cat); $memberID = mysql_real_escape_string($memberID); $validationID = mysql_real_escape_string($validationID); $creation_date = mysql_real_escape_string($creation_date); //post the details of the new category to me $query = "INSERT INTO clubs (`name`, `cat`, `memberID`, `validationID`, `CreationDate` ) VALUES ('$name', '$cat', '$memberID', '$validationID', '$creation_date' )"; $result= mysql_query($query) or die(mysql_error()); $url = "address.php?new_club=$validationID"; header("Location: $url"); }} It works great. Within that query there is a unused post $new_cat = trim($_POST['newCat']); Now I dont ever want this field entered into the database. Firstly. If its empty then I want nothing to happen with it but, if the user has entered something into the field then I want the contents of the field emailed to an address without effecting the rest of the query. Is this possible? I have written it so many different ways now and none of them seem to work. Link to comment https://forums.phpfreaks.com/topic/227751-help/ Share on other sites More sharing options...
zenlord Posted February 15, 2011 Share Posted February 15, 2011 Between these lines: $result = ... $url = ... You just add a new check: if ($newCat !="") { mail($to, $subject, "Cat has been changed to $newCat"); } More info on mail: http://be.php.net/manual/en/function.mail.php Vincent Link to comment https://forums.phpfreaks.com/topic/227751-help/#findComment-1174527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.