Siegfried Posted October 29, 2020 Share Posted October 29, 2020 Hi there, I am trying to create a custom registration form and connect the file to mysql using a config.php file. I created the file with a tutorial. I placed both the config.php and the registration.php in a "page-templates folder" inside the "theme folder". Using wordpress "add new page" I am able to select the registration.php file as a template. I am able to open the newly created page and type in information like username and password. I am able to press submit and I get redirected to a new page. Problem: The username and password are not in the dedicated table of the mysql database - hence I assume that the config.php file is not working properly. How do I make it work? I would really appreciate your help. Siegfried Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/ Share on other sites More sharing options...
gw1500se Posted October 29, 2020 Share Posted October 29, 2020 By correcting the erroneous code. Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/#findComment-1582132 Share on other sites More sharing options...
Siegfried Posted October 29, 2020 Author Share Posted October 29, 2020 (edited) Thank you so much. I did not know that. Are there common mistakes that I can correct? Edited October 29, 2020 by Siegfried Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/#findComment-1582140 Share on other sites More sharing options...
gw1500se Posted October 29, 2020 Share Posted October 29, 2020 Could be. Perhaps if you posted your code and any error messages you are getting might help. My clairvoyance is not working today. Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/#findComment-1582141 Share on other sites More sharing options...
Siegfried Posted October 29, 2020 Author Share Posted October 29, 2020 (edited) Here is my code. Two files. Form.php with the signup form. Uploads.php with the uploading function. Of course I also created a folder with the title "uploads". Form.php: <?php [...] return '<form id="signinform" action="upload.php" method="POST" enctype="multipart/form-data"> <div class="form-group"> <label>' . __('Name') . '</label> <input placeholder="' . __('Your Name') . '" class="form-control" type="text" data-parsley-required="true" data-parsley-error-message="' . __('Enter your name.') . '" name="Name" id="Name"> </div> <div class="form-group"> <label>Phone</label> ' . $phone_html . ' </div> <div class="form-group"> <label>File</label> <input placeholder="Your file" class="form-control-file" type="file" data-parsley-max-file-size="4200" data-parsley-required="true" data-parsley-error-message="' . __('Please upload file.') . '" data-parsley-trigger="change" name="file" id="file"> </div> <div class="form-group"> <label>Email</label> <input placeholder="' . __('Your Email') . '" class="form-control" type="email" data-parsley-type="email" data-parsley-required="true" data-parsley-error-message="' . __('Please enter your email.') . '" data-parsley-trigger="change" name="email" id="email"> </div> <div class="form-group"> <label>password</label> <input placeholder="' . __('Your Password') . '" class="form-control" type="password" data-parsley-required="true" data-parsley-error-message="' . __('Please enter your password.') . '" name="password"> </div> <button class="btn btn-theme btn-lg btn-block" type="submit" name="register" id="register">Register</button> <br /> </form>'; ?> Uploads.php: <?php if(isset($_POST['register'])){ $file = $_FILES['file']; $fileName = $_FILES['file']['name']; $fileTmpName = $_FILES['file']['tmp_name']; $fileSize = $_FILES['file']['size']; $fileError = $_FILES['file']['error']; $fileType = $_FILES['file']['type']; $fileExt = explode('.', $fileName); $fileActualExt = strtolower(end($fileExt)); $allowed = array('jpg', 'jpeg', 'png'); if(in_array($fileActualExt, $allowed)) { if ($fileError === 0){ if (fileSize < 4000000) { $fileNameNew = uniqid('', true).".".$fileActualExt; $fileDestination = 'uploads/'.$fileNameNew; move_uploaded_file($fileTmpName, $fileDestination); } else { echo "File too big!"; } } else { echo "There was as error uploading your file!"; } } else{ echo "You cannot upload files of this type!"; } } ?> Edited October 29, 2020 by Siegfried Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/#findComment-1582142 Share on other sites More sharing options...
requinix Posted October 29, 2020 Share Posted October 29, 2020 Where's the code to enter the information into the database? Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/#findComment-1582143 Share on other sites More sharing options...
Siegfried Posted October 30, 2020 Author Share Posted October 30, 2020 This is my config.php <?php /* Database credentials. Assuming you are running MySQL server with default setting (user 'root' with no password) */ define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'XYZXYZXYZ_user'); define('DB_PASSWORD', 'XYZXYZXYZ_pass'); define('DB_NAME', 'XYZXYZXYZ_database'); /* Attempt to connect to MySQL database */ $mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME); // Check connection if($mysqli === false){ die("ERROR: Could not connect. " . $mysqli->connect_error); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/#findComment-1582149 Share on other sites More sharing options...
gw1500se Posted October 30, 2020 Share Posted October 30, 2020 Not the code we need. What requinix is looking for is the database query code. Quote Link to comment https://forums.phpfreaks.com/topic/311655-wordpress-mysql-config-php-file-not-working/#findComment-1582150 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.