Codegamer Codegamer - 4 months ago 11
Javascript Question

account system w/ js, html & php

I need help to make a account system in php! It will create a new document for each user with some data in it, here is what I tried:

PHP:

//> Profile Creation <//
if($_CREATEPROFILE) {
$uname = $_CREATEPROFILE['uname'];
$pword = $_CREATEPROFILE['pword'];
$email = $_CREATEPROFILE['email'];

$path = 'profiles/' + $uname + ".txt";

if(file_exists('profiles/' + $uname)) {
//Run If Profile Already Created
echo("<script>cantCreate();</script>");
} else {
//Profile Creation
$handle = fopen("profiles/" + $uname,"a");

}
}

//> Profile Logging In <//
if($_LOGIN) {

}


HTML:

<form action="" method="CREATEPROFILE">
<input type="text" id="uname" name="uname" placeholder="Username">
<input type="text" id="pword" name="pword" placeholder="Password">
<input type="text" id="email" name="email" placeholder="EMail">

<center><div id="accountStatus-Signup" class="accountStatus-Signup">You Have Not Done A Account Scan Yet!</div></center>

<input type="submit" id="submit" name="submit" value="Sign Up">
</form>


Javascript:

<script>
function cantCreate() {
document.getElementById("accountStatus-Signup").innerHTML = "<h2 style=\"color: red;\">Sorry! But That Username Is Unadvaible!";
}
</script>


Please explain to me my errors! Thanks for helping me!

Answer

CREATEPROFILE is not a valid form method. I guess you are trying to use POST method. Do it instead, and catch data with $_POST[] global. To check if form was submitted do if(isset($_POST['uname'])) rather than if($_POST). That is your main problem. Although I recommend to do a couple of tutorials before trying to write something alone.

Comments