I have been trying to make this work for a very long time. I’m attempting to create a system where users can sign up, but I don’t know why my code fails to execute.
here it is:
<?php
function signUpDone() {
header('Location: https://localhost/fanthomchat/email_verif');
}
if (isset($_POST['submit'])) {
$con=mysqli_connect("localhost","root","password");
mysqli_select_db($con,"signups");
$username= $_POST['username'];
$password= $_POST['password'];
$email= $_POST['email'];
$sqli = "SELECT ID FROM `signups` WHERE username='$username' OR email='$email'";
$queryResult = mysqli_query($con,$sqli);
$result = mysqli_num_rows($queryResult);
if ($result < 1) {
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@!#$%^&*(()_+-={}|[]\?/~)';
$result = '';
for ($i = 0; $i < 10; $i++)
$result .= $characters[mt_rand(0, 61)];
$query ="insert into signups (username,password,email,confirmed,confirmPass,userpage,userpageAft) values ('$username','$password','$email','false','$result','/$username','/$username/index.php')";
if (mysqli_query ($con,$query)) {
$sqli2 = "SELECT confirmPass FROM signups WHERE username='$uname'";
$confirmPass = mysqli_query($con,$sqli2)->fetch_object()->confirmPass;
$to = "$email";
$subject = "fanthom-chat confirmation email";
$msg = "Your fanthom-chat.com confirmation code:\n$confirmPass";
$headers = "From: [email protected]" . "\r\n" .
mail ($to,$subject,$msg,$headers);
SignUpDone();
}
}