-2

I'm doing my first steps into MySQL and I'm a bit confused. I'm trying to make a simple database to fill with my contacts. Each contact will have a few NOT NULL fields (name, email, and so on) and a few NULL ones.

I created the database and the table with all the fields I needed. Now I need to create a webpage with a simple form, where my friends can compile said form with their info, filling the database directly.

The two most important things are: - You can't submit your data if the email is already recorded (so that no double will be created, since names can be identical) - It needs a "i'm not a robot" thingy to avoid bots to fill it out.

Does anyone know a good tutorial I could follow? Or has a script I can customise that does that?

Thanks for the help

Mr_Bober
  • 153
  • 6
  • Have you had a good google? Plenty of tutorials about databases – Ed Heal Jun 18 '17 at 18:35
  • 1
    Asking for tutorials or other off-site resources is off topic on SO. You need to read at least of the thousands of tutorials regarding PHP and MySQL, try something yourself and come back if you run into some _specific_ issue. Here on SO, we can help you with your existing code, but we won't write it for you. – M. Eriksson Jun 18 '17 at 18:40

1 Answers1

0

Good day Mr Bober, hope you're great! First, in order to create a page where you have a form and submit it, you need to know html/html5. It is simple, just create a body with a form and some form fields. Use also the post method in html, which is to be reflected in the PHP as $_POST.

First, use this approach:

-Create the html template with the form. -Apply the php with simple isset($_POST['submit']), where the submit event in html will trigger the php to run. - Pass to variables all the $_POST variables that are corresponding to the field inputs' names. - Make a query string with the input values saved in the variables. - Send the query with mysqli_query($connection, $query) function and remember to check if the query succeeded in order to display the proper message.

  • Another way to accomplish the unique email alert with PHP is to make a request to the server everytime the user blurs from the input of the email. A simple query to the db will be enough, such as: SELECT * FROM table_name WHERE email = "email@email.com".
  • A result will come back, may empty, maybe full. Take action depending on the result.

Lastly, the I am not a robot checkbox is just a plugin, you must implement it in the html and php code.

Here is a link to a tutorial where using Google CAPTCHAS is explained: https://www.codexworld.com/new-google-recaptcha-with-php/

If there is anything else bro, ask, but it is better that you grab a paper, draw the problem in it, describe it and make a task list of how you think are the steps to resolve it.

grillote33
  • 26
  • 1