0

I create a registration system for a club. I already tested the system using localhost xampp before upload it to server. It functioning well. However when upload it to server. I cannot register as a new member. I can login, update and delete the data but cannot register. I already export the database to server database.

<?php

include_once("config.php");

//receive data
$name = $_POST['regname'];
$user_name = $_POST['regusername'];
$user_password = $_POST['regpassword'];
$user_email = $_POST['email'];
$user_gender = $_POST['ugender'];

$file = rand(1000,100000)."_".$_FILES['receipt']['name'];
$file_loc = $_FILES['receipt']['tmp_name'];
$file_size = $_FILES['receipt']['size'];
$file_type = $_FILES['receipt']['type'];
$folder = "../receipt/";

$new_file = $file_size/1024;
$new_file_name = strtolower($file);
$final_file = str_replace(' ','-',$new_file_name);
if (move_uploaded_file($file_loc,$folder. $final_file)) {
    echo"
        <script>
            alert('successfully uploaded');
        </script>
    ";
}
else {
    echo"
        <script>
            alert('Problem to upload');
        </script>";

}

$receipt = $final_file; //file name

//send to database

$result = mysqli_query($login, "INSERT INTO user(name,username,email,password,gender,receipt) VALUES('$name', '$user_name', '$user_email', '$user_password', '$user_gender', '$receipt')");
if ($result)
    echo"<script>
            alert('You have been registered. Please wait for admin approval before login.');
            window.location.href='../index.php';
        </script>";
else

echo "Problem to register";


?>

This is the form in html for user to fill the information needed for registration

<form id="register-form" action="register.php" method="POST" enctype="multipart/form-data" role="form" style="display: none;">
                                <div class="form-group">
                                    <input type="text" name="regname" id="regname" tabindex="1" class="form-control" placeholder="Name" required>
                                </div>
                                <div class="form-group">
                                    <input type="text" name="regusername" id="regusername" tabindex="1" class="form-control" placeholder="Username" required>
                                </div>
                                <div class="form-group">
                                    <input type="email" name="email" id="email" tabindex="1" class="form-control" placeholder="Email Address" required>
                                </div>
                                <div class="form-group">
                                    <input type="password" name="regpassword" id="regpassword" tabindex="2" class="form-control" placeholder="Password" required>
                                </div>
                                <div class="form-group">
                                    <label for="gender" >Gender:   </label>
                                        <input type="radio" name="ugender" value="Male"required>   Male 
                                        <input type="radio" name="ugender" value="Female"required> Female <br>
                                </div>
                                <div class="form-group">
                                    <label for="receipt">Payment Receipt: </label>
                                    <input type="file" name="receipt" id="receipt" tabindex="3" class="form-control" size="40" required>
                                </div>
                                <div class="form-group"> 
                                    <div class="row">
                                        <div class="col-sm-6 col-sm-offset-3">
                                            <input type="submit" name="register-submit" id="register-submit" tabindex="4" class="form-control btn btn-register" value="Register Now">
                                        </div>
                                        <div class="col-sm-6 col-sm-offset-3">
                                            <button type="button" onclick="back()" name="cancel" id="cancel" tabindex="5" class="form-control btn btn-register" >Cancel</button>
                                        </div>
                                    </div>
                                </div>
                            </form>

When i tried to register it come out like this. register

A'isyah
  • 3
  • 3
  • Do you get any errors? – ADyson Jan 02 '21 at 08:21
  • No, I did not get any error. I cannot register user since I upload the site to server but I can login and edit data without problem. When I tested before upload, its working properly. – A'isyah Jan 02 '21 at 11:57
  • So what does "cannot" mean then...i.e. what does the code do when you attempt to register? Have you done any debugging? Have you got error logging enabled in the PHP config? – ADyson Jan 02 '21 at 12:09
  • 1
    Also, we don't want a picture of your PHP code. Paste it properly like you did for the HTML, please – ADyson Jan 02 '21 at 12:10
  • ok I already edit it. You can see the code now. When I try to register new user it will state that "problem to register" (refer picture given). – A'isyah Jan 02 '21 at 16:23
  • Ok so clearly that means your query failed (because $result must have been false). Turn on mysqli error reporting and PHP error logging so you can see the real error. Let me know if you need instructions for that. Also, your query is really vulnerable to SQL injection attacks. **Please urgently** learn how to use parameters to make your queries safe. See https://phpdelusions.net/mysqli for details and examples – ADyson Jan 02 '21 at 18:04
  • can I get the instruction to turn on mysqli error reporting and PHP error logging? – A'isyah Jan 02 '21 at 18:20
  • It's not hard to Google it but... https://stackify.com/php-error-logs-guide (php error logging/reporting) https://stackoverflow.com/a/14578644/5947043 (mysqli error handling) – ADyson Jan 02 '21 at 18:30

1 Answers1

-1

Removedisplay: none; Please Check again