Jump to content

johnman

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by johnman

  1. Good day everyone I needed users to search for cars in my application by brand and location. I created two drop down fields "Brand" and "Location" that is populated from database. When users choose the prefered brand and location, and search button is clicked. It will open a new page displaying the related search. The challenges i am having right now is how to join the tables in order to display the required result to the users. See below code Page1.php <div class="form-group"> <label for="exampleSelectGender">Select City/Location<span style="color:red">*</span></label> <select class="form-control" name="location" required id="exampleSelectGender"> <option>---Select Location---</option> <?php $ret = "select LocationName,LocationName from tbllocations"; $query = $dbh->prepare($ret); $query->execute(); $results = $query->fetchAll(PDO::FETCH_OBJ); if ($query->rowCount() > 0) { foreach ($results as $result) { ?> <option value="<?php echo htmlentities($result->LocationName); ?>"> <?php echo htmlentities($result->LocationName); ?></option> <?php }}?> </select> </div> <div class="form-group"> <label for="exampleSelectGender">Select Brand<span style="color:red">*</span></label> <select class="form-control" name="brand" required id="exampleSelectGender"> <option>---Select Brand---</option> <?php $sql = "SELECT * from tblbrands "; $query = $dbh->prepare($sql); $query->execute(); $results = $query->fetchAll(PDO::FETCH_OBJ); $cnt = 1; if ($query->rowCount() > 0) { foreach ($results as $result) {?> <option value="<?php echo htmlentities($result->brandID); ?>"> <?php echo htmlentities($result->BrandName); ?></option> <?php }}?> </select> </div> <div class="spacer-10"></div> <div class="form-group"> <button type="submit" class="btn btn-main fa fa-search">Search Car</button> </div> </form> </div> SearchResult.php <?php $sql = "SELECT tblvehicles.*,tblbrands.BrandName,tblbrands.brandID as bid from tblvehicles join tblbrands on tblbrands.brandID=tblvehicles.VehiclesBrand.*. tbllocations.LocationName,tbllocations.locID as lid from tblvehicles join tbllocations on tbllocations.locID=tblvehicles.Location"; $query = $dbh->prepare($sql); $query->bindParam(':brand', $brand, PDO::PARAM_STR); $query->bindParam(':location', $location, PDO::PARAM_STR); $query->execute(); $results = $query->fetchAll(PDO::FETCH_OBJ); $cnt = 1; if ($query->rowCount() > 0) { foreach ($results as $result) {?> Every time i tried the search it always display no items instead of displaying list of items related to the search keyword selected Kindly help
  2. Good day I have written a CRUD code in prepared statement, the challenge i have is in the update query data, whenever i tried updating/editing the data the images does not update to newly updated image in the table HTML Form code <form action="participantsController.php" method="POST" enctype="multipart/form-data"> <?php $partID = $_GET['partEdit']; $ret = mysqli_query($connection, "select * from participants where partID = '$partID'"); $cnt = 1; while ($row = mysqli_fetch_array($ret)) { ?> <div class="form-group"> <label >Upload business logo here <span class="text-danger mb-3">* </span> </label> <div> <input type="hidden" name="oldBizLogo" value="<?php echo $row['bizLogo']; ?>"> <input type="file" name="imageBizLogo" id="imageBizLogo" class="form-control" > <img src="../uploads/participants/<?=$bizLogo;?>" width="120" alt="Business Logo" class="img-thumbnail"> </div> </div> <div class="form-group"> <label >Upload participant profile image here <span class="text-danger mb-3">* </span> </label> <div> <input type="hidden" name="oldProfileImg" value="<?php echo $row['profileImg']; ?>"> <input type="file" name="imageProfileImg" id="imageProfileImg" class="form-control" > <img src="../uploads/participants/<?=$profileImg;?>" width="120" alt="Profile Image" class="img-thumbnail"> </div> </div> <?php }?> </form> Php code for updating //Update page code if(isset($_POST['partUpdate'])) { $partID = $_POST['partID']; $oldBizLogo = $_POST['oldBizLogo']; $oldProfileImg = $_POST['oldProfileImg']; if(isset($_FILES['imageBizLogo']['name'])&&($_FILES['imageBizLogo']['name']!="") || ($_FILES['imageProfileImg']['name'])&&($_FILES['imageProfileImg']['name']!="")) { $newBizLogo ="../uploads/participants/".$_FILES['imageBizLogo']['name']; $newProfileImg ="../uploads/participants/".$_FILES['imageProfileImg']['name']; unlink($oldBizLogo); unlink($oldProfileImg); move_uploaded_file($_FILES['imageBizLogo']['tmp_name'], $newBizLogo); move_uploaded_file($_FILES['imageProfileImg']['tmp_name'], $newProfileImg); } else{ $newBizLogo = $oldBizLogo; $newProfileImg = $oldProfileImg; } $query = "UPDATE participants SET bizLogo=?,profileImg=? WHERE partID=?"; $stmt=$connection->prepare($query); $stmt->bind_param("ssi",$newBizLogo,$newProfileImg,$partID); $stmt->execute(); $_SESSION['updateResponse']="Updated Successfully!"; $_SESSION['updateRes_type']="primary"; header('location:participantsAdd.php'); } Kindly help
  3. Good day I am trying to create a three column bootstrap card that will dynamically display data using php and mysql my challenge is instead of dispaying in a grid it is displaying linearly. see the code below <?php require "database/dbconfig.php"; //include_once __DIR__.'/core-php-admin/database/dbconfig.php'; $query = "SELECT * FROM users"; $query_run = mysqli_query($connection, $query); if (mysqli_num_rows($query_run) >0) { foreach ($query_run as $row) { ?> <div class="container py-5"> <div class="row mt-3"> <div class="col-xs-12 col-sm-6 col-md-4"> <div class="frontside"> <div class=" my-card card shadow-sm p-3 mb-5 bg-white rounded"> <div class="row"> <div class="col-sm-3"> <img class="card-img user-img d-none d-sm-block" src="img/participants/bizlogo.png" alt="Card image"/> &nbsp; <img class="card-img user-img user-img d-none d-sm-block" src="img/participants/bizlogo.png" alt="Card image"/> </div> <div class="col-sm-9"> <div class="card-body-right"> <p class="card-title" style="font-family:Montserrat; font-size:15px"><strong>Maramoja Transport</strong> <br> <span class="sub-title" style="line-height:17px">Founder: Nasiru Mustapha </span> </p> <p class="card-text" style="font-family:Montserrat; font-size:15px"> Maramoja Transport </p> <a href="#trasteaprofile" data-toggle="modal" data-target="#trasteaprofile"><p style="font-family:Montserrat; font-size:15px">See More</p></a> </div> </div> </div> </div> </div> </div> </div> </div> <?php } } else { echo "No record found"; } ?> kindly help
  4. Good day I will like to get customers credit details in my app after inputer the required parameters through the form input. After inputing the required values in the form fields and clicking the submit button the response was json with key but null value. My Code // Collection object $data = [ 'BVN' => $_POST["customerBVN2"], 'SessionCode' => $_POST["sessionCode2"], ]; $url = "https://api2.creditregistry.com/nigeria/AutoCred/v7.Test/api/Reports/GetData2"; // Initializes a new cURL session $curl = curl_init($url); // Set the CURLOPT_RETURNTRANSFER option to true curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Set the CURLOPT_POST option to true for POST request curl_setopt($curl, CURLOPT_POST, true); // Set the request data as JSON using json_encode function curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); // Set custom headers for RapidAPI Auth and Content-Type header curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ]); // Execute cURL request with all previous settings $response = curl_exec($curl); // Close cURL session curl_close($curl); echo $response . PHP_EOL; Error response {"Success":false,"Errors":["Invalid request. ReportDataRequest property of the GetDataRequest2 object cannot be null. Expected object format is: \r\n {\r\n \"SessionCode\": \"\",\r\n \"ReportDataRequest\": {\r\n \"BVN\": \"\",\r\n \"AccountOwnerIDs\": \"\",\r\n \"HistoryLengthInMonths\": 84,\r\n \"SectorExclusionIDs\": \"\",\r\n \"IncludeSMARTScore\": false,\r\n \"IncludePDFReport\": false,\r\n \"PDFReportType\": 110,\r\n \"Reason\": \"General credit inquiry\",\r\n \"GetNoMatchReport\": 0\r\n }\r\n}"],"SMARTScores":[],"Accounts":[],"PerformanceSummary":{"Inquiry_Count_12_Months":null,"Count_AccountStatus_Closed":null,"Count_AccountStatus_Delinquent_30_over_60_days":null,"Count_AccountStatus_Derogatory_120_days":null,"Count_AccountStatus_Derogatory_150_days":null,"Count_AccountStatus_Derogatory_Doubtful_180":null,"Count_AccountStatus_Derogatory_Lost_360":null,"Count_AccountStatus_Derogatory_Substandard_90":null,"Count_AccountStatus_Late_less_than_30_days":null,"Count_AccountStatus_Open":null,"Count_AccountStatus_Performing":null,"Count_AccountStatus_Unknown":null,"Count_AccountStatus_Unspecified":null,"Count_AccountStatus_Written_off":null,"Count_LegalStatus_Judgment":null,"Count_LegalStatus_Litigation":null,"Count_LegalStatus_Notice":null,"Count_LegalStatus_Receivership":null,"SelfInquiriesLast12Months":null,"DishonouredChequesLast12Months":null},"AccountSummaries":[],"PDFReport":{"Success":true,"Errors":[],"PDFContent":"","NoMatchPDFContent":"","ReportNo":"","Filename":"","StatusCode":200,"Message":""},"StatusCode":400,"Message":"Invalid request. ReportDataRequest property of the GetDataRequest2 object cannot be null."} Kindly help
  5. @requinix thanks you for your reply i will rewrite the code
  6. I edited the above code because the API endpoint is not included, it has been included in the below code $mydata = array( 'number1' => $_POST["customerNUM1"], 'number2' => $_POST["sessionNUM1"], ); $headers = array( 'Content-Type' => 'application/json' ); $url = "https://api2.creditregistry.com/nigeria/AutoCred/v7.Test/api/Customers/FindByBVN2"; $ch = curl_init($url); // curl_setopt($ch,CURLOPT_COOKIEJAR, $this->cookie_jar); // curl_setopt($ch,CURLOPT_COOKIESESSION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, False); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, False); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($ch,CURLOPT_MAXREDIRS,0); curl_setopt($ch,CURLOPT_TIMEOUT,30); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $err = curl_error($ch); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; }
  7. Good day I tried getting a json response using the below written code but instead it returned the following error message {"Message":"The request entity's media type 'multipart/form-data' is not supported for this resource."} see the code below $mydata = array( 'number1' => $_POST["customerNUM1"], 'number2' => $_POST["sessionNUM1"], ); $headers = array( 'Content-Type' => 'application/json' ); $ch = curl_init($url); // curl_setopt($ch,CURLOPT_COOKIEJAR, $this->cookie_jar); // curl_setopt($ch,CURLOPT_COOKIESESSION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, False); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, False); curl_setopt($ch, CURLOPT_ENCODING, ""); curl_setopt($ch,CURLOPT_MAXREDIRS,0); curl_setopt($ch,CURLOPT_TIMEOUT,30); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $err = curl_error($ch); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } Kindly help
  8. Good day I have written a php code that allows users to login to a dashboard successfully and works fine. Right now i want the code to return and display response on the next page i.e dashboard when logged into dashboard see the code below $data = array( 'EmailAddress' => 'john@mail.com', 'Password' => '1234567890', ); $url = "https://website.com/Login.php"; $nextPage = "dashboard.php"; $options = array( 'http' => array( 'method' => 'POST', 'content' => json_encode( $data ), 'header'=> "Content-Type: application/json\r\n" . "Accept: application/json\r\n" ) ); $context = stream_context_create( $options ); $result = file_get_contents( $url, false, $context ); $response = json_decode( $result, true ); //echo $result; to see the result remove comment and add comment to header('Location: '.$nextPage); if ($response["Message"] !== "The request is invalid." && $response["Authenticated"]) { echo "login successfull"; header('Location: '.$nextPage); } else { echo "login failed!"; } Kindly help
  9. Good day I am developing a project that requires me to consume/connect to an API for login and registration of users on my website. I know how to develop login and registration pages on my own server/database but i have not used a third party webservice/API to implement. I will be grateful if i can be pointed to a tutorial or a help guide that can solve this challenge Thanks in advance
×
×
  • 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.