Jump to content

sigmahokies

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by sigmahokies

  1. Hi CyberRobot, I will try to do that...Thank you, but it hasn't solve yet, but pretty close now.
  2. I did that, but I am just having little vague to make a logic to make it work, here my script in php: <?php $Garydb = mysqli_connect("XXXXX","XXXXX") or die("Could not connect MySQL Database"); mysqli_select_db($Garydb, "XXXXX") or die("Could not find a Database"); if ($_POST['submitted']) { $select = $_POST['birth']; if ($select) { $birthdate = "SELECT CONCAT(FirstName,' ',LastName) AS Birth FROM Members WHERE birthdate = ".$select; $result = mysqli_query($Garydb, $birthdate); if (mysqli_num_rows($result)) { while($row = mysqli_fetch_assoc($result)) { echo "<p>".$row['Birth']."</p>"; } } } } ?> <!doctype html> <html> <head> <title>Test with option</title> </head> <body> <h1>Please select the Members from RCD</h1> <form action="option.php" method="POST"> <select name="birth"> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <br /> <input type="submit" name="submitted" value="find member's birthday"></input> </form> </body> <html>
  3. Hi everyone, I made script in php that working with HTML select and option, but I can't figure how to do that. Is any website that can provide tutorial about select and option with php database. I mean, for example, I set up the 12 months in the select, then drop menu to pick an option, I pick July, then click on submit, then php display the list of name who have birthday on July. Get it? Please ask me if you are not sure you understand what i mean... Thank you in advance time. Gary
  4. Psycho, your script in PHP about passing the value, it got few error but i fixed it, it works! seem it is not require to have pass all value; just select ID, then pass one value to other, then use SQL with ID, then all data has been place in the HTML form. Now, I am testing to UPDATE the data in the database. Thank you! Gary
  5. Look like i have to go to school that studying in PHP, I will visit Radford university soon as I can.
  6. Mac_gyver, Really? But it is working to pass all data to next page already. Only problem that I could not update as insert in the database that show the data from previous page, For example, I put all value in php like /insert.php?id=$row['id'] inside the link, but I was told that POST cannot be done in link, only GET can. That is why I wrote GET instead of POST. Also, I am aware that GET is visible to anyone, POST is invisible to anyone, but inside link, only GET work. I am still learning to write code in PHP. I can do Dreamweaver CS6 and CC, but I notice that many companies are less favor in Dreamweaver, I notice they rather to have someone who can do code instead of design by software. I can do update in Dreamweaver, but write in the code to create the update page is more challenger than Dreamweaver. I changed the method, so I hope my writing in PHP is more readable. I thought I am using table to make it neat in form, I notice without table, then form will go ugly. Should I use CSS to make it neat instead ofg Here inside link: <a href='update.php?id=$row[iD]&id2=$row[FirstName]&id3=$row[LastName]&id4=$row[Locations]&id5=$row[birthdate]&id6=$row'>EDIT</a> this link will go in the HTML form, it is working passing from previous page (insert.php) to update page. Here more NEAT writing in PHP in update.php for ginerjm <?php $Garydb = mysqli_connect("XXXXX","XXXXX","XXXXX") or die("Could not connect MySQL Database"); mysqli_select_db($Garydb, "XXXXX") or die("Could not find a Database"); $edit = $_GET['id']; $firstname = $_GET['id2']; $lastname = $_GET['id3']; $location = $_GET['id4']; $birthdate = $_GET['id5']; $email = $_GET['id6']; if ($_GET['submitted']) { $id = $_POST['id9']; $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $locations = $_POST['locations']; $birthdate = $_POST['birthdate']; $email = $_POST['email']; if ($first_name && $last_name && $locations && $birthdate && $email) { $update = "UPDATE Members SET FirstName='$first_name', LastName='$last_name', Locations='$locations', birthdate='$birthdate', Email='$email' WHERE ID='$id'"; mysqli_query($Garydb, $update); } } ?> <!doctype html> <html> <head> <title>Update Members info</title> </head> <body> <form action="insert.php" method="POST"> <table> <tr><td>Identify Number:</td><td><input type="hidden" name="id9" value="<?php echo $edit ?>"></td></tr> <tr><td>First Name:</td><td><input type="text" name="first_name" value="<?php echo $firstname ?>"></td></tr> <tr><td>Last Name:</td><td><input type="text" name="last_name" value="<?php echo $lastname ?>"></td></tr> <tr><td>Locations:</td><td><input type="text" name="locations" value="<?php echo $location ?>"></td></tr> <tr><td>birthdate:</td><td><input type="text" name="birthdate" value="<?php echo $birthdate ?>"></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="<?php echo $email ?>"></td></tr> <tr><td colspan="2"><input type="submit" name="submitted" value="update"></td></tr> </table> </form> </body> </html>
  7. Psycho, All right, I changed a name id9 in the input hidden in the form, Reason I put id9 in TD because I don't want to have ID number change by update when it is in form text. Yes, This is just learning exercise. That is why I am practicing on PHP, because it is not easy to understand fully, because it is still complex to write the program in code. However, it has not update in the database...I guess something else goes wrong.
  8. Hi everyone, I'm learning about update the data in the database in PHP now, seem it is little tougher than register form. But I believe I am doing right code in PHP, but seem update has not enter MYSQL database yet. what did I do wrong? Also, I set up the link from previous website like this: /insert.php?id=$row['id']&id2=$row['firstname']&id3=$row['lastname'], goes on. So, this link passed the data in the value to this update website. <?php $Garydb = mysqli_connect("XXXXX","XXXXX","XXXXX") or die("Could not connect MySQL Database"); mysqli_select_db($Garydb, "XXXXX") or die("Could not find a Database"); $edit = $_GET['id']; $firstname = $_GET['id2']; $lastname = $_GET['id3']; $location = $_GET['id4']; $birthdate = $_GET['id5']; $email = $_GET['id6']; if ($_GET['submitted']) { $id = $_GET['id9']; $first_name = $_GET['first_name']; $last_name = $_GET['last_name']; $locations = $_GET['locations']; $birthdate = $_GET['birthdate']; $email = $_GET['email']; if ($first_name && $last_name && $locations && $birthdate && $email) { $update = "UPDATE Members SET FirstName='$first_name', LastName='$last_name', Locations='$locations', birthdate='$birthdate', Email='$email' WHERE ID='$id'"; mysqli_query($Garydb, $update); } } ?> <!doctype html> <html> <head> <title>Update Members info</title> </head> <body> <form action="insert.php" method="GET"> <table> <tr><td>Identify Number:</td><td name="id9"><?php echo $edit ?></td></tr> <tr><td>First Name:</td><td><input type="text" name="first_name" value="<?php echo $firstname ?>"></td></tr> <tr><td>Last Name:</td><td><input type="text" name="last_name" value="<?php echo $lastname ?>"></td></tr> <tr><td>Locations:</td><td><input type="text" name="locations" value="<?php echo $location ?>"></td></tr> <tr><td>birthdate:</td><td><input type="text" name="birthdate" value="<?php echo $birthdate ?>"></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="<?php echo $email ?>"></td></tr> <tr><td colspan="2"><input type="submit" name="submitted" value="update"></td></tr> </table> </form> </body> </html>
  9. All right, I will do my best to make reduced the risk of weird and dangerous technique. I have two websites, one website for practice, other one is set as professional website what I learned from previous website. For now, I am using one website for practice, but oddly, in practice website, Insert data into the database is working, so, I copied the code from practice one to my professional website, it is not working. Of course, I tested the connect to MySQL and select database, it works finely. what I don't get is why practice one is working, and professional website does not work at all. I am beginning to think about different OS in server; my professional website is in ubuntu, maybe this practice website is other OS, maybe Linux or IIS. I don't like IIS, but I'm not sure Linux. Now, I am practice on update the data in the database, I know it is little harder than register. You can look up in other thread in this website.
  10. Guru, I can see you said my weird and technique in MySQL and PHP, I guess i am still having a long way to go. As i can see, you are using object-oriented style in PHP, I am using procedural style in PHP. Is Procedural style dangerous, too?
  11. I think i know why it won't insert a new data in PHPmyadmin, It show the error in the function in the database, the message showed "A fatal JavaScript error has occur". It must prevent the add a new data in the database. Of course, I removed StudentiD and NULL from function already, but still won't add the new data...
  12. Hi everyone, I'm sure you have seen me around in here by learning PHP, I am getting advance now. But I don't understand why it won't insert in PHPmyadmin (MySQL) with my prompt in php. Can you find why it won't add name as insert into my database? if ($_POST['submmited']) { $first = $_POST['firstname']; $last = $_POST['lastname']; $email = $_POST['email']; if ($first && $last && $email) { $sql = "INSERT INTO Student (StudentID,Firstname,LastName,Email) VALUES (NULL,'$first','$last','$email')"; mysqli_query($Garydb, $sql); } else { echo "Failed to add register"; } } I checked around, there is no mistake but it won't add a new as insert into my database...why? What Did I do wrong? Thank you in advance Gary
  13. Ohhh, i don't know about that...I can see $_POST is useless to pass the value, only $_GET can do that... Some articles about $_POST and $_GET are not clear, I just understand that $_POST is an invisible, $_GET is visible. Now, you just clear my puzzled, Thank you! Gary
  14. I'm not sure I understand...using $_GET? it will be visual to computer, I rather to use $_POST than $_GET. I know how to write $_POST and $_POST in other page. In other page that I write: <tr><td>Identify Number:</td><td><?php echo $edit['ID']; ?></td></tr> But the value from the previous has not appear in HTML form in this current page from the previous page.
  15. Hi everyone, I am still learning PHP, I am trying to "update" the data in the database, I succeed create page to add (insert) the data in the database, but I can't figure how to update that the data come from link from previous page. Is that correct for script link to transfer to HTML form in other page in below of here? echo "<tr><td>".$row['FirstName']."</td><td>".$row['LastName']."</td><td>".$row['Email']."</td><td><a href='update.php?edit=$row[iD]'>EDIT</a></td></tr>"; the message shows me "update.php?edit=1" at left-bottom of website. But I clicked link to other page, seem the value has not passing to other page that i want to update in HTML form. Can you help? Thank you in advance time. Gary
  16. Moderator, are you telling me that I should change like this: 42 $show = "SELECT FirstName, LastName FROM Members"; 43 $result2 = mysqli_query($Garydb,$show) or die("Could not show record"); 44 45 if ($result2 = mysqli_num_rows($result2) or die("error display")) { 46 while ($row = mysqli_fetch_assoc($result2) or die("Could not fetch to display")) { 47 echo "<table><tr><td>".$row."</td></tr></table>"; 48 } 49 } 50 else { 51 echo "<table><tr><td>No display record</td></tr></table>"; 52 } Are they correct?
  17. Moderator, I just use die() to find the the error.
  18. Hi everyone, I am trying to display the record on website, but I could not. I checked many times, I don't see any error, seem to me, all structure is properly, but still showing error. Can you help me to find this error? 42 $show = "SELECT FirstName, LastName FROM Members"; 43 $result2 = mysqli_query($Garydb,$show) or die("Could not show record"); 44 45 if ($result3 = mysqli_num_rows($result2) or die("error display")) { 46 while ($row = mysqli_fetch_assoc($result3) or die("Could not fetch to display")) { 47 echo "<table><tr><td>".$row."</td></tr></table>"; 48 } 49 } 50 else { 51 echo "<table><tr><td>No display record</td></tr></table>"; 52 } the error showing is line 46 - Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, integer given in. Thank you in advance!
  19. Ummm...interesting your explain, Guru. Thank you so much!
  20. I think I get it clear, but i need to make sure...Is it good for prevent to store password in any web browser and application?
  21. I read this before, but i'm not understand what it does. can you please explain to me? Thanks
  22. I am trying to create the login system, I notice "hash" in mysqli_real_escape_string(hash("sha512", $_POST['password'])); Can anyone explain what "hash" use for in php? Thank you in advance time Gary
  23. Hi everyone I just completed my challenge: transfer name from first page to second page by POST and GET. Now, I will like to know if there is possible for me to display the list of name on PDF that come from php. For example, I have display list of name on page, but i will like to print list on display, but print on HTML is not really good, so i will like to print on PDF. Is there possible to do that? Please let me know and thank you so much! Gary
  24. Jazzman1, your code is working, but it apply to two columns, I need to have many columns, I notice ascending don't work in 1 and 3 or more than 3 columns. I added sort(), but seem it won't recognized this code to make those name stay in order...
  25. Oh FINALLY!!!! it works!!! FINALLY!!! i am going to create 200 name in database! It is EXACTLY what I need to do! Thank you, Cronix and Jazzman1!!!
×
×
  • 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.