lundi 1 avril 2019

php not writing to database

Php isn't writing to my database, and it doesnt show any errors. Any help with fixing php to write into my database? Thanks!

<label for="name">Full Name:</label>
<input type="text" id="name" name="name" placeholder="Your name..">
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Your username.." maxlength="15">
<label for="email">Email:</label>
<input type="email" id="email" name="email" placeholder="Your email..">
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Your password..">

PHP:
<?php
session_start();

$con = mysqli_connect('localhost', 'root', 'Acer2002!');

mysqli_select_db($con, 'register');

$name = $_POST['name'];
$user = $_POST['username'];
$email = $_POST['email'];
$pass = $_POST['password'];

$s = " select * from account where name = '$name'";
$result = mysqli_query($con, $s);

$num = mysqli_num_rows($result);
if($num == 1){
    echo "username already taken";
} else{
    $reg = " INSERT INTO account(name, username, email, password) VALUES ('$name', '$user', '$email', '$pass')";
    mysqli_query($con, $reg);
    echo "You have made an account!";
}
?>

IGNORE: I needed more detail but i dont know what else to add




Aucun commentaire:

Enregistrer un commentaire