Jump to content

ianhaney50

Members
  • Posts

    261
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ianhaney50

  1. Ahh ok if I take that out, is is still possible to have the alert box appear to let the visitor know their info has been added to the database?
  2. That's it, is what I thought na just double checked Below is the php coding I have <?php if(isset($_POST["submit"])){ $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // escape variables for security $visitor_name = mysqli_real_escape_string($conn, $_POST['visitor_name']); $visitor_email = mysqli_real_escape_string($conn, $_POST['visitor_email']); $visitor_firstline = mysqli_real_escape_string($conn, $_POST['visitor_firstline']); $visitor_secondline = mysqli_real_escape_string($conn, $_POST['visitor_secondline']); $visitor_town = mysqli_real_escape_string($conn, $_POST['visitor_town']); $visitor_county = mysqli_real_escape_string($conn, $_POST['visitor_county']); $visitor_postcode = mysqli_real_escape_string($conn, $_POST['visitor_postcode']); $visitor_tel = mysqli_real_escape_string($conn, $_POST['visitor_tel']); $visitor_mobile = mysqli_real_escape_string($conn, $_POST['visitor_mobile']); $visitor_model = mysqli_real_escape_string($conn, $_POST['visitor_model']); $visitor_plate = mysqli_real_escape_string($conn, $_POST['visitor_plate']); $sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline,visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate) VALUES ('$visitor_name', '$visitor_email', '$visitor_firstline', '$visitor_secondline', '$visitor_town', '$visitor_county', '$visitor_postcode', '$visitor_tel', '$visitor_mobile', '$visitor_model', '$visitor_plate')"; $conn->query($sql); $visitor_id = $conn->insert_id; $insurance_date = date('Y-m-d', strtotime($_POST['visitor_insurance'])); $mot_date = date('Y-m-d', strtotime($_POST['visitor_mot'])); $tax_date = date('Y-m-d', strtotime($_POST['visitor_tax'])); $sql = "INSERT INTO renewal (visitor_id, item_id, renewal_date) VALUES ($visitor_id, 1, '$insurance_date'), ($visitor_id, 2, '$mot_date'), ($visitor_id, 3, '$tax_date')"; echo "<pre>$sql</pre>"; $conn->query($sql); if ($conn->query($sql) === TRUE) { echo "<script type= 'text/javascript'>alert('Your Information has been added successfully to our database');</script>"; } else { echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>"; } $conn->close(); } ?> I even checked my footer.php just to make sure
  3. Is what I thought the query is only being executed once $sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline,visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate) VALUES ('$visitor_name', '$visitor_email', '$visitor_firstline', '$visitor_secondline', '$visitor_town', '$visitor_county', '$visitor_postcode', '$visitor_tel', '$visitor_mobile', '$visitor_model', '$visitor_plate')"; $conn->query($sql); - would these lines affect it as is called here then bit further below $visitor_id = $conn->insert_id; $insurance_date = date('Y-m-d', strtotime($_POST['visitor_insurance'])); $mot_date = date('Y-m-d', strtotime($_POST['visitor_mot'])); $tax_date = date('Y-m-d', strtotime($_POST['visitor_tax'])); $sql = "INSERT INTO renewal (visitor_id, item_id, renewal_date) VALUES ($visitor_id, 1, '$insurance_date'), ($visitor_id, 2, '$mot_date'), ($visitor_id, 3, '$tax_date')"; echo "<pre>$sql</pre>"; $conn->query($sql); - same as the line bit further above Is weird cause the visitor table is ok and not being duplicated, is only the renewal table data being duplicated
  4. Is it right that it is duplicating the records in the renewal table, thought it would just do 3 rows for the visitor_id and not 6, I have attached a screen shot of what it is doing
  5. Sorry realised cause it had data in it so removed the data and is ok now, just going to do a test one again
  6. I wonder if that is why in the renewal table records are duplicated twice I tried making it AI and it comes up with incorrect table defination and only one column can be AUTO and it needs to be defined as a key and does not let me change it and then try and make it primary and says duplicate entry 0 for key primary
  7. Sorry yeah is outputting correctly on the page but in the database it is making the date appear as 0000-00-00 as can see in the screenshot
  8. No worries, done that and has added to the database and on the php page has outputted the following INSERT INTO renewal (visitor_id, item_id, renewal_date) VALUES(22, 1, '2015-06-25'),(22, 2, '2015-06-24'),(22, 3, '2015-06-23')
  9. Ok done that by changing the coding and added a new visitor and is still storing it as 0000-00-00 in the renewal_date column in the renewal table I got the following $insurance_date = date('Y-m-d', strtotime($_POST['visitor_insurance'])); $mot_date = date('Y-m-d', strtotime($_POST['visitor_mot'])); $tax_date = date('Y-m-d', strtotime($_POST['visitor_tax'])); AND <label>Car Tax Renewal Date :</label> <input type="text" id="datepicker" name="visitor_tax" required="required" placeholder="Please Enter your Car Tax Renewal Date"/> <br><br> <label>MOT Expiry Date :</label> <input type="text" id="datepicker2" name="visitor_mot" required="required" placeholder="Please Enter your MOT Expiry Date"/> <br><br> <label>Insurance Expiry Date :</label> <input type="text" id="datepicker3" name="visitor_insurance" required="required" placeholder="Please Enter your Insurance Expiry Date"/>
  10. Ok cool have changed the database to date_notified DATETIME DEFAULT NULL and the coding in the UPDATE sql query to SET date_notified = NOW() The dates I am entering is 23-06-2015 for the tax, 24-06-2015 for the mot and 25-06-2015 for the insurance The coding for them bits is below $insurance_date = mysqli_real_escape_string($conn, $_POST['renewal_date']); $mot_date = mysqli_real_escape_string($conn, $_POST['renewal_date']); $tax_date = mysqli_real_escape_string($conn, $_POST['renewal_date']); AND $sql = "INSERT INTO renewal (visitor_id, item_id, renewal_date) VALUES ($visitor_id, 1, '$insurance_date'), ($visitor_id, 2, '$mot_date'), ($visitor_id, 3, '$tax_date')"; the coding for them bits in the form is below <label>Car Tax Renewal Date :</label> <input type="text" id="datepicker" name="renewal_date" required="required" placeholder="Please Enter your Car Tax Renewal Date"/> <br><br> <label>MOT Expiry Date :</label> <input type="text" id="datepicker2" name="renewal_date" required="required" placeholder="Please Enter your MOT Expiry Date"/> <br><br> <label>Insurance Expiry Date :</label> <input type="text" id="datepicker3" name="renewal_date" required="required" placeholder="Please Enter your Insurance Expiry Date"/>
  11. Hi Barand Sorry being a pain I know It is adding into the database now and the visitor info if being added ok along with the data in the renewal table but in the renewal table, it is adding 3 rows to it and the renewal date column is being displayed as 0000-00-00 and the data notified column is posting the current time an date? see the screenshot attached
  12. I have changed the coding now to the following as realised I messed up the sql query coding <?php if(isset($_POST["submit"])){ $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // escape variables for security $visitor_name = mysqli_real_escape_string($conn, $_POST['visitor_name']); $visitor_email = mysqli_real_escape_string($conn, $_POST['visitor_email']); $visitor_firstline = mysqli_real_escape_string($conn, $_POST['visitor_firstline']); $visitor_secondline = mysqli_real_escape_string($conn, $_POST['visitor_secondline']); $visitor_town = mysqli_real_escape_string($conn, $_POST['visitor_town']); $visitor_county = mysqli_real_escape_string($conn, $_POST['visitor_county']); $visitor_postcode = mysqli_real_escape_string($conn, $_POST['visitor_postcode']); $visitor_tel = mysqli_real_escape_string($conn, $_POST['visitor_tel']); $visitor_mobile = mysqli_real_escape_string($conn, $_POST['visitor_mobile']); $visitor_model = mysqli_real_escape_string($conn, $_POST['visitor_model']); $visitor_plate = mysqli_real_escape_string($conn, $_POST['visitor_plate']); $description = mysqli_real_escape_string($conn, $_POST['description']); $visitor_id = mysqli_real_escape_string($conn, $_POST['visitor_id']); $insurance_date = mysqli_real_escape_string($conn, $_POST['insurance_date']); $mot_date = mysqli_real_escape_string($conn, $_POST['mot_date']); $tax_date = mysqli_real_escape_string($conn, $_POST['tax_date']); $item_id = '$item_id'; if( isset( $_POST['item_id'])) { $item_id = $_POST['item_id']; } /*if(isset($_POST['item_id'])){ $item_id = $_POST['item_id']; }*/ $sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline,visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate) VALUES ('$visitor_name', '$visitor_email', '$visitor_firstline', '$visitor_secondline', '$visitor_town', '$visitor_county', '$visitor_postcode', '$visitor_tel', '$visitor_mobile', '$visitor_model', '$visitor_plate'); INSERT INTO item (item_id, description) VALUES ('$item_id', '$description'); INSERT INTO renewal (visitor_id, item_id, renewal_date) VALUES ($visitor_id, 1, '$insurance_date'), ($visitor_id, 2, '$mot_date'), ($visitor_id, 3, '$tax_date')"; /*$sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline, visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate, visitor_tax, visitor_mot, visitor_insurance) VALUES ('".$_POST["visitor_name"]."','".$_POST["visitor_email"]."','".$_POST["visitor_firstline"]."', '".$_POST["visitor_secondline"]."', '".$_POST["visitor_town"]."','".$_POST["visitor_county"]."','".$_POST["visitor_postcode"]."','".$_POST["visitor_tel"]."','".$_POST["visitor_mobile"]."','".$_POST["visitor_model"]."','".$_POST["visitor_plate"]."','".$_POST["visitor_tax"]."','".$_POST["visitor_mot"]."','".$_POST["visitor_insurance"]."')";*/ /*echo $sql;*/ if ($conn->query($sql) === TRUE) { echo "<script type= 'text/javascript'>alert('Your Information has been added successfully to our database');</script>"; } else { echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>"; } $conn->close(); } ?> I am just getting the following errors now Notice: Undefined index: description in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/information-form.php on line 101 Notice: Undefined index: visitor_id in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/information-form.php on line 103 Notice: Undefined index: insurance_date in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/information-form.php on line 104 Notice: Undefined index: mot_date in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/information-form.php on line 105 Notice: Undefined index: tax_date in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/information-form.php on line 106 Sorry
  13. Think I sorted the undefined index issue but the form is not adding no data to the database, below is my coding <?php if(isset($_POST["submit"])){ $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $visitor_name = ''; $visitor_email = ''; $visitor_firstline = ''; $visitor_secondline = ''; $visitor_town = ''; $visitor_county = ''; $visitor_postcode = ''; $visitor_tel = ''; $visitor_mobile = ''; $visitor_model = ''; $visitor_plate = ''; $item_id = ''; if( isset( $_POST['item_id'])) { $item_id = $_POST['item_id']; } /*if(isset($_POST['item_id'])){ $item_id = $_POST['item_id']; }*/ $description = ''; $newId = ''; $insurance_date = ''; $mot_date = ''; $tax_date = ''; $sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline,visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate) VALUES (mysqli_real_escape_string($visitor_name), mysqli_real_escape_string($visitor_email), mysqli_real_escape_string($visitor_firstline), mysqli_real_escape_string($visitor_secondline), mysqli_real_escape_string($visitor_town), mysqli_real_escape_string($visitor_county), mysqli_real_escape_string($visitor_postcode), mysqli_real_escape_string($visitor_tel), mysqli_real_escape_string($visitor_mobile), mysqli_real_escape_string($visitor_model), mysqli_real_escape_string($visitor_plate); INSERT INTO item (item_id, description) VALUES (mysqli_real_escape_string($item_id), mysqli_real_escape_string($description); INSERT INTO renewals (visitor_id, item_id, renewal_date) VALUES ($newId, 1, '$insurance_date'), ($newId, 2, '$mot_date'), ($newId, 3, '$tax_date')))"; /*$sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline, visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate, visitor_tax, visitor_mot, visitor_insurance) VALUES ('".$_POST["visitor_name"]."','".$_POST["visitor_email"]."','".$_POST["visitor_firstline"]."', '".$_POST["visitor_secondline"]."', '".$_POST["visitor_town"]."','".$_POST["visitor_county"]."','".$_POST["visitor_postcode"]."','".$_POST["visitor_tel"]."','".$_POST["visitor_mobile"]."','".$_POST["visitor_model"]."','".$_POST["visitor_plate"]."','".$_POST["visitor_tax"]."','".$_POST["visitor_mot"]."','".$_POST["visitor_insurance"]."')";*/ if ($conn->query($sql) === TRUE) { echo "<script type= 'text/javascript'>alert('Your Information has been added successfully to our database');</script>"; } else { echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>"; } $conn->close(); } ?> Sorry about this, am trying to work it out myself, thought it would of thrown up a error message if anything wrong with the coding etc.
  14. Sort of getting there, got rid of most of the errors such as undefined variable the last one I got is below Notice: Undefined index: item_id in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/information-form.php on line 111 on line 111 is the following ('".$_POST["item_id"]."',mysqli_real_escape_string($description)); So far the whole coding looks like the following <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php $title = "Information Form - The Tax Elephants"; $pgDesc=""; $pgKeywords=""; include ( 'includes/header.php' ); ?> <!--CONTENT--> <div id="column-left"> <div class="form"> <form action="" method="post"> <label>Name :</label> <input type="text" name="visitor_name" required="required" placeholder="Please Enter Name"/> <br /><br /> <label>Email :</label> <input type="email" name="visitor_email" required="required" placeholder="john123@gmail.com"/> <br/><br /> <label>Address Line 1 :</label> <input type="text" name="visitor_firstline" required="required" placeholder="Please Enter First Line of your address"/> <br><br> <label>Address Line 2 :</label> <input type="text" name="visitor_secondline" required="required" placeholder="Please Enter Second Line of your address"/> <br><br> <label>Town :</label> <input type="text" name="visitor_town" required="required" placeholder="Please Enter your Town"/> <br><br> <label>County :</label> <input type="text" name="visitor_county" required="required" placeholder="Please Enter Your County"/> <br/><br /> <label>Postcode :</label> <input type="text" name="visitor_postcode" required="required" placeholder="Please Enter Your Postcode"/> <br><br> <label>Telephone Number :</label> <input type="text" name="visitor_tel" required="required" placeholder="Please Enter Your Telephone Number"/> <br><br> <label>Mobile Number :</label> <input type="text" name="visitor_mobile" required="required" placeholder="Please Enter Your Mobile Number"/> <br><br> <label>Model of Car/Van :</label> <input type="text" name="visitor_model" required="required" placeholder="Please Enter the Model of your Car or Van"/> <br><br> <label>License Plate Number :</label> <input type="text" name="visitor_plate" required="required" placeholder="Please Enter your License Number Plate"/> <br><br> <label>Car Tax Renewal Date :</label> <input type="text" id="datepicker" name="visitor_tax" required="required" placeholder="Please Enter your Car Tax Renewal Date"/> <br><br> <label>MOT Expiry Date :</label> <input type="text" id="datepicker2" name="visitor_mot" required="required" placeholder="Please Enter your MOT Expiry Date"/> <br><br> <label>Insurance Expiry Date :</label> <input type="text" id="datepicker3" name="visitor_insurance" required="required" placeholder="Please Enter your Insurance Expiry Date"/> <br><br> <input type="submit" value=" Submit " name="submit"/> </form> </div> </div> <div id="column-right"> </div> <!--CONTENT--> <?php if(isset($_POST["submit"])){ $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $visitor_name = ''; $visitor_email = ''; $visitor_firstline = ''; $visitor_secondline = ''; $visitor_town = ''; $visitor_county = ''; $visitor_postcode = ''; $visitor_tel = ''; $visitor_mobile = ''; $visitor_model = ''; $visitor_plate = ''; $newId = ''; $description = ''; $insurance_date = ''; $mot_date = ''; $tax_date = ''; $sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline,visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate) VALUES (mysqli_real_escape_string($visitor_name), mysqli_real_escape_string($visitor_email), mysqli_real_escape_string($visitor_firstline), mysqli_real_escape_string($visitor_secondline), mysqli_real_escape_string($visitor_town), mysqli_real_escape_string($visitor_county), mysqli_real_escape_string($visitor_postcode), mysqli_real_escape_string($visitor_tel), mysqli_real_escape_string($visitor_mobile), mysqli_real_escape_string($visitor_model), mysqli_real_escape_string($visitor_plate); INSERT INTO item (item_id, description) VALUES ('".$_POST["item_id"]."',mysqli_real_escape_string($description)); INSERT INTO renewals (visitor_id, item_id, renewal_date) VALUES ($newId, 1, '$insurance_date'), ($newId, 2, '$mot_date'), ($newId, 3, '$tax_date')"; /*$sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline, visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate, visitor_tax, visitor_mot, visitor_insurance) VALUES ('".$_POST["visitor_name"]."','".$_POST["visitor_email"]."','".$_POST["visitor_firstline"]."', '".$_POST["visitor_secondline"]."', '".$_POST["visitor_town"]."','".$_POST["visitor_county"]."','".$_POST["visitor_postcode"]."','".$_POST["visitor_tel"]."','".$_POST["visitor_mobile"]."','".$_POST["visitor_model"]."','".$_POST["visitor_plate"]."','".$_POST["visitor_tax"]."','".$_POST["visitor_mot"]."','".$_POST["visitor_insurance"]."')";*/ if ($conn->query($sql) === TRUE) { echo "<script type= 'text/javascript'>alert('Your Information has been added successfully to our database');</script>"; } else { echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>"; } $conn->close(); } ?> <?php include( 'includes/footer.php' ); ?>
  15. I know it's wrong as got loads of issues on the php page after submitting the form http://www.broadwaymediadesigns.co.uk/sites/the-tax-elephants/information-form.php
  16. Is the following right? $newId = $mysqli->insert_id; $sql = "INSERT INTO visitors (visitor_name, visitor_email, visitor_firstline, visitor_secondline,visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate) VALUES ('".mysqli_real_escape_string($visitor_name)."','".mysqli_real_escape_string($visitor_email)."','".mysqli_real_escape_string($visitor_firstline)."', '".mysqli_real_escape_string($visitor_secondline)."', '".mysqli_real_escape_string($visitor_town)."','".mysqli_real_escape_string($visitor_county)."','".mysqli_real_escape_string($visitor_postcode)."','".mysqli_real_escape_string($visitor_tel)."','".mysqli_real_escape_string($visitor_mobile)."','".mysqli_real_escape_string($visitor_model)."','".mysqli_real_escape_string($visitor_plate)."')"; "INSERT INTO item (item_id, description) VALUES ('".$_POST["item_id"]."','".mysqli_real_escape_string($description)."')"; "INSERT INTO renewals (visitor_id, item_id, renewal_date) VALUES ($newId, 1, '$insurance_date'), ($newId, 2, '$mot_date'), ($newId, 3, '$tax_date')";
  17. don't think I have done this right $newId = $mysqli->insert_id; $sql = "INSERT INTO visitors (visitor_id, visitor_name, visitor_email, visitor_firstline, visitor_secondline,visitor_town, visitor_county, visitor_postcode, visitor_tel, visitor_mobile, visitor_model, visitor_plate) VALUES ('".$_POST["$newId"]."','".$_POST["visitor_name"]."','".$_POST["visitor_email"]."','".$_POST["visitor_firstline"]."', '".$_POST["visitor_secondline"]."', '".$_POST["visitor_town"]."','".$_POST["visitor_county"]."','".$_POST["visitor_postcode"]."','".$_POST["visitor_tel"]."','".$_POST["visitor_mobile"]."','".$_POST["visitor_model"]."','".$_POST["visitor_plate"]."')"; "INSERT INTO item (item_id, description) VALUES ('".$_POST["1"]."','".$_POST["description"]."')"; "INSERT INTO renewals (visitor_id, item_id, renewal_date) VALUES ($newId, 1, '$insurance_date'), ($newId, 2, '$mot_date'), ($newId, 3, '$tax_date')"; or do I just put it as exactly as you have above $newId = $mysqli->insert_id; INSERT INTO renewals (visitor_id, item_id, renewal_date) VALUES ($newId, 1, '$insurance_date'), ($newId, 2, '$mot_date'), ($newId, 3, '$tax_date'); Sorry
  18. Ok so if was to use one PHP form, is it possible to add the data into the visitors table such as their personal info then add the data such as the dates to the renewals table using the one PHP form?
  19. Ahh ok sorry got it, makes sense when you lay it out like you have just above, sorry So that side of it is ok with the database set up correctly and the SELECT coding, just need to alter the INSERT coding which I just use muliple sql queries like the following $sql1 $sql2 $sql3 That right as think I got that bit sussed? well hopefully or just thought use one query but seperate the INSERT part by using ; at the end of the INSERT so bit like the following INSERT INTO tbl(field, field) VALUES(val, val); INSERT INTO tbl2(field2, field2) VALUES(val2, val2); INSERT INTO tbl3(field3, field3) VALUES(val3, val3); Would that work?
  20. Sorry have forgot to attach the screenshots, I have attached them to this post
  21. Think I got it right, I have attached screenshots of my database table structure for the 3 tables, hopefully I got it right but got a feeling I don't need the visitor_id, item_id and renewal_id in the renewal table as the coding looks like they are joining the columns together, is that right? thought would confirm before I delete any columns in any of the tables The coding as well I got is below $sqlCommand = "SELECT v.visitor_id , visitor_name , visitor_email , visitor_model , visitor_plate , item.description , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue FROM visitors v INNER JOIN renewal USING (visitor_id) INNER JOIN item USING (item_id) WHERE renewal_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY AND date_notified < CURDATE()-INTERVAL 14 DAY;"; Hopefully is correct or am close
  22. Hi Barnard So sorry for my late reply, been out all day and just got back Ok cool got it, will adjust the database now and then do the coding and report back if ok
  23. Sorry my mistake, I just got the email, is just late in being delivered
  24. I noticed as well this morning, I have refreshed the page and the date_last_modified column has updated to todays date and the time at 10:17 but I have not received any email I adjusted the coding to be from 7 DAY to 14 DAY, don't think that would affect it as am I right in saying the code takes today's date and shows any expiry dates within 14 days from today's date Is that right? The coding is below for the INTERVAL etc. $sqlCommand = "SELECT visitor_id, visitor_name, visitor_email, visitor_model, visitor_plate, visitor_tax, visitor_mot, visitor_insurance , IF(visitor_tax BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY, DATE_FORMAT(visitor_tax, '%e %M %Y') , 'n/a') as taxdate , IF(visitor_mot BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY, DATE_FORMAT(visitor_mot, '%e %M %Y') , 'n/a') as motdate , IF(visitor_insurance BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY, DATE_FORMAT(visitor_insurance, '%e %M %Y') , 'n/a') as vidate FROM visitors WHERE visitor_tax BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY OR visitor_mot BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY OR visitor_insurance BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY"; The email script coding is below $from = "noreply@irhwebsites.co.uk"; $to = "{$row['visitor_email']}"; $subject = "{$row['visitor_name']} Expiry Date(s)"; $message = "Name: {$row['visitor_name']} \n Car Tax Expiry Date: {$row['taxdate']} \n Car MOT Expiry Date: {$row['motdate']} \n Insurance Expiry Date: {$row['vidate']}"; $headers = "From:" . $from; $sendmail = mail($to,$subject,$message, $headers); echo "Email Successfully Sent"; if($sendmail){ $sqlCommand2 = "UPDATE visitors SET date_last_modified = NULL WHERE visitor_id = " . $row['visitor_id']; $query2 = mysqli_query($db, $sqlCommand2) or die (mysqli_error($db)); } else { echo "do nothing"; }
×
×
  • 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.