Jump to content

Siegfried

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Siegfried

  1. 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); } ?>
  2. 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!"; } } ?>
  3. Thank you so much. I did not know that. Are there common mistakes that I can correct?
  4. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.