Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by Sigmahokies

  1. Never mind everyone, I found to make it work...I remove "action='[file]'" from HTML form. Thank you for effort
  2. Oh, I missed that part, I just changed that $updated from $update. Seem it doesn't work with update in database, it's result same. It haven't update...I think something is missing, I tried to use PHP tester, test showed it's fine. Very odd.
  3. No error is showing, all syntax are corrected. Only I see that data has not change when I entered the update a data in the database.
  4. Hi everyone, I need a help...I don't understand why it is not work. I'm trying to "update" data in database, but it couldn't do that. Maybe there is wrong script in PHP. Can you find what did I do wrong? //Edit data from database if(isset($_GET['edit'])) { $edit = $_GET['edit']; $update = "select * FROM sampleDB where ID = '$edit';"; $updated = mysqli_query($GaryDB, $update); $change = mysqli_fetch_assoc($updated); if($change) { $editted = "<tr><td colspan='4'><input type='text' name='update' value='".$change['ID']."' readonly></td></tr> <tr><td colspan='5'><input type='text' name='update1' value='".$change['FirstName']."'></td></tr> <tr><td colspan='5'><input type='text' name='update2' value='".$change['LastName']."'></td></tr> <tr><td colspan='5'><input type='text' name='update3' value='".$change['City']."'></td></tr> <tr><td colspan='5'><input type='text' name='update4' value='".$change['State']."'></td></tr> <tr><td><input type='radio' name='update5' value='EST'>EST</td><td><input type='radio' name='update5' value='CST'> CST</td><td><input type='radio' name='update5' value='MST'> MST</td><td><input type='radio' name='update5' value='PST'> PST</td></tr> <tr><td colspan='5'><input type='submit' name='updateddata' value='Update data'></td><tr>"; if(isset($_POST['updateddata'])) { $updateFirst = $_POST['update1']; $updateLast = $_POST['update2']; $updateCity = $_POST['update3']; $updateState = $_POST['update4']; $updateTime = $_POST['update5']; $updated = "UPDATE `sampleDB` SET `FirstName`='$updateFirst', `LastName`='$updateLast', `City`='$updateCity', `State`='$updateState', `TimeZone`='$updateTime' WHERE `ID` = '$edit';"; $up_date = mysqli_query($GaryDB, $update); if(isset($up_date)) { header('location: sampleDB.php'); } else { $updated2 = "Could not updated data"; } } } } Anyone can help will be very appreciate Thanks, Gary
  5. dsoneuk, You are right, it works now...thank you so much! Gary
  6. Hi everyone, I'm trying to display all record in php from database, there are three rows in phpmyadmin already, but why while won't print three rows? it just printed last row. what did I do wrong? I followed exactly from w3school's instruct, but it is still show last row, not all record. $show = "SELECT FirstName, LastName, City, State, TimeZone FROM sampleDB"; $query = mysqli_query($GaryDB, $show); if(mysqli_num_rows($query)) { while($row = mysqli_fetch_assoc($query)) { $display = "<tr><td>".$row['FirstName']."</td><td>".$row['LastName']."</td><td>".$row['City']."</td><td>".$row['State']."</td><td>".$row['TimeZone']."</td></tr>"; } } else { $display = "<tr><td>None of record in database</td></tr>"; } mysqli_close($GaryDB); Can you help? Thanks, Gary
  7. Sigmahokies

    PHP email

    Hi everyone, Can anyone help me underatdn why my email in php didn't work. I set up the email form in web, seem it didn't send at all. I put boolean with email, then I tested to fill out text to send email, then it said it didn't send email at all. What did I do wrong? <?php $error = ""; if($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($_POST['email'])) { $error = "<tr><td colspan='2'>E-mail is required</td></tr>"; } elseif (empty($_POST['FirstName'])) { $error = "<tr><td colspan='2'>First Name is required</td></tr>"; } elseif (empty($_POST['LastName'])) { $error = "<tr><td colspan='2'>Last Name is required</td></tr>"; } elseif (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $error = "<tr><td colspan='2'>Invalid e-mail format</td></tr>"; } else { $first = $_POST['FirstName']; $last = $_POST['LastName']; $email = $_POST['email']; $comment = $_POST['comment']; $title = $_POST['Title']; $emailGary = "XXXX@gmail.com"; if(mail($emailGary, $title, $comment)) { $sent = "<tr><td colspan='2'>E-mail has been sent</td></tr>"; } else { $sent = "<tr><td colspan='2'>E-mail has not sent</td></tr>"; } } } ?> <body class="background"> <h5><a href="#garydtaylor">XXXX</a></h5> <div class="w3-row"> <div class="w3-col" style="width:300px; text-align: left; padding-left: 50px;"><p>Hello</p></div> <div class="w3-rest w3-round" style="text-align: left; padding-left: 50px;"><p>Hello</p> <form action="resume.php" method="post"> <table cellpadding="5"> <tr><td>* First Name:</td><td><input type="text" name="FirstName"></td></tr> <tr><td>* Last Name:</td><td><input type="text" name="LastName"></td></tr> <tr><td>* Title:</td><td><input type="text" name="Title"></td></tr> <tr><td>* Email:</td><td><input type="text" name="email"></td></tr> <tr><td valign="top">* Comment:</td><td><textarea maxlength="5000" cols="18" rows="6" type="text" name="comment"></textarea></td></tr> <tr></tr><td></td><td><input type="submit" name="submit" class="w3-round" style="background: maroon; color: white; height: 25px; width: 175px;" value="E-mail to Gary Taylor"></td> <?php echo $error ?> <?php echo $sent ?> </table> </form> </div> </div> </div> </body> </html> Can you help me? Of course, i will use CSS to make it decoration as style, but I want to make sure it works. Thanks, Gary
  8. Hi everyone, I'm wondering about Javascript and PHP allow to using same keyword with different reason, like using keyword word twice in html line. For example, I'm using keyword "name" in Javascript for count in adjust number, now, I'm trying to use keyword "name" for other reason, like undo all checked. Can use keywords more than one time? or cannot be done? Thanks, Sigmahokies
  9. Sigh...All right, you are not helpful. I will do other forum, I hope someone can help me.
  10. I'm still not get it...Maybe that "this" keyword is not useful. I'm not sure I understand, I thought "this" is good for pass variable to other class like other page.
  11. I'm not sure I get it about your last reply. I checked around about "this" keyword in Javascript...it's not clear to me.
  12. So, do i have to use class? class is allowed to have multiply...
  13. Hi everyone, I'm still learning, but getting deeper now. I'm trying to use JavaScript and PHP in one page in website. I'm trying to make a switch video source on html by click on button. I believe I'm doing right in PHP, but Javascript seem something is missing. I don't understand how it gone work...it said undefined. <!doctype html> <html> <head> <link href="css/grammar.css" rel="stylesheet" type="text/css"> <link rel="icon" href="images/sigma.png"> <script type="text/javascript" src="js/checkbox.js"></script> <script> function clickvideo() { let path = document.getElementById("video1").button; document.getElementById("display").innerHTML = "<video width='450' controls style='border-radius: 5px;' height='240' type='mp4'>" + "<source src='UPLOADS/Breakfast/" + path + "'></video>"; } </script> </head> <body> <table class="table"> <tr><td><video width="450" controls style="border-radius: 5px;"><source src="video/Ha_Demo.mp4"></video></td></tr> <tr><td> <div id='display'><video width='450' controls style='border-radius: 5px;'><source src="UPLOADS/Breakfast/hello.mp4"></video></div></td></tr> <tr><td> <?php $video = opendir("UPLOADS/Breakfast/"); while(($listvideo = readdir($video)) !== FALSE) { if(preg_match("/^[^\.].*$/", $listvideo)) { echo "<button id='video1' onclick='clickvideo()'>".$listvideo."</button>&nbsp;"; } } ?> </td></tr> </body> </html>
  14. So, do I have to find source, then download it, then put in path to connect to this script?
  15. Hello everyone, I'm trying to create a RSA encryption, but seem it is not function correctly. Is Javascript know RSA? like, let rsa = new RSA(); do I have to download from github? here my code: let rsa = new RSA(); let prime = ["2", "3", "5", "7", "11", "13"] //<-- Prime number let random = prime[Math.floor(Math.random() * prime.length)]; let text = document.getElementById("readed"); document.getElementById("en").innerHTML = rsa.encrypt(random, text); Seem console log show it is not function.
  16. Never mind, i found a way to post, Javascript and PHP can use one keyword, but work in separate.
  17. Hi Justsomeguy, Ok here my code, I replaced array ([ ]) to nothing in PHP, so PHP should able to get data from this name. <tr><td>Go/Walk-To/From</td> <td><label for="box"><input class="single-count" type="checkbox" id="box" name="chkboxGrp0[]" value="1"></label></td> <td class="vert-middle">0</td></tr> <tr><td>Bring-Stack-Comic</td> <td><input class="single-count" type="checkbox" name="chkboxGrp1[]" value="1"></td> <td class="vert-middle">0</td></tr> <tr><td>Pick-up</td></tr> In JavaScript: var inputNameArray = []; for (var j = 0; j < chkbox.length; j++) { var chkBoxNameStripSqrBraces = chkbox[j].name.replace('[]', ''); <---- if (inputNameArray.indexOf(chkBoxNameStripSqrBraces) === -1 && chkbox[j].checked === true) { chkboxTotal[parseInt(chkBoxNameStripSqrBraces.replace('chkboxGrp', ''))].innerHTML = "1"; inputNameArray.push(chkBoxNameStripSqrBraces); } In PHP: if (isset($_POST['save'])) { $name01 = $_POST['chkboxGrp0[]']; $name01 = $_POST['chkboxGrp1[]']; } Look at arrow in JavaScript, please then goes on save in database... As you can see Javascript use "name", but I need "name" in php to get data from form in HTML, but seem it won't work because of conflict. I'm sorry if you don't understand, I'm ASL user, not english. if still not understand, i will display all whole code.
  18. Hi everyone, I want to make clear again. I am trying to get data from "name" by PHP in HTML, but problem is "name" is used up by Javascript, but I need "name" for PHP's $_POST to get data from input from html, but can I use this "name" by JavaScript and PHP in same time? I need to get data from that word to post in database, but I think I'm stuck now...Anyone can tell me what is alternative keyword to get data from "name" in HTML? If you don't understand what I said, I will display and show you Thanks, Gary
  19. Hi everyone, is it possible to collect data such as checkbox and radio inside iframe when push button outside of iframe? or require to method of post inside iframe?
  20. I used session storage, seem it doesn't work. I use localstorage, seem it works a little, but stayed checked on checkbox has not work. here code I get from other website, but seem function is not right <script> function onClickBox() { let checked = $("#box").is(":checked"); localStorage.setItem("checked", checked); $("#msg").text("Checkbox is checked: " + $("#box").is(":checked")); } function onReady() { $("#msg").text("Loaded."); let checked = "true" === localStorage.getItem("checked"); $("msg").prop('checked', checked); $("#box").click(onClickBox); } $(document).ready(onReady); </script> <form> <div id="msg"></div> <table> <tr><th colspan="3">Spatial Verbs</th></tr> <tr><td>Go/Walk-To/From</td> <td><input class="single-count" type="checkbox" id="box" name="chkboxGrp0[]" value="1"></td> <td class="vert-middle">0</td></tr>
  21. Does that mean i have to use PHP as well?
  22. Hi everyone, I'm trying to create the look like "paginate data page", but it is not. I set up the file to insert in website by iframe, but I need to find a way to make clicked data like click the checkbox, then click on next, go to next file in iframe, then come back, stay checked in checkbox. Do you understand what I mean? I'm not fluent in English, my prime is American Sign Language.
  23. Hi everyone, inside PhpStorm, seem tag of frame has been strike, it might mean it is not support. I want to create like paginate data, but I just want to have page inside frame on page, so I can leave video on left, then other column can be change page by link. Anyone can help? Thanks, Gary
  24. Hi everyone, I am still learning changing PHP by mysqli to PDO. I'm not get used with PDO because it is little complex to understand, but maybe few weeks I will understand how PDO works. Now, I am trying to make redirect with type account in website and database. I am trying to identify type of three - administrator, license, and scorer page. I set up the test to make it work, seem it went dead end, it won't go to admin or license or scorer page. What did I do wrong? maybe something is missing. here my code: <?php /** * Created by PhpStorm. * User: Gary.Taylor * Date: 7/5/2018 * Time: 10:10 PM */ session_start(); require('access.php'); if(isset($_POST['submitted'])) { $username = $_POST['username']; $password = $_POST['password']; if($username && $password) { $login = $GaryDB->prepare("select username, password, Administrator from account Where username = '.$username.' and password = '.$password.' and Administrator = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:admin.php'); } } elseif ($username && $password) { $login = $GaryDB->prepare("select username, password, License from account Where username = '.$username.' and password = '.$password.' and License = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:license.php'); } } elseif ($username && $password) { $login = $GaryDB->prepare("select username, password, Scorer from account Where username = '.$username.' and password = '.$password.' and Scorer = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:scorer.php'); } } else{ header('location:denied.html'); } }
  25. Never mind about above, I found a way to make it work Thank you, everyone.
  • Create New...