Register code or script for 6607

02/27/2021 00:47 HeartlessBoiYang#16
It is cq but what I put here is just a sample.


Quote:
Originally Posted by denominator View Post
So the name of your database is database? Not cq, tq or something similar
02/27/2021 01:31 denominator#17
Ahh okay, why not find another webpage and edit it?
02/27/2021 12:23 turk55#18
Quote:
Originally Posted by pintinho12 View Post
I bet he can read documentations, which will (must) be easier than setup a website from scratch.
He can also google how to use those functions but that is already too hard.
02/27/2021 17:39 bashondegek#19
Quote:
Originally Posted by HeartlessBoiYang View Post
you got it wrong. I mean i got the website everything to work, but then for the register, I can't make it to connect to the database, like after click submit/create account. It wont go into the database, all it appear is username, password. it won't appear actual username and password that you filled in. That's why I'm asking if i did something wrong or code it wrong.
Then try to change this
Code:
 $sql = "INSERT INTO `accounts` (`Username`, `Password`) VALUES ('$username', '$pass')";
To
Code:
$sql = "INSERT INTO `accounts` (`Username`, `Password`) VALUES ('{$username}', '{$pass}')";
If its just adding plain text values into your database its definitely something with the values you insert in your database.

If this ain’t working, you will need to debug it, we really can’t help you any better then this, php documentations will definitely help you.
02/28/2021 22:15 HeartlessBoiYang#20
Okay thanks i got it to work on the php side, but then now is a new question.
How do I create a form for HTML and linked it with php. like instead ofhave a new page wit no background on the php side, I want it to be able to just successful registered on the html side.

Also i know there has to be with something like

<form method="post" action='register.php'>
user:
pass:
email:
</form>

Quote:
Originally Posted by HeartlessBoiYang View Post
Okay thanks i got it to work on the php side, but then now is a new question.
How do I create a form for HTML and linked it with php. like instead ofhave a new page wit no background on the php side, I want it to be able to just successful registered on the html side.
my html file for register page:



register php code:

and my .ja file, trying to make the submit form without redirect to a new tab(white page said Successfully registered!)


so please tell me if i did anything wrong here...
03/01/2021 08:42 bashondegek#21
Quote:
Originally Posted by HeartlessBoiYang View Post
Okay thanks i got it to work on the php side, but then now is a new question.
How do I create a form for HTML and linked it with php. like instead ofhave a new page wit no background on the php side, I want it to be able to just successful registered on the html side.

Also i know there has to be with something like

<form method="post" action='register.php'>
user:
pass:
email:
</form>



my html file for register page:



register php code:

and my .ja file, trying to make the submit form without redirect to a new tab(white page said Successfully registered!)


so please tell me if i did anything wrong here...
Seems like you are using Ajax there.
So you won't have to use the action="blabla.php" in your form.

you just have to catch the button click in your JS and let it go through the ajax file.

Use your browser built in inspector got to console and check what errors there are.



give your button a class or id or something.
so for example;
Code:
<button id="btnRegister">register now</button>
And in your JS do something like;

Code:
$("#btnRegister").on("click", function(){
 // code of ajax
});
03/01/2021 18:49 pintinho12#22
Quote:
Originally Posted by HeartlessBoiYang View Post
Okay thanks i got it to work on the php side, but then now is a new question.
How do I create a form for HTML and linked it with php. like instead ofhave a new page wit no background on the php side, I want it to be able to just successful registered on the html side.

Also i know there has to be with something like

<form method="post" action='register.php'>
user:
pass:
email:
</form>

my html file for register page:



register php code:

and my .ja file, trying to make the submit form without redirect to a new tab(white page said Successfully registered!)


so please tell me if i did anything wrong here...
Dude, trust me. You're sharing vulnerable code that you want to use on production. Learn how to use mysqli and prepared statements so at least lammers wont mysql inject your website.
03/01/2021 20:02 turk55#23
Quote:
Originally Posted by bashondegek View Post
Seems like you are using Ajax there.
So you won't have to use the action="blabla.php" in your form.
You can, I personally do. That way I don't have URLs hardcoded in my scripts (if it's not a SPA app).

Quote:
Originally Posted by bashondegek View Post
give your button a class or id or something.
so for example;
Code:
<button id="btnRegister">register now</button>
And in your JS do something like;

Code:
$("#btnRegister").on("click", function(){
 // code of ajax
});
I would personally add the submit on the form.
Code:
document.querySelector("#registerForm").addEventListener('submit', (e) =>{
  e.preventDefault();
  const submitUrl = e.currentTarget.getAttribute("action");
 // AJAX postcall here
});
This way you can re-use your JS without having to have it specific.
03/02/2021 00:15 bashondegek#24
Quote:
Originally Posted by turk55 View Post
You can, I personally do. That way I don't have URLs hardcoded in my scripts (if it's not a SPA app).



I would personally add the submit on the form.
Code:
document.querySelector("#registerForm").addEventListener('submit', (e) =>{
  e.preventDefault();
  const submitUrl = e.currentTarget.getAttribute("action");
 // AJAX postcall here
});
This way you can re-use your JS without having to have it specific.
Sure i won’t even do it like this myself since i’m using frameworks, most of it is already built in and its a fast way to set up secure websites if you know how it works..

Anyway i guess thats a bit to hard for him as he is not even able to make this basic register form working 😅. Just trying to help him out a little bit instead of making it harder for him to understand.
03/02/2021 06:44 HeartlessBoiYang#25
Well yeah, but I did make it work, just that it pop up a new window with no background etc. So now I need it to just stay in the same page. Hopefully u get what I mean. And yes, im still learning, better than not learning xD


Quote:
Originally Posted by bashondegek View Post
Sure i won’t even do it like this myself since i’m using frameworks, most of it is already built in and its a fast way to set up secure websites if you know how it works..

Anyway i guess thats a bit to hard for him as he is not even able to make this basic register form working 😅. Just trying to help him out a little bit instead of making it harder for him to understand.
03/02/2021 08:13 bashondegek#26
Quote:
Originally Posted by HeartlessBoiYang View Post
Well yeah, but I did make it work, just that it pop up a new window with no background etc. So now I need it to just stay in the same page. Hopefully u get what I mean. And yes, im still learning, better than not learning xD
I understand that, but what Turk and Pitinho are saying is true.
The code that i shared i just basic, it will work, but there are really better ways.

Anyway, it can stay in the same page using Ajax.

If you use the Code turk shared and put that in your JS, and change your button to something like this;
Code:
<button type="submit">Register now</button>
you are already doing a bit better.

Do you have any other problems? Or did you make it to work?
03/02/2021 23:24 pintinho12#27
[Only registered and activated users can see links. Click Here To Register...]

crappy but not so much
03/03/2021 00:13 turk55#28
Quote:
Originally Posted by pintinho12 View Post
[Only registered and activated users can see links. Click Here To Register...]

crappy but not so much
+

[Only registered and activated users can see links. Click Here To Register...]
03/07/2021 07:54 HeartlessBoiYang#29
Thanks so much for helping me everyone, very appreciates. Sorry for being a noob(which I am, lol) and an idiots who know nothing but trying hardest to learn xD. I figured I just need to change from .html to .php, since in some way my website work either .html or .php .