Jump to content

pwes24

Members
  • Posts

    56
  • Joined

  • Last visited

    Never

Posts posted by pwes24

  1. This is a small issue I believe, but I just can't get it right. Please help.

     

    I'm like to store login info for new users. This script should check user input and if empty, should return error msg and not save anything on the database table. But my code saves whatever is sent even if some sections are empty. What should I do?

     

    if ($name == "") {
    $error .= "Enter your name";
    }
    if ($username == "") {
    $error .= "Enter username";
    }
    if($password == "") {
    $error .= "Enter password";
    }
    else {
    $query = "insert into 'login' values()";
    

     

    I have shortened to get to the point. If I only use one 'if' and one 'else' statement it works well. What can I do?

  2. Hello everyone,

     

    I have two issues regarding dates:

    1. How can i capture a formatted instance of a particular date like now in a variable to store on a database table;

    2. How do i calculate between two dates and come up with the days, hours and minutes between them?

     

    Thank yall!

  3. Hello everyone,

     

    I'd like to sort a table(descending) after fetching it. What expressions should I use. Also if you know where I can read more on this and other related topics, please let me know. Thank you.

  4. Hello everyone,

    Is there a way I can play the same song over different web pages on my website without the song loading on every new page I'm visiting?

    I don't know where to ask this question, so I'll try here.

    Thank you.

  5. Hi everyone. I have script to logout a user but I've realized that if after logging out a user can go back in the same browser and view restricted files. This script works only if the user closses the browser window. Any ideas?

    <?php
    session_start();
    if (isset($_SESSION['user_id'])) {
    echo "Your username is ".$_SESSION['user_id'].".<br>";
    session_destroy();
    echo "Your username is still ".$_SESSION['user_id'].".<br>";
    $_SESSION = array();
    echo "You are now logged out!";
    }
    ?>
    

  6. Hello everyone.

     

    Say you have two forms on a page that gather different information. How do i make sure that script working on a particular form is called when the other form is submitted? Do I use,

                if($_POST['submit']) { ?

    and does the 'submit' stand for the name of the submit button?

     

    Thanks for reading this post.

  7.  

    What am I doing wrong here?

     

    <body>

    <?php

    if (isset($_POST['submit'])){

    $food=$_GET[food];

    if (!empty($food)) {

    echo "The foods selected are:<br />";

    foreach($food as $foodstuff) {

    echo $foodstuff.", ";

    } else {

    echo('check a box please');

    }

    }

    }

    ?>

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

    <fieldset>

    <label>Italian <input name="food[]" type="checkbox" value="Italian" checked /></label>

    <label>Mexican <input name="food[]" type="checkbox" value="Mexican" /></label>

    <label>Chenese <input name="food[]" type="checkbox" value="Chenese" /></label>

    </fieldset>

    <input type="submit" value="submit" name="submit">

    </body>

  8. Well the script is pretty long but heres a picture:

     

    a user needs to state what days he's available to work. Let's say he is available Friday and Monday. The table handlin user info has one spot to store these days. so first i capture user selection as $days=$_get['days'] and insert into `table` as $days. when i check user input in the table, it shows "array". Can i have something like Friday, Monday?

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