Jump to content

wildteen88

Staff Alumni
  • Posts

    10,480
  • Joined

  • Last visited

    Never

Posts posted by wildteen88

  1. In main.php you're calling header("location:attendance.php"); after output has been sent. header() cannot be called after output has been sent to the browser. You should move this block of code in main.php

    <?php
    if(!empty($_POST['submit']))
    {
      $username=$_POST['username'];
      $pwd=$_POST['pwd'];
    $_SESSION['user']=$username;
      //$_SESSION['user'];
      $_SESSION['pswd']=$pwd;
    }
    header("location:attendance.php");
    
    
    ?>

    Into the same code block where you have session_start();.

     

    Use this code for main.php

    <?php
    session_start();
    //include "../sabkuch/dbconnect.php";
    
    if(isset($_POST['submit']))
    {
        $username = $_POST['username'];
        $pwd = $_POST['pwd'];
        
        $_SESSION['user'] = $username;
        $_SESSION['pswd'] = $pwd;
        
        header("location:attendance.php");
    }
    
    ?>
    <form name="login" method="post" action="#">
        <b>ENTER YOUR DETAILS BELOW</b><br/>
        <hr/>
        USERNAME:<input name="username" type="text" value=""><br/>
    
            PASSWORD:<input name="pwd" type="password" value=""><br/>
        <input name="submit" type="submit" value="LOGIN">
    
    </form>

     

    The next issue is in attendence.php, on  line 16 you're calling session_destroy();.  Calling this function will destroy the current session. You should only call this function in certain circumstances, such as when logging out the current user. If you leave it as is every time you go to main.php and fill in your username/password your session will always be reset.

  2. No problem. Also another tip. When comparing values you should be using the comparison operator (==), not the assignment operator (=). String should always be wrapped in quotes. Otherwise PHP will think the word news is a constant rather than a string.

        if($page = news){

    So that line should read

        if($page == 'news'){

  3. Just include news.php and don't pass a query string to.

            include("inc/news.php");

    $_GET['id'] in news.php will return the id passed to it from your parent script (index.php?page=news&id=123)

     

    Before I said you can't pass a query string to an include. You can do this by using a url as the path

    include "http://site.com/file.php?var=value"

    However if you wish to use any variables from file.php within your parent script you wont be able to do this. This is because when you use a url as the path for an include only output from that file (text/html) will be returned. The raw php source code of that file will not be returned.

  4. I still don't fully understand the logic with the  . ';" '; stuff

    It is because you're outputting CSS. PHP and CSS statements must be ended with a semi-colon at the end of the line. A better way to code this

    <p
    <?php
    echo ' style="font-family: ' . $_POST['font'] . '; ';
    echo 'font-size: ' . $_POST['size'] . '; ';
    echo 'color: ' . $_POST['color'] . '; "';
    ?> >

    Could be as

    <p style="font-family: <?php echo $_POST['font'] ?>; font-size: <?php echo $_POST['size'] ?>; color: <?php echo $_POST['color']?>;">

     

  5. That is what my original code did! Did you even try my code example?

    if(!empty($store[$i]))
    			    $values[$i] = "( '{$id[$i]}', '{$store[$i]}', '{$item[$i]}', '{$itemprice[$i]}', '{$itemnumber[$i]}', '{$couponvalue[$i]}', '{$couponsused[$i]}')"; // build the array of values for the query string

     

    The ! symbol means NOT. The if statment means this is. If the store field for the current row IS NOT empty them add the store, item, price etc into the database.

  6. Your rewrite rule is incorret, it should be

    RewriteRule cat/(\w+)$ urls.php?cat=$1

    Mod rewrite will not rewrite your existing links within your files. You'll need to change say

    <a hef="urls.php?cat=whatever">whatever</a>

    to

    <a hef="/cat/whatever">whatever</a>

    Yourself.

     

    If you went to http://localhost/urls/urls.php?cat=mouse it will not redirect the user to http://localhost/urls/cat/mouse

     

    In fact, even http://localhost/urls/urls.php/cat/and/mouse/are/having/a/fight/over/bacon does not give an error, instead,  it is still displaying the content of http://localhost/urls/urls.php

    That is because that is infact a valid url

  7. I don't think you can make a submit button a link

    <a href="http://www.ebermylove.com/login.php"><input type="submit" name="submit" value=" Submit! "></a>

     

    What are you trying to do submit the form to login.php and form.php?

     

    PS when posting code wrap it within

    
    

    or

    
    

    tags

  8. The text that comes after the question make in the url is referred to as the query string. It is up to you what you set in the query string in order for your php script to function. For example you're making a news script. You may code this script so it requires an id variable to be passed in the query string to grab a news entry within a database that is associated with that id.

  9. IIS is preventing PHP from writing files to C:\inetpub\wwwroot\. I think you need to configure IIS to allow PHP to write files to www directory.

     

    To fix this error

    It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for '1.0/no DST' instead in C:\inetpub\wwwroot\10.php on line 3

    Set date.timezone to Europe/Paris or whatever your timezone is within the php.ini

    date.timezone = Europe/Paris

    IIS may need to be restated in order for the changes to take affect.

  10. I would then like to sort those arrays by things like branch name, costs and profit.

    Wouldn't it be easier to do this within your query eg

    SELECT brand, costs, profit FROM table ORDER BY brand ASC

    That will return all the branches in alphabetical order.

  11. Change the if statement to just

    				if(!empty($store[$i]))
    			    $values[$i] = "( '{$id[$i]}', '{$store[$i]}', '{$item[$i]}', '{$itemprice[$i]}', '{$itemnumber[$i]}', '{$couponvalue[$i]}', '{$couponsused[$i]}')"; // build the array of values for the query string

    That will make just the store field require. The others will be optional.

     

    As your table stands you have 7 fields in your table (user_id, store, item, itemprice, itemnumber, couponvalue, couponsused). Each of those fields will require a value of some sort (be it an empty value or what is entered in your form). If you only want the store name inserting into one row, then on the next row you add in the item, itemprice, itemnumber, couponvalue, couponsused values then that is bad database design.

     

    A better way would be to enter all your stores within your stores table, then just have the store id of the store that the product belongs to within your item table.

  12. You should format your code so it becomes easier to read. The issue is your're not ending your echo statements with a ;

    if (strtotime($row['shutoff']) <= time()) {
       echo 'No longer accepting registrations.';
    } else {
       echo "<INPUT TYPE='submit' name='submit'   VALUE='Register'>";
    }

  13. Yes a form can have multiple submit buttons.

    <?php
    
    if(isset($_POST['bob_submit']))
    {
         echo "send message to bob";
    }
    elseif(isset($_POST['richard_submit']))
    {
         echo "send message to richard";
    }
    
    ?>
    
    <form action="" method="post">
    
    <input type="submit" name="bob_submit" value="Send to Bob" /> Or <input type="submit" name="richard_submit" value="Send to Richard" />
    </form>

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