<?php
$con = mysqli_connect("localhost", "root", "") or die("Não foi possível conectar com o servidor de dados!");
mysqli_select_db($con, "reglog") or die("banco de dados nao localizado");
?>
Nothing at all? How far through your code does it get? Do you get any error messages?
(Also can you format the code so it’s readable please, use three back-ticks either side of the block of code or the </> button in the editor. Can’t read it at the moment to see what the issue might be.)
And have you added some debug “echo” statements through to code to see which lines of code it executes and where it stops? If you run the query from phpmyadmin with the same data, does it work?
Also here:
$query1 = mysqli_fetch_row(mysqli_query("SELECT * FROM reglog WHERE reglog = '$user'"));
if ($query1 == 1){
Where does $user come from? And do you have a column called reglog? You don’t populate that in your insert query. And why would the return from that query be 1? Surely it would be an array?
No you haven’t done any of those things, or no, you have tried but none of the echo statements appear? Or no, the query doesn’t work in phpmyadmin either?
To be frank, you need to be careful where you learn from as a beginner. This video is teaching some very bad coding habits, it is not up to modern standards and opens huge security holes.
OK, if you’re getting an error that says you haven’t filled in the fields, that will stop your queries working. Did you fix the typo (incorrect quotes) that I mentioned in post #4? That typo would alter the name of your password field, and mean that when you check the intended name, it will be empty.
Before you use this code anywhere, you appear to be storing plain-text passwords in your database - you really don’t want to do that. Use password_hash() to store them, and password_verify() to verify when the user is logging in.
So the result is that field is called “senha id”, and will produce `$_POST[‘senha id’]. That is, I think it will - I’ve never tried field names with a space in them.
I’d have expected a parse error unless you have a similar problem somewhere else to balance it out. Or is it a typo in the post, not in your actual code? Either way, you can var_dump($_POST) to see what you are receiving from the form when it is submitted.
No, @Gandalf means can you show us which line of your code is line 46? Highlight it in the original post, or post it separately.
But, I think I know which line it is, presumably you’ve now fixed it to read
if ($_GET['go'] == 'cadastrar'){
and this error means that you’re trying to access an array element called “go” which does not exist. You should read up on the isset() function to see how to get rid of it. I presume you get the error when you first open the page, not when you submit the form.
I must say the way you decide whether the form is submitted is rather strange, to my relatively inexperienced eyes at least. Most people look at whether the button is set, but the more recommended way these days seems to be
if ($_SERVER['REQUEST_METHOD'] == "POST") {
Normally I’d see that before you draw the form, rather than afterwards, unless the form handling code is in a separate file. It’s difficult to tell from the original post.
I don’t see why you are sending a form with both POST and GET variables, unless that’s needed somewhere else too.
Maybe I missed something but looking at your code you seem to be connecting to a database called reglog and updating a table called reglog. Is this correct or are you confusing the table and the database?