Jump to content

eddcaton

Members
  • Content Count

    22
  • Joined

  • Last visited

Community Reputation

0 Neutral

About eddcaton

  • Rank
    Member

Recent Profile Visitors

274 profile views
  1. Thanks for the reply, do you know if i can send this custom data with the PayPal SDK?
  2. Hey All, I have setup a Paypal API to handle the recurring payments on my website, once the payment is completed I get a token id and ba_token id return. I am storing this in a database, but wondered how people link this with a user table? I could use a cookie to store the user's id before payment and then get it once the payment is complete, but this would not work with the subsequent recurring payments. How do you go about sending the user id when a recurring payment happens? Any advise would be appreciated. Edd
  3. I have managed to get a little further with this. Could anyone advise how to get the filenames back to my form.php file: This is my upload.php file that my form.php sends the drop zone upload request. <?php /** * Dropzone PHP file upload/delete */ // Check if the request is for deleting or uploading $delete_file = 0; if(isset($_POST['delete_file'])){ $delete_file = $_POST['delete_file']; } $targetPath = dirname( __FILE__ ) . '/user_uploads/item/'; // Check if it's an upload or delete and if there is a file in the form if ( !empty($_FILES) && $delete_file == 0 ) { // Check if the upload folder is exists if ( file_exists($targetPath) && is_dir($targetPath) ) { // Check if we can write in the target directory if ( is_writable($targetPath) ) { /* create new name file */ $source = $_FILES["file"]["tmp_name"]; $destination = "../img/imageDirectory/{$basename}"; /** * Start dancing */ $filename = uniqid() . "-" . time(); // 5dab1961e93a7-1571494241 $extension = pathinfo( $_FILES["file"]["name"], PATHINFO_EXTENSION ); // jpg $basename = $filename . "." . $extension; // 5dab1961e93a7_1571494241.jpg $tempFile = $_FILES['file']['tmp_name']; $targetFile = $targetPath . $basename; // Check if there is any file with the same name if ( !file_exists($targetFile) ) { move_uploaded_file($tempFile, $targetFile); // Be sure that the file has been uploaded if ( file_exists($targetFile) ) { $response = array ( 'status' => 'success', 'file_link' => $targetFile ); } else { $response = array ( 'status' => 'error', 'info' => 'Couldn\'t upload the requested file :(, a mysterious error happend.' ); } } else { // A file with the same name is already here $response = array ( 'status' => 'error', 'info' => 'A file with the same name is exists.', 'file_link' => $targetFile ); } } else { $response = array ( 'status' => 'error', 'info' => 'The specified folder for upload isn\'t writeable.' ); } } else { $response = array ( 'status' => 'error', 'info' => 'No folder to upload to :(, Please create one.' ); } // Return the response echo json_encode($response); exit; } // Remove file if( $delete_file == 1 ){ $file_path = $_POST['target_file']; // Check if file is exists if ( file_exists($file_path) ) { // Delete the file unlink($file_path); // Be sure we deleted the file if ( !file_exists($file_path) ) { $response = array ( 'status' => 'success', 'info' => 'Successfully Deleted.' ); } else { // Check the directory's permissions $response = array ( 'status' => 'error', 'info' => 'We screwed up, the file can\'t be deleted.' ); } } else { // Something weird happend and we lost the file $response = array ( 'status' => 'error', 'info' => 'Couldn\'t find the requested file :(' ); } // Return the response echo json_encode($response); exit; } ?> I have seen that some people user something like this on the form.php file: onyxDropzone.on("success", function(file, response) { let parsedResponse = JSON.parse(response); file.upload_ticket = parsedResponse.file_link; But unfortunetly my understanding on JAVA is very limited. Basically I want to get all the filenames of the files that have been updated in the drop zone and then save them as a php variable which then i can insert into MYSQL when the form is submitted.
  4. I am after some guideance / best practices for dropzone.js inside a text form. I have a form that is used to create listings on a website and it has text fields and a dropzone.js file uploader in it. But on submit of the completed form, i would like it to upload the files and submit the text fields to mysql. The upload files part is working and also the mysql part working but I cannot work out how to make the relationship between the listing and the images that are attributed to the listing, which are stored in different tables. At the point of submission the user is not logged in, so i cannot use that to assist with telling mysql where the image is attributed to.. I have looked into submitting the text form first then redirecting to the upload section but it really isn't what I want for the form. It would be nice that the user can submit all the information for that listing in one form. Now i am sure that there is a really simple way to achieve this but i am running round and round in circles on this one.
  5. Thanks for all the help and assistance on this really annoying issue. I have now found the error in the code. When coding in Sublime everything looks fine and no issues. When i took a look at the file directly from Cpanel there was a single . before <?php which threw the whole lot off. I have removed the dot from the cpanel view and it works perfectly now.
  6. Thanks for the info. 1. Shows up an error on the working and not working file Warning: Cannot modify header information - headers already sent by (output started at /homepages/41/d553935649/htdocs/edd/login.php:1) in /homepages/41/d553935649/htdocs/edd/login.php on line 47 Warning: Cannot modify header information - headers already sent by (output started at /homepages/41/d553935649/htdocs/edd/login.php:1) in /homepages/41/d553935649/htdocs/edd/login.php on line 48 line 1: <?php line 47: setcookie("login_id", $randomNumber, time()+86400); line 48: header("location:index.php"); 2. Amended 3. Yes the db_const.php is in the same directory as the login.php file 4. The form is in the same file as the php action with a if(isset($_POST["login"])) before the posting and setting of the cookie 5. Shows the email and login that was input into the login form and the errors mentions in #1
  7. Thanks. I will take a look at changing the PHP settings. Do you think this might influence the cookie setting?
  8. Hey, error_reporting is set to 22517 and display_errors is set to on
  9. if(password_verify($_POST["user_password"], $row["user_password"])) //// Check PHP HASH ///////////// { $randomNumber = rand(); $user_id = "$row[user_id]"; setcookie("login_id", $randomNumber, time()+86400); $sql2 = "UPDATE user_details SET login_id=$randomNumber WHERE user_id='$user_id'"; if ($mysqli->query($sql2) === TRUE) { } header("location:index.php"); exit(); MYSQL submits fine and the table is updated fine when the login form is completed. What i cant understand is that i have it working 100% in a un stylised php file. As soon as i copy to a stylised design it doesn't work...
  10. Once a submission is made from the un stylised login from it displays: Array { [login_id] => 1681386050 } The cookie is populated with a random number that is sent to the DB when the user submits the login form. Then later on in other pages I check the cookie against the DB to then get the users info. I added the random number in after @mac_gyver mentioned about the security issue of setting the cookie with the users actual id.
  11. I will take a look at the PHP info and see what i have listed. I just cant help thinking there is something throwing the cookie off from being set properly
  12. Thanks for the info. I have done some more searching of google and found how to see cookies that are set from a website in google chrome. When I submit the login form from the troublesome page. I checked the cookies and it has set a cookie with the description of "Database Storage" and the flie is 2,315 B in size. It looks like somewhere along the line i am submitting something other than the login_id that i am trying to set. Here is the part of the code that handles my cookie setting etc. <?php //login.php include 'db_const.php'; //if(isset($_COOKIE["login_id"])) //{ // header("location:index.php"); // exit(); //} $message = ''; if(isset($_POST["login"])) { if(empty($_POST["user_email"]) || empty($_POST["user_password"])) { $message = "<div class='alert alert-danger'>Both Fields are required</div>"; } else { $query = " SELECT * FROM user_details WHERE user_email = :user_email"; $statement = $connect->prepare($query); $statement->execute( array( 'user_email' => $_POST["user_email"] ) ); $count = $statement->rowCount(); if($count > 0) { $result = $statement->fetchAll(); foreach($result as $row) { if(password_verify($_POST["user_password"], $row["user_password"])) //// Check PHP HASH ///////////// { $randomNumber = rand(); $user_id = "$row[user_id]"; setcookie("login_id", $randomNumber, time()+86400); $sql2 = "UPDATE user_details SET login_id=$randomNumber WHERE user_id='$user_id'"; if ($mysqli->query($sql2) === TRUE) { } header("location:index.php"); exit(); } else { $message = '<div class="alert alert-danger">Wrong Password</div>'; } } } else { $message = "<div class='alert alert-danger'>Wrong Email Address</div>"; } } } ?> <html> <head>
  13. Hey, This is what i get when i submit the login form: Array ( ) When i say "blank" file. I mean a file with just the code in for the form. Nothing fancy and no real CSS styling.
  14. Any further ideas why the cookies are being set in a "blank" file and not in a stylised file?
  15. Thanks for the info. 1. So if i generated a random code submitted to MYSQL every time the login form is submitted, then save that to the cookie. When i am then trying to get the users info then i check MYSQL for the random code that matches the cookie info? 2. Sorry for my lack of knowledge on this. I am unsure where the exits need to be placed 3. I should change the fetch argument to: $random_id = $_COOKIE["random_id"]; /// not the user_id but a random code generate on login. $sql = "SELECT * FROM user_deatils WHERE random_id LIKE ".$random_id.""; $result = $mysqli->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { 4. I thought the code needed to be before any HTML to set the cookie.
×
×
  • 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.