Jump to content

J.Daniels

Members
  • Posts

    143
  • Joined

  • Last visited

    Never

Posts posted by J.Daniels

  1. With the two pieces of code you have provided, and assuming they are they in the same if/else statement, $arr_email only gets added to if $_POST['Submit_Auto'] is true and $_POST['Email_Auto'] is false.

     

    So when Email_Auto is submitted, it goes into the elseif statement where you are only trying to read from the $arr_email array.

  2. mysql_last_insert_id() only returns an id if there was a previous INSERT statement.  Unless you have performed an INSERT before your code, it will return 0.  If you want both columns to have the same id, you will have to do the INSERT, then UPDATE the record with mysql_last_insert_id().

     

    If this is what you are looking for, I am curious as to why you would need two columns with the same id.

  3. Working from your display code, you have a semi-colon after the while and you do not need the foreach:

     

    <?php 
    while($row=mysql_fetch_array($query, MYSQL_ASSOC)) {
    ?>
    <div class="id_box"><?=$row['internal']?></div>
    <div class="from_box"><?=$row['name']?></div>
    <div class="from_email_box"><?=$row['email']?></div>
    <div class="msg_status_box"><?=$row['status']?></div>
    <div class="reply_status_box">
    <a href="?more=<?=$row['internal']?>">more</a>
    </div>
    <div class="updated_box">
    <? if(empty($row['reply_time'])){
            print "".$row['time']." on ".$row['date']."";
        }
        else{
            print "";
        }
    }
    ?>
    

     

    Also, before the while loop, you can echo out the number of rows to make sure there are two rows returned:

     

    echo mysql_num_rows($query);
    

  4. You are missing a closing parenthesis

     

    mysql_query("insert into `demo_users` (`name`, `company`, `address`, `city`, `state`, `zip`, `phone`, `email`) values ('$name', '$company', '$address', '$city', '$state', '$zip', '$phone', '$email')") or die(mysql_error());
    

  5. Personally, when I enter dates into a database, I use MySQL's DATE types.  This allows you to order by date, or select by a range of dates.

     

    However, using your database structure, you can order your results by multiple columns.

     

    $nextEvents = "SELECT * FROM calendar ORDER BY year, month, day DESC LIMIT 0, 3";
    

     

    This should order the records by year, then month, then day in a descending order.  The LIMIT only returns the first 3 records.

  6. This is what I'm assuming you are trying to do with your code.

    <?php session_start();
    
    include 'Functions.php';
    include 'Database.php';
    
    $username = Clean($_POST['username']);
    $password = Encrypt($_POST['password']);
    $sekret = Clean($_POST['sekret']);
    $POST = count($_POST);
    $GET = count($_GET);
    $length = strlen($_POST['username'] || $_POST['password']);
    
    if ($_SESSION['token'] != $_POST['token']) {
            echo "Invalid submission.";
            exit();
    }
    
    if ($POST == 4 && $GET == 0) {
    
            if ($length > 32) {
    
                    $sql = "SELECT * FROM `users` WHERE `username` = '$username' AND `password` = '$password'";
                    $results = mysql_query($sql) or die (mysql_error());
    
                    if (mysql_num_rows($results) > 0) {
    
                            header('Location:hello.php');
    
                    } else {
    
                            print "Error, Account Does Not Exist";
    
                    }
    
            } else {
    
                    print "Submission Error, Post Varibles Too Long";
    
            }
    
    } elseif ($POST < 4 && $GET == 0) {
    
            print "Error, Please Enter All Field's";
    
    } else {
    
            print "Submission Error, Too Man Post Varibles.";
    
    }
    ?>
    

     

    I am just a little unclear on what you are trying to do with this part:

    $length = strlen($_POST['username'] || $_POST['password']);
    

    I think (I haven't tested this) this will always return a length of 1 as it is a conditional check.

  7. Also, you need to switch the two else statements.

     

    The first if checks if the username and password have been supplied.  The second if checks if they match any record in the database

     

    <?php session_start();
    
    include 'Functions.php';
    include 'Database.php';
    
    $username = Clean($_POST['username']);
    $password = Encrypt($_POST['password']);
    
    if (isset($username) && isset($password)) {
    
    $sql = "SELECT * FROM `users` WHERE username = '$username' AND password = '$password'";
    $results = mysql_query($sql) or die (mysql_error());
    
    if (mysql_num_rows($results) > 0) {
    
    header('Location:hello.php');
    
    } else {
    
    print "Account Does Not Exist";
    
    }
    
    } else {
    
    print "Please Enter All Field's";
    
    }
    ?>
    

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