Jump to content

sigmahokies

Members
  • Posts

    138
  • Joined

  • Last visited

Posts 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.

     

     

    Screen Shot 2019-10-17 at 8.25.25 AM.png

  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. All right gw1500se,

    Here my full code, but it is three file different. one html and two php. I use php file to upload video, I use one html to let anyone know (display on monitor) that file is exist in folder. 

    upload file first:

    	<?php
    	?>
    <!doctype html>
            <html>
            <head>
                <link href="css/upload.css" rel="stylesheet" type="text/css">
            </head>
            <body>
            <form action="upload.php" method="post" enctype="multipart/form-data">
                <table class="table">
                    <tr>
                        <td colspan="2" align="center" class="children"><label for="file1">Children:</label></td>
                    </tr>
                    <tr>
                        <td>First Name:</td>
                        <td><input type="text" name="first" required></td>
                    </tr>
                    <tr>
                        <td>Last Name:</td>
                        <td><input type="text" name="last" required></td>
                    </tr>
                    <tr>
                        <td>School Name:</td>
                        <td><input type="text" name="school" required></td>
                    </tr>
                    <tr>
                        <td>Grade:</td>
                        <td><select name="grade">
                                <option value="3">3</option>
                                <option value="4">4</option>
                                <option value="5">5</option>
                                <option value="6">6</option>
                                <option value="7">7</option>
                            </select></td>
                    </tr>
                    <tr>
                        <td>Age:</td>
                        <td><input type="text" name="age" required></td>
                    </tr>
                    <tr>
                        <td>Test Video:</td>
                        <td><input type="radio" name="videos" value="Home">Home Alone</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><input type="radio" name="videos" value="Breakfast">Tiffany Breakfast</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td><input type="radio" name="videos" value="Spider">Spider</td>
                    </tr>
                    <tr>
                        <td class="lowerfont">Upload your video</td>
                        <td><input type="file" name="file1" id="file1"></td>
                    </tr>
    	                <tr>
                        <td>&nbsp;</td>
                        <td><input type="submit" name="video" value="Upload your video"></td>
                    </tr>
                </table>
            </form>
            <h2><a href="deletevideo.php" style="margin-left: 550px; color: white; text-decoration: none;">Go to Delete
                    Video site</a></h2>
            <h2><a href="list.html" style="margin-left: 550px; color: white; text-decoration: none;">Return to list site</a>
            </h2>
            <div class="check"></div>
            </body>
            </html>
    	

    now, run to upload site...

    [/php]

    	<?php
    	require ("access.php");
    	// if the form was posted,    process the upload
    if ($_POST['video']) {
    	        $path1 = "UPLOADS/Home/";
            $path2 = "UPLOADS/Breakfast/";
            $path3 = "UPLOADS/Spider/";
    	        $scan1 = scandir($path1);
            $scan2 = scandir($path2);
            $scan3 = scandir($path3);
    	        $count1 = count($scan1) - 3;
            $count2 = count($scan2) - 3;
            $count3 = count($scan3) - 3;
    	        if($count1 !== 0) {
                header('location:exist.html');
            }elseif ($count2 !== 0) {
                header('location:exist.html');
            }elseif ($count3 !== 0) {
                header('location:exist.html');
            }
    	    $first = $_POST['first'];
        $last = $_POST['last'];
        $school = $_POST['school'];
        $age = $_POST['age'];
        $grade = $_POST['grade'];
        $option = $_POST['videos'];
    	    if ($option == "Home") {
            $fileToMove = $_FILES['file1']['tmp_name'];
            $destination = "UPLOADS/Home/" . $_FILES['file1']['name'];
        } elseif ($option == "Breakfast") {
            $fileToMove = $_FILES['file1']['tmp_name'];
            $destination = "UPLOADS/Breakfast/" . $_FILES['file1']['name'];
        } elseif ($option == "Spider") {
            $fileToMove = $_FILES['file1']['tmp_name'];
            $destination = "UPLOADS/Spider/" . $_FILES['file1']['name'];
        }
    	        if ($first && $last && $school && $age && $grade && $option) {
                $GaryDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                $exec = $GaryDB->prepare("insert into Children (`FirstName`, `LastName`, `School`, `Grade`, `Age`) values (:firstN, :lastN, :school, :grade, :age)");
    	            $exec->bindValue(':firstN', $first, PDO::PARAM_STR);
                $exec->bindValue(':lastN', $last, PDO::PARAM_STR);
                $exec->bindValue(':school', $school, PDO::PARAM_STR);
                $exec->bindValue(':grade', $grade, PDO::PARAM_STR);
                $exec->bindValue(':age', $age, PDO::PARAM_STR);
                $exec->execute();
    	            if (move_uploaded_file($fileToMove, $destination)) {
                    header('location: uploaded.html');
                } else {
                    header('location: failupload.html');
                }
            }
        }
    ?>
    	

    Now, exist.html...

    	<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Exist video</title>
        <link href="css/upload.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    <h2>There is video inside, you need to delete it to first.</h2>
    <h2><a href="deletevideo.php">Delete site</a></h2>
    </body>
    </html>
    	

    that's my full code in html and php

  6. Hi gw1500se,

     

    This part is not work to not send to other site name 'exist.html' if php find one video is inside folder in server. I notice server is still taking uploading file when file is exist already in folder. I'm trying to stop upload file into folder when there is one video or document inside folder already.

  7. Hi everyone, I'm still learning, but getting intermediate in PHP now, but it is still challenge to learn. I'm trying to have php check to see if one file inside folder in server, seem I could not get it right, but I tested it on other site, it works, but not this script, I don't understand why it won't work...maybe logical is wrong?

    here my code:

    	if ($_POST['video']) {
    	        $path1 = "UPLOADS/Home/";
            $path2 = "UPLOADS/Breakfast/";
            $path3 = "UPLOADS/Spider/";
    	        $scan1 = scandir($path1);
            $scan2 = scandir($path2);
            $scan3 = scandir($path3);
    	        $count1 = count($scan1) - 3;
            $count2 = count($scan2) - 3;
            $count3 = count($scan3) - 3;
    	        if($count1 > 0) {
                header('location:exist.html');
            }elseif ($count2 > 0) {
                header('location:exist.html');
            }elseif ($count3 > 0) {
                header('location:exist.html');
            }
    	

    But other site, it works:

    	$scan = scandir($path);
    $count = count($scan) - 3;
    	echo $count;
    	if($count > 1){
        echo "Hello yourself!<br />";
    }
    	

    Anyone will help will be appreciate! Thank you!

    Gary

  8. 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

  9. 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

  10. 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
  11. 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

  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. 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.

  16. 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

  17. 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 

  18. 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
  19. 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>
×
×
  • 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.