Jump to content

sigmahokies

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by sigmahokies

  1. Hi Phill W., I know about SQL injection, it's wide open. but it's practice, I said i will set up the SQL security after I make sure Insert and update is working. Relax! Also, I know how to close SQL in PHP, I want to make sure it is working, beside, it's in xampp, so it's localhost, not open to internet. I'm not that dumb. I need to practice to make it work, so I can move on with my demonstration to interview. SQL injection is my last to install in my code in PHP. Thanks, Gary
  2. I don't understand why it doesn't work to insert in Phpmyadmin (MariaDB) with my code...It saying failed to add all times. I know about security issue, I will install security later. I just want to make sure insert into MariaDB is working, then I will set up security system. Here my code: /* Register and check username and email is exist or not */ if (isset($_POST['submitted'])) { $username = $_POST['user']; $email = $_POST['email']; $first = $_POST['first']; $last = $_POST['last']; $password = $_POST['password']; $check_user = "SELECT * FROM username where Username = '".$username."'"; $check_email = "SELECT * FROM username where Email = '".$email."'"; $check_user2 = mysqli_query($GaryDB, $check_user); $check_email2 = mysqli_query($GaryDB, $check_email); if(mysqli_num_rows($check_user2) > 0) { $taken_user = "→ Sorry, Username is taken"; } elseif (mysqli_num_rows($check_email2) > 0) { $taken_email = "→ Sorry, E-mail is taken"; } else { $register = "INSERT INTO username (Username, Password, FirstName, LastName, Email) VALUES ('$username','$password','$first','$last','$email')"; $insert = mysqli_query($GaryDB, $register); } if ($insert) { $insert1 = "successfully added"; } else { $insert1 = "Failed to added"; } } Can you find what I did do wrong? Thank you in advance!
  3. All right, I'm trying to tell you that I'm trying to get all array from $srs in above of script into function below of loop in array, but problem is PHP still does not recognize $srs is defined from beginning of script; Look at image screen as example that need to be done.
  4. <?php $srs = array(); for ($section = 1; $section < 5; $section++) { for ($row = $section; $row < 10; $row++) { for ($seat = $row; $seat < 20; $seat++) { $srs[] = array( 'section_name' => $section, 'row_name' => $row, 'seat_name' => $seat); } } } output(convert_array($srs)); // Converts the array function convert_array($input) { return $input; } function output($obj) { echo "<pre>"; print_r($obj); echo "</pre>"; die; } ?> I'm trying to convert those array number to string, add implode() to make it happen, but seem PHP didn't recognize variable in $input. Like this implode("Section: ", $input) or (Section: ", $srs). Can you help me? Thanks, Gary
  5. My apology, I mean to name title "OOP vs Procedural", instead of PDO. Sorry...
  6. I want to see your opinion about OOP and Procedural. Which method has more easier to code in PHP? I'm using Procedural, but I notice PHP can read OOP as C++. Which is better for PHP? Thanks, Gary
  7. Hi everyone, It's been awhile since I was here in autumn time. How are everyone here? I'm good. I want to know, which best and cheaper host to create website with PHP? include Phpmyadmin or SQLBuddy. Please let me know... Thanks, Gary
  8. I put your code in above of my script, there is no error warning message on site.
  9. Hi everyone Happy Holiday to everyone!!! I am trying to create the form contact in PHP. I created form contact in html, But next page - I'm not sure it is right script in PHP to send email to my gmail account. I asked the hosting company to see if their server can send email to my gmail account, they said yes, should be. So, I create script in PHP, I don't know if it is right script, i hope you will find something missing in this script. I followed exactly from website, I tested to send then I checked my gmail account, this email has not sent. Can you help? Here my script: <?phpif (isset($_POST['submitted'])) {$name = $_POST['name'];$email = $_POST['email'];$select = $_POST['select'];$text = $_POST['text'];} $to = "xxxxxxx@gmail.com";$subject = "ASL class";$message = "Message is from ".$name.".\n The type class is ".$select.".\n The message said: ".$text; mail($to,$subject,$message); echo "<p>Sent! Thank you for fill an E-mail form</p>";?> Thank you in advanced, Gary
  10. Hi everyone, I want to ask for your opinion and advice. Is there possible for Deaf person getting a job as PHP web developer? I know few Deaf people who can write in PHP. I just want to see how chance for Deaf people, because discriminate against Deaf people are still exist in America even it is illegal. Please let me know, if you don't understand what I said, Please let me know, then i will be happy to repost in this thread. Thanks, Gary
  11. Barand and Psycho, it is working now. Thank you, Gary
  12. Hi everyone, I usually write PHP, but this time, I need a help in CSS. I am trying to create a vertical text, Not transfer rotate degree. I want to write like this: C L A S S Thanks, Gary
  13. Hi gizmola, I'm sorry for waste your time but explain about split, I found why it didn't work why PHP didn't take value from html's value...I forget to add the vertify the connect to MySQL. Like always start with connect to MySQL like this: <?php include('connection.php') ?> I did write this, but I forget to verify script connect INSIDE connection.php...that is why insert is not work. Now, it is working, even type of class are working by insert, so i can split this column into three columns to view which people are register for class. Thank you for your time...
  14. All right, gizmola I am trying to set up the three class, ASL1, ASL2, ASL3 in a one column that will split into three column on display to allow instructor see type of class.. I need to have three type ASL on one column, Like list of local and nonlocal in membership. I could put this tag - <td><input type="hidden" value="ASL1">ASL 1</td>. Seem PHP didn't take the post from value in html that will send value into table column. I don't want to have three tables, I prefer to have one table. For example, following register: Table: ID (AC) | FirstName | LastName | Email | Type Gary Taylor Gary@gmail.com ASL1 Wendy Taylor Wendy@gmail.com ASL2 [\php] So, In other display, then i can select column name from table name that where equal ASL 1 or ASL 2 or ASL 3. Instructor can tell which students are registered in those three classes. Get it? Please advise me if you don't understand what i am saying... Thanks in advance time Gary
  15. Thank you for advise, I am going to remove ENUM from phpmyadmin, trying to set up the one columns will split into three columns. Thank you.
  16. Hi everyone, I hope you have a great thanksgiving weekend. It is kind of hard for me to explain about ENUM in MySQL, Please forgive me for not good at grammar at English. Please let me know if you don't understand my request. I'm ASL user, English is my second language. I am trying to create the type of list in ENUM in website, I set up the MySQL (phpmyadmin) ENUM with three options, But i'm not sure how to do insert the option in MySQL, for example, IN PHP - $sql = "INSERT INTO Table_name (ID, FirstName, LastName, Type) VALUES (NULL, '$firstname','$lastname','option');. I know NULL is not require, but it is host-sharing is requiring it. However, That "option" is type in ENUM that I set, but in website, what is right script to insert the option in ENUM in table? I set ENUM by 'option1','option2','option3', how can i insert into table in that has option from website? Please forgive me if I don't make a clear to explain, I will do my best in next post in this thread.
  17. Psycho, It is working now, but I need to learn to do the logic in script in PHP. There are some things in PHP I don't understand fully. Like, I wonder why some people use "%", I know it is about like round, but how it does work? Also, I notice you put - ".=" it is a dot with equal, how it does work? I mean, why do you put ".=" instead of "==" or ">="...? I have few books about PHP, they don't explain very clearly about those. Can you give me a link for advance tutorial in PHP to use those letters? Thanks, Gary
  18. All right, I admit...English is my ESL - English Second Language. I'm Deaf. I am using American Sign language (ASL), I have problem with English that which conflict with ASL sometimes. I am trying to create a vertical data cell in the table that display the record from database. Please forgive me, I am very fluent in ASL, then English is my second language...once any second langauge, surely little lower skill in language. I might be not good at english, but I can do PHP. I hope everyone will understand. What i want is... 1 4 7 2 5 8 3 6 9 Got it? Thank you for be patient with me. Gary
  19. So, Do i have to change $result from $data, like $result['FirstName']? I did that...it is not showing, still empty in cell in table. Do I have to create 'while' to code with mysqli_fetch_assoc or mysqli_fetch_array instead of 'for'? Please advise me Thanks
  20. Hi everyone, I am still learning. I am trying to create the display the record in vertical columns, but set up the vertical columns with order by last name in MySQL is success, but problem that all table cell are empty that I write to display the record, seem MySQL's query did not answer or delivery the record from database. What did I do wrong? Here my code: $display = "SELECT ID, FirstName, LastName, MonthEx FROM Members ORDER BY LastName";$result = mysqli_query($Garydb, $display); $data = mysqli_num_rows($result);$row = 1;$col = 2; echo "<table border='1'>";for ($i = 0; $i < $data / $col; $i++) {echo "<tr>";for ($j = 0; $j < $col && $row <= $data; $j++, $row++) {echo "<td>".$data['FirstName']." ".$data['LastName']."</td><td><a href='update.php?update=$data[iD]'>EDIT</a></td><td><a href='delete.php?delete=$data[iD]'>DELETE</a></td>\n";}echo "</tr>";}echo "</table>"; funcation is working, but display the record hasn't come out from MySQL... Thank you in advance time. Gary
  21. Psycho, are you telling me that I have to put mysqli_real_escape_string and stripalashes in session and execute SQL all times to protect?
  22. Hi everyone, I don't understand why MySQL won't do execute query to delete record in phpmyadmin. I made a script in PHP, what did I do wrong? First page: <?php session_start(); if ($_SESSION['user']) { echo "<p>You are logging in as ".$_SESSION['user']." <a href='logout.php'>Log out</a></p>"; } else { header('location:denied.php'); } require('require.php'); ?> <!doctype html> <html> <head> <title>Delete your member's information</title> <link href="rcd.css" rel="stylesheet" type="text/css"> <link href="submit.css" rel="stylesheet" type="text/css"> </head> <body> <center> <p>Are you sure you want to delete this member's information?</p> <form action="delete2.php"> <table> <?php $del = $_GET['delete']; $show = "SELECT * FROM Members WHERE ID = '".$del."'"; $result = mysqli_query($Garydb, $show); if (mysqli_num_rows($result)) { while ($rows = mysqli_fetch_assoc($result)) { echo "<tr><td>First Name: </td><td><input type='text' value='".$rows['FirstName']."'></td></tr>"; echo "<tr><td>Last Name: </td><td><input type='text' value='".$rows['LastName']."'></td></tr>"; echo "<tr><td>Birth Month: </td><td><input type='text' value='".$rows['Month']."'></td></tr>"; echo "<tr><td>Email: </td><td><input type='text' value='".$rows['Email']."'></td></tr>"; echo "<tr><td>Local: </td><td><input type='text' value='".$rows['Local']."'></td></tr>"; echo "<tr><td colspan='2'><a href='delete2.php?delete2=".$rows['ID']."' style='font-size:20px;'>Delete Member's Information</a></td></tr>"; } } ?> </table> </form> <p><a href="register.php">Return to register page</a></p> </center> </body> </html> Second Page <?php session_start(); if ($_SESSION['user']) { echo $_SESSION['user']; }else { header('denied.php'); } require("require.php"); if ($_GET['delete2']) { $delete = $_GET['delete2']; } if ($delete) { $del = "DELETE * FROM Members WHERE ID = '".$delete."'"; mysqli_query($Garydb, $del); } ?> <!doctype html> <html> <head> <title>Deleted</title> </head> </html>
  23. I can't edit what i said in above. I am trying to protect this third page from manual web address by using session, but session_start(); just go an error. Thanks again, Gary
  24. Hi I'm back. I succeed to create the denial page if username and password are wrong and not exist, but i got problem with continue session by username, (of course, I won't continue the session by password). it get an error when conflict with header (redirect) and cache. There are three page that I am showing to you now. First page: <!doctype html> <html> <head> <title>Login System</title> <link href="rcd.css" rel="stylesheet" type="text/css"> <link href="font.css" rel="stylesheet" type="text/css"> <link href="submit.css" rel="stylesheet" type="text/css"> </head> <body> <form action ="checklogin.php" method="POST"> <center> <fieldset style='width:800px;'> <table cellspacing="10" cellpadding="10"> <p id="font">Please Login to RCD's database</p> <tr><td>Username:</td><td><input type="text" name="user" placeholder="Username"></td></tr> <tr><td>Password:</td><td><input type="password" name="pass" placeholder="Password"></td></tr> <tr><td colspan="2" align="center"><input id="submit" type="submit" name="submitted" value="Log in"></td></tr> </table> </fieldset> </center> </form> </body> </html> Second Page: <?php require_once("require.php"); session_start(); $username= stripslashes($_POST['user']); $password = stripslashes($_POST['pass']); $username = mysqli_real_escape_string($Garydb, $username); $password = mysqli_real_escape_string($Garydb, $password); $log = "SELECT username, password, type FROM username WHERE username ='".$username."' AND password = '".$password."'"; $result = mysqli_query($Garydb, $log); $count = mysqli_num_rows($result); if ($count == 1) { $_SESSION['user']; $_SESSION['pass']; header('location:register.php'); } else { die(header('location:denied.php')); } ?> <!doctype type> <html> </html> Third Page: <html> <?php require_once('require.php'); ?> <!doctype html> <head> <title>Register a new member</title> <link href="rcd.css" rel="stylesheet" type="text/css"> <link href="members.css" rel="stylesheet" type="text/css"> </head> <body> <?php session_start(); $_SESSION['username'] = $user; echo "<p>You are logged as ".$user."</p>"; ?> On this third page, I get an error message - Warning: session_start(): Cannot send session cache limiter - headers already sent I know I must write session_start(); on top of all php script, but I don't know why I gets error when I am got them right username and password. But yet, If someone typed wrong or not exist username and password will go to denied, it works. but i got error, session won't print on screen as you can see as logging. Can you help? Thank you in advance time. Gary
  25. Ok ok, you don't have to make bigger font size, ok? I am going to remove password in session... Done, removed.
×
×
  • 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.