Jump to content

Dilip

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by Dilip

  1. Hi, thanks. I am learning this slowly. Hope to improve.
  2. It worked this time. I don't know what was wrong. I added a row using phpMyAdmin, copy pasted the query from phpMyAdmin and replaced it with the $name and so on. It was exactly the same, but it worked this time.
  3. Hi, I am using XAMPP and trying to put up a simple form. The index.php is <form action='connect.php' method="POST"> <label for="user">Name: </label> <input type='text' name='name' id="name" required/> <br><br> <label for="email">Email: </label> <input type='email' name='email' id="email" required/> <br><br> <label for="phone">Phone: </label> <input type='text' name='phone' id="phone" required/> <br><br> <input type='submit' name='submit' id='submit' /> </form> The connect.php is <?php if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit'])) { echo 'submit button clicked'; $conn= mysqli_connect('localhost', 'root', '', 'my_software') or die("Connection Failed:" .mysqli_connect_error()); echo 'no connection error'; if(isset($_POST['name']) && isset($_POST['email']) && isset($_POST['phone'])) { $name= $_POST['name']; $email= $_POST['email']; $phone= $_POST['phone']; echo 'Upto SQL'; $sql= "INSERT INTO 'user' ('name', 'email', 'phone') VALUES ('$name', '$email', '$phone')"; echo 'SQL Run'; $query = mysqli_query($conn,$sql); echo 'query run'; if($query) { echo 'Entry Successful'; } else { echo 'Error, Entry Failed'; } } } ?> There was no addition to the database. So I used echo to find what or where it is going wrong. It prints up to " SQL Run ". But still, no input to the database I created using phpMyAdmin or any error message indicating where I am doing it all wrong. Any help would be great.
  4. Hi, I have a working contact form with CAPTCHA now. Please see the code below contact.php is <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Contact Us</title> <!--Load reCAPTCHA API --> <script src="https://www.google.com/recaptcha/api.js" async defer></script> </head> <body> <form method="post"> <!-- Form --> <input type="text" name="name" value="Name"/> <input type="email" name="email" value="[email protected]"/> <input type="text" name="message" value="Your Message"/> <!-- CAPTCHA --> <div class="g-recaptcha" data-sitekey="SITEKEY"></div> <input type="submit" name="submit" value="Go!"/> </form> <?php //Process form on submit if (isset($_POST['submit'])) { require "process.php"; } ?> </body> </html> process.php is <?php // Verify CAPTCHA $error = ""; $secret = "SECRET KEY"; $url = "https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=".$_POST['g-recaptcha-response']; $verify = json_decode(file_get_contents($url)); // Send email if all is good if($verify->success) { $to = "[email protected]"; $subject = "Contact Form Submission"; $body = ""; foreach ($_POST as $k=>$v) { if ($k != "g-recaptcha-response") { $body .= "$k : $v\r\n"; } } if (!mail($to, $subject, $body)) { $error = " Failed to send email"; } } else { $error = "Invalid CAPTCHA"; } // Output result echo $error=="" ? "OK" : $error; ?> Sadly, there is no error displayed when someone skips CAPTCHA. The kind of people I am expecting might most likely won't know that they should click the " I am not a robot " box. It would be nice if someone could help me add the same. Thanks.
  5. It needs Composer though, right?
  6. Hi, thanks I do remember seeing a video which talks about using reCAPTCHA in contact.php. Will try to find it again. Also, I am using Namecheap shared hosting. Is it possible to use phpMailer or SwiftMailer while using shared hosting?
  7. Hi, I am trying to set up a Contact form. It is a simple contact form that fetches basic details like name, email, phone no, and message and emails it to a preset ID. This is what I have at the moment for contact.php from the contact form that uses <form action="contact.php" method="post"> <?php // Check if the form has been submitted if (isset($_POST['submit'])) { // Get the form data $name = $_POST['full_name']; $email = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; // Send an email to the contact email address $to_email = '[email protected]'; $subject = 'New Contact Form Submission'; $body = 'From: ' . $name . "\n" . 'Email: ' . $email . "\n" . 'Phone: ' . $phone . "\n" . 'Message: ' . $message; mail($to_email, $subject, $body); // Redirect the user to the thank you page header('Location: thank-you.html'); } ?> It works, but I am worried about spammers and bad actors who might flood the form. How can I add measures to stop flooding and other critical spam actions? It would be great if someone could help me find a safe tutorial on the same or give me some pointers. Thanks.
  8. Helo, I am new here. I have a simple " Like " plugin for Vanilla Forums which does it work nicely. Sadly, it won't sent notifications when someone likes our post. I have another plugin from the same author which gives notifications on Profile-Like aka Kick/Poke. I am trying to use the notification part of the Kick plugin ( which I modified at my best to " Like ") added to the " Like " plugin so that I will able to provide notifications to post-authors on receiving a " Like ". I have created a GitHub repo with my attempt so far. It would be nice if someone can help me find a final solution. Thanks https://github.com/meetdilip/Like
×
×
  • 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.