Jump to content

asmith

Members
  • Posts

    967
  • Joined

  • Last visited

Posts posted by asmith

  1. <select name="test[]"  multiple="multiple">
    <option value="1"> 55 </option>
    <option value="2"> 66 </option>
    <option value="3"> 77</option>
    </select>
    

    the code above without "[]" , no matter how many choices been selected , overwrite to last one, putting [] , makes all selected a array  like :

    $test = $_POST[test];
    $test[0]
    $test[1]
    $test[2]
    // the values
    

     

    , why this code won't work properly ? (it has to remain the selected item for each pge reload, but it makes all confusing.mixed

     

     

     

     

    <?php
    echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" >';
    
    $options = array ("1"  =>  "55","2"  =>  "66","3"  =>  "77");
    
    
    echo '<select name="test[]" multiple="multiple">'; 
    $test = $_POST[test];
    $i  = count($test);
    $a = 0;
    while(list($aa,$bb) = each($options))
    {
    if ($a < $i){ 
    if ((isset($_POST['test1'])) AND ($test[$a] == $aa))
    {$sel = 'selected="selected"';$a++;} } 
    echo '<option value='.$aa.' '.$sel.'>'.$bb.'</option>';
    }
    echo '<input type="submit" name="test1" value="test" /></select></form>';
    
    ?>
    

     

    (BTW any more simple idea ? less coding ? )

  2. <form action="$_SERVER['PHP_SELF'] method="post">
    <input type="text" name="hello" value="$_POST['hello'] />
    <input type="submit" value="test" />
    </form>
    

    the above code , by pressing test (submit) button reload the page, and if user had typed anything to the field, it remains.

     

    i can't do the same thing with select option : (and more important to me, multiple select options)

     

     

    <form action="$_SERVER['PHP_SELF'] method="post">
    <select name="test" >
    <option value="1"> 1 </option>
    <option value="1"> 2 </option>
    <option value="1"> 3 </option>
    </select>
    <input type="submit" value="test" />
    </form>
    

     

     

    the best thing i could do was :

     

    
    <form action="$_SERVER['PHP_SELF'] method="post">
    <select name="test" >
    <option value="$_POST[test]"> $_POST[test] <option>
    <option value="1"> 1 </option>
    <option value="1"> 2 </option>
    <option value="1"> 3 </option>
    </select>
    <input type="submit" value="test" />
    </form>
    

     

    this code , when the page reload , saves the users choice, but if the user click on the menu , he will saw his selected option 2 times!

    the problem gets bigger, when i have about 20 options , that they can be choose multiple.

    anyone help ?

     

  3. header won't work in the middle of the html , it should be at the top . before html begins

    any special code that simply opens a link automaticlly anywhere on the page ? (PHP)

     

    It is ilogical to attempt to display data and then redirect. What is the point of displaying something if your simply going to redirect to another

     

    that's true, i just didn't want to rearrange codes !!

  4. header won't work in the middle of the html , it should be at the top . before html begins

    any special code that simply opens a link automaticlly anywhere on the page ? (PHP)

     

    for one thing the code i gave will only generate one link, if you notice im just if'ing the href portion of a single link, but now i understand what your wanting

     

    you can do it thru javascipt on the body tag onload event.

     

    <body onload="window.location = '<? if ($a = "hello") { echo "http://yahoo.com";} else {echo "http://gmail.com";} ?>'>
    

     

    it is a good code , but if the browser do not support java, it won't work .

     

  5. how can i tell php to run a link ?

    like :

     

    if ($a = "hello") { //goto "yahoo.com"
    else {//goto "gmail.com"
    

    of course i don't mean :  header(location :    )

    in header there should be nothing even a space before it ,

    i mean just simply run a link . !

  6. don't know if it is a mysql or php code,

    i want to delete the users which hasn't activate their accounts ,

    i send them through e-mail the activation link , if they do not click the link for example for 10 days, then their information in database will be deleted.

    how can i apply that ?

    (for the time they've signed up i've used mysql "now()" function)

  7. when a user log in :

    before i show him his logged page

    $_SESSION[user] = "aaa";
    

     

    and at all of user pages :

     

    if ($_SESSION[user] != "aaa") {header("location: login.php");exit;}
    

     

    1.is this way enough secure ?

    i mean i have put a "aaa" variable  , isn't that unsafe ?

    2.beside how can i use a changable variable for defining users ?

  8. i meant add a "string" to a record,

    update delete the last record and replace that with new one    ,

    i meant the new value go beside the old one ,

    old value    "i hate you john"

    i add    "!!!" to the field

     

    so it will be " i hate you john!!!"

     

    :)

  9. done ! i thought update do not delete last information , just add.

    is there a command to write a value beside the record ?

    for example in  a table , username = john .

    then  i would add "1"  in the right or left of john : 1john or john1 .

    (i know i could get john, put in a variable then add 1 to it ,  any sql comand instead of 3 ,4 php lines ?)

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