Jump to content

Dealmightyera

Members
  • Posts

    14
  • Joined

  • Last visited

Dealmightyera's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks @ginerjm It's going thru but how will i set a return when the code has already been used and when it has not been used but exist on the oda table
  2. I'm just new to PHP/Mysql and don't think I can go far beyond this level... I'm still learning.
  3. I'm just a noob in Php/mysql... and have never executed such project was just trying see if someone could help me out with the full code structure because of time... I just have less than 3hours to go. maybe I just have to end it here on this project even if i didn't succeed. Thanks everyone for the time you made, I appreciate. Just have to say good bye.
  4. Hers the new code <?php error_reporting(E_ALL); ini_set('display_errors', '1'); session_start(); require_once 'INC/DBcon.php'; $error = ""; //Variable to hold error messages // Check if the user submitted a transaction code if(ISSET($_POST['transactioncode'])) { // Trim the transaction code and assign to variable $tcode = trim($_POST['transactioncode']); //Create a query to identify if the transaction code exists //AND if it has been used for a candidate by JOINing the tables $query = "SELECT t.transactioncode AS tCode, c.transactioncode AS cCode FROM tsc AS t LEFT JOIN Candidates AS c USING (transactioncode) WHERE transactioncode = :trancd"; $stmt = $conn->prepare($query)->execute([$tcode]); $parms = array(':trancd'=>$tcode); if(!$stmt = $conn->prepare($query)) { echo "Error doing prepare - Aborting"; exit(); } else { if (!$stmt->execute($parms)) { echo "Error running query - query was<br>$query<br>"; exit(); } } // process results now if (!$result = $stmt->fetch()) { } } ?> <!DOCTYPE html> <html class="no-js" lang="en"> <head> </head> <body> <?php echo $error; ?> <form action="" name="regForm" onsubmit="return validateForm()" method="POST"> <h4 class="text-success"> <b>N/B:</b> Enter Session/Transaction ID/Number Correctly and click on PROCEED/FETCH, candidates will now commence registration.</h4> <br> <br> <div class="fCont"> <div class="fContL"> <label for="tsc"> TRANSACTION NUMBER/<br>SESSION ID/<br>TRACKING CODE: </label> </div> <div class="fContR"> <input type="text" id="tsc" name="transactioncode" placeholder="Your TRANSACTION NUMBER/SESSION ID/TRACKING CODE.."> </div> </div> <br> <br> <div class="fCont"> <input type="submit" id="submit" value="PROCEED/FETCH" class="submit" name="Submit1"> </div> </form> </body> </html>
  5. I'm still giving a head's up on the code
  6. Thanks Sir, I really really appreciate. You're one in a million. I've learnt a lot. Please can you just help me implement in the whole so I'll I've a full grasph. Thanks
  7. Sorry, didn't read thru it well. <?php session_start(); require_once 'INC/DBcon.php'; $error = ""; //Variable to hold error messages // Check if the user submitted a transaction code if(ISSET($_POST['transactioncode'])) { // Trim the transaction code and assign to variable $tcode = trim($_POST['transactioncode']); //Create a query to identify if the transaction code exists //AND if it has been used for a candidate by JOINing the tables $query = "SELECT t.transactioncode AS tCode, c.transactioncode AS cCode FROM tsc AS t LEFT JOIN Candidates AS c USING (transactioncode) WHERE transactioncode = ?" $stmt = $conn->prepare($query)->execute([$tcode]); $result = $stmt->fetch(); //Check if results were empty if(!$result) { //The transaction code does not exist $error = "The transaction code does not exist"; } //Check if the cCode (transaction code in candidate table) is not empty elseif (!empty($result['cCode'])) { //The transaction code has been used $error = "That code has already been used."; } else { //The transaction code exists and has not been used $_SESSION['tsc'] = $tcode; echo "<script>alert('Validation Succcessful')</script>"; header("location: Sign-up.php"); exit(); } } ?> <!DOCTYPE html> <html class="no-js" lang="en"> <head> </head> <body> <?php echo $error; ?> <form action="" name="regForm" onsubmit="return validateForm()" method="POST"> <h4 class="text-success"> <b>N/B:</b> Enter Session/Transaction ID/Number Correctly and click on PROCEED/FETCH, candidates will now commence registration.</h4> <br> <br> <div class="fCont"> <div class="fContL"> <label for="tsc"> TRANSACTION NUMBER/<br>SESSION ID/<br>TRACKING CODE: </label> </div> <div class="fContR"> <input type="text" id="tsc" name="transactioncode" placeholder="Your TRANSACTION NUMBER/SESSION ID/TRACKING CODE.."> </div> </div> <br> <br> <div class="fCont"> <input type="submit" id="submit" value="PROCEED/FETCH" class="submit" name="Submit1"> </div> </form> </body> </html>
  8. Here's the error Fatal error: Uncaught Error: Call to a member function fetch() on bool in C:\XAMPP\htdocs\Test.php:23 Stack trace: #0 {main} thrown in C:\XAMPP\htdocs\Test.php on line 23
  9. <?php $db_username = 'root'; $db_password = ''; $conn = new PDO('mysql:host=localhost;dbname=db_login', $db_username, $db_password); if(!$conn){ die("Fatal Error: Connection Failed!"); } ?> The above is the content of my DBCon.php
  10. Everything seems to work very except that when the submit button is triggered it brings a Fatal error message concerning the fetch in line 23. I'm just still a novice in PHP, Can't still figure it out now. Thanks, I've really learnt a lot.
  11. Please, I beg you help me implement it in the code. I'm still a beginner in PHP. Thanks.
  12. Please I've been trying to get his done for more than five days but can and it's very urgent.... I have 2 DB (A and B). DB A, will have 2 columns 'id' and 'transactioncode' and DB B(user registration info in different columns such as name, last, nickname, regcode) Now I want to validate if $_POST['code'] has already been used and exist in 'regcode' column in the user registration information table of DB B And if not used(not exist) in 'regcoe' column of DB A but exist in the column 'transactioncode' in DB A I've not mastered php yet. i need it in pdo Thanks in anticipation <?php session_start(); require_once 'INC/DBcon.php'; if(ISSET($_POST['Submit1'])){ if($_POST['transactioncode'] != ""){ $trr = $_POST['transactioncode']; $stmt = $conn->prepare("SELECT * FROM Candidates WHERE transactioncode=?"); $stmt->execute([$trr]); $user = $stmt->fetch(); // $trr1 = $_POST['transactioncode']; $stmt1 = $conn->prepare("SELECT * FROM tsc WHERE transactioncode=?"); $stmt1->execute([$trr1]); $user1 = $stmt1->fetch(); if($user = $trr && $user1 = $trr1) { echo "<script>alert('Already use!')</script>"; }elseif($user1 = $trr1 and $user != $trr) { echo "<script>alert('Validation Succcessful')</script>"; $_SESSION['tsc'] = $fetch['transactioncode']; header("location: Sign-up.php"); } }else{ echo " <script>alert('Please complete the required field!')</script> <script>window.location = 'VLL.php'</script> "; } } ?> <!DOCTYPE html> <html class="no-js" lang="en"> <head> </head> <body> <form action="" name="regForm" onsubmit="return validateForm()" method="POST"> <h4 class="text-success"> <b>N/B:</b> Enter Session/Transaction ID/Number Correctly and click on PROCEED/FETCH, candidates will now commence registration.</h4> <br> <br> <div class="fCont"> <div class="fContL"> <label for="tsc"> TRANSACTION NUMBER/<br>SESSION ID/<br>TRACKING CODE: </label> </div> <div class="fContR"> <input type="text" id="tsc" name="transactioncode" placeholder="Your TRANSACTION NUMBER/SESSION ID/TRACKING CODE.."> </div> </div> <br> <br> <div class="fCont"> <input type="submit" id="submit" value="PROCEED/FETCH" class="submit" name="Submit1"> </div> </form> </body> </html>
×
×
  • 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.