Jump to content

davidannis

Members
  • Posts

    627
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by davidannis

  1. I really don't like the way your login script stores the password in a cookie. That's not very secure. I guess it depends what you are trying to do but storing a password in plain text and passing it back from the browser with every page request is just sloppy.

     

    To address Requinix's concern you should create a staff_id column as she detailed in post #6 and substitute $_SESSION['staff_id'] for $_SESSION['username'] in the code I posted.

  2. At the top of the login script add a

    session_start();
    

    Note: this needs to happen before you output anything, so just put it at the top of the script.

    Then after the user is verified do this:

    $_SESSION['username']=$variable_you_stored_username_in ; 
    

    on the script that you use to record form data you'll do the session_start() at the top again and have something like this:

    $sanitized_field1=mysqli_real_escape_string($connection, $_POST[field1']; // sanitize all fields thsi way
    $sql="INSERT into `dispatch` ('field_name', 'some_other_name', 'username') VALUES ('$sanitized_field1', '$sanitized_field2', $_SESSION['username'])";
    
  3. Try this:

    <?php
    if ($_POST['games']!='') echo '<h1>Last time you selected '.$_POST['games'].'</h1>'; 
    ?>
    <form action="mypage.php" method="POST">
    <p>Select a game:</p>
    <select name="games" size="3">
    <option value="1">game1</option>
    <option value="2">game2</option>
    </select>
    <input type="submit">
    </form>
    

    save it as mypage.php and run it a couple of times to see how it works.

  4. What Jessica said is do something like this:

    //Note: removed ! in the line below
        if(isset($_GET['limit'])) {
       $num_rows=intval($_GET['limit'] ) ; //cast to an integer - makes it work for any number of rows
        $fetch = mysql_query("SELECT * FROM (table name) LIMIT 0, $num_rows")or
        die(mysql_error());
        }
    

    also needed to remove the test for if limit was 10

  5. I have added Dr Freak code after the insert and it gives me 2 strange errors:

     

    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, object given in /home...
     
    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home....
     
     
    Any idea what this translate to please?

    You never connected to the database. You will need to create the database and add the table first. I'd recommend using PhpMyAdmin. Google mysql php tutorial for an overview of how  MySQL works or perhaps Jessica can recommend one. Then you need a line in your code before you do anything wiht Mysql like

    
    $con = mysqli_connect("localhost", "my_user", "my_password", 'my_db');
    
  6. I think that you should not try to create the table in your script.

    mysqli_query($con,"CREATE TABLE $tbl_name");
    

    Set it up once, before your site goes live and forget about it. When you create the table make the phone column a unique key. This will not allow a duplicate phone to be inserted. Before the insert try something like:

    $result=mysqli_query($con,"SELECT * FROM $tblname WHERE phone=$phone");
    $row_cnt = mysqli_num_rows($result);
    if ($row_cnt>0){
    echo "this phone number has already been used";
    }else{
    // Do your insert here
    }
    
  7. <form action=bills.php method=POST<input type=submit name=submit value=Remove</form>

    Valid HTML would be helpful here.

     

    I pointed that out in replies 18 and 19 on this thread. If OP doesn't fix it this go around I think I'm done with this topic.

     

    Apologies for the snarky tone.

  8. You didn't apply the previously mentioned fixes. This:

    <td><form action=bills.php method=POST<input type=submit name=submit value=Remove</form></td>
    

    should be something like this:

    <td><form action=\"bills.php\" method=\"POST\"> <input type=\"submit\" name=\"submit\" value=\"Remove\"><input type=\"hidden\" name=\"id\" value=\"$id\"></form></td>
    
  9. I believed that I answered the question: told you what the errors were and quoted the two lines of code that had the errors in them. I then went on to suggest that if you were coding in a good IDE all of the errors you posted would have been far less likely to occur and easier to spot. Please read my posts again.

  10. There is not enough information in your post to begin to answer the question. What is the application written in? How many colors need to change? On how many screens? Is color dependent on some variable or static? Categories of what? Are the categories stored in a database? What information needs to be stored about each category?  The list could go on. Please describe the application and the changes you want in detail to get a meaningful answer.

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