Jump to content

VipulK

New Members
  • Posts

    2
  • Joined

  • Last visited

VipulK's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. @requinix The server is a VPS and I have full access. I suppose I have access to cron as well but I haven't used it before. @benanamen here's what I have so far $name = mysqli_real_escape_string($connect, $_POST['name']); $phone = mysqli_real_escape_string($connect, $_POST['phone']); $email = mysqli_real_escape_string($connect, $_POST['email']); $message = mysqli_real_escape_string($connect, $_POST['message']); $today = date('Y-m-d'); $time = date("g:i:s a"); $ip = $_SERVER['REMOTE_ADDR']; $source = $_SERVER['HTTP_REFERER']; if(isset($_POST['g-recaptcha-response'])){ //if form has captcha process it $url='https://www.google.com/recaptcha/api/siteverify'; $secret = 'RECAPTCHA_KEY'; $response = $_POST['g-recaptcha-response']; $verifyCaptcha = file_get_contents($url."?secret=".$secret."&response=".$response."&remoteip=".$ip); $captchaReply = json_decode($verifyCaptcha); if(isset($captchaReply->success) AND $captchaReply->success == true){ $validQuery = true; } else { $validQuery = false; } } else { $validQuery = true; } if($validQuery){ //ready to insert $lastId = mysqli_query($connect, "SELECT id, query_id FROM `queries` ORDER BY `id` DESC LIMIT 1"); $lastId = mysqli_fetch_assoc($lastId); //generate a unique id for this query $explode = explode('-', $lastId['query_id']); $splitNumber = str_split($explode[0], 2); $yearNumber = $splitNumber[0]; $monthNumber = $splitNumber[1]; if($yearNumber == date('y')){ $queryID = $explode[1] + 1; }else{ $queryID = '0000'; } $queryID = str_pad($queryID, 4, "0", STR_PAD_LEFT); $queryID = date('ym').'-'.$queryID; //insert query $insertQuery = "INSERT INTO queries (query_id, `name`, `phone`, `email`, `project_details`, `date_of_query`, `ip`, `source`, location) VALUES ('".$queryID."', '".$name."', '".$phone."', '".$email."', '".$message."', '".$today."', '".$ip."', '1', '".$source."')"; $insert = mysqli_query($connect, $insertQuery); if($insert){ header('Location: thanks.php'); exit(); } else { echo "Query failed. ".mysqli_error($connect); } } else { echo 'Captcha verification Failed. Please try again.'; } I'm not asking for someone to code it for me or a ready-made solution. I'm asking for concept ideas to go ahead for it.
  2. I have a client whose website sent the contents of a contact form to their email but for some reason the mail sending took 20-25 seconds to process which was bad for user experience. I did very thorough investigation and the hosting provider also looked into it but couldn't find anything out of the blue. It seems the only solution would be to change the servers completely which is not possible at the moment. Anyways, to reduce this time, I instead routed the contact form data to a database (MySQL) instead and created a CRM sort of panel for him to view all the submissions he has received from the contact form. Now, that's all fine but the client the other day told me if he could get a mail as well, so he gets notified when a new query has come from the contact page. If I add the mail() function back in there, the whole point of database will be moot since it'll take even longer this time because now I'll have to add to database and send email too. But it seems having a notification is important to the client. So I was wondering If it would be possible to add data to the database and show thank you page to the website user instantly, but send the email in the background? Or maybe schedule the mail sending at a later time which doesn't require any input from the user? The traffic on the site isn't much so performance is not that high on the priority list. Any ideas would be greatly helpful.
×
×
  • 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.