Jump to content
php.lv forumi

edi

Reģistrētie lietotāji
  • Posts

    144
  • Joined

  • Last visited

Posts posted by edi

  1. kas jārdaksta pie td, lai teksts neietu arpus tabulas, ja ir pa garu, bet parietu jauna rinda?

    mēģināju ar nowrap, bet vins vienkāši pagarina tabulu :D

    vajag tā, lai td max-width ir 600px

     

    td

    {

    text-align:left;

    padding: 3px;

    background-color:#FFF;

    max-width:600px;

    white-space: nowrap;

    }

    width paliek 600px, bet teksts tāpat iziet arā no td

  2. index.php

    <?php
    session_name (md5('SSS'));
    session_start ();
    $view	=	isset ( $_GET['view'] ) ? $_GET['view'] : NULL;
    require_once('header.php');
    require_once('functions.php');
    
    
    
    
    
    switch ($view) {
    
      default:
         echo "hellow world :D";
       break;
    
     case pirmais:
    
    
     .....
    
    
    
       break;
    
    
     case lalala:
    
    
    
    ....
    
    
    
       break;
    
    
    
    
    
    case login:
    
    echo '<center><form action="" method="POST" name="login" >
    	Login<br/><input type="text" class="inp" name="eml" size="23" value="" /><br />
    	Password<br/><input type="password"  size="23" /><br />							
    	<input id="" class="" type="submit" name="login" value="Ienākt"/>
    
    
    </form></center>';
    
    
    break;
    
    
    
    }
    require_once('footer.php');
    ?>

    kā uztaisti tā, ja lietotājs nav ielogojies ar savu vai arī kādu cita loginu, tad vinam tiek atverta case "login";

    + lietotājs ievadot savus datus formā un nospiežot pogu tiek parmests uz default un sanem savu sessiju.

    + neautorizēts lietotājs nevarētu atvērt citas lapas neautorizējoties ..

  3. Formas fails form.php

    <?php
    echo 'Pievienot jaunu lietotaju<br>
    <form name="" action="insert.php" method="post">
    Vards:<input name="name" type="text" value=""><br>
    Uzvards:<input name="lastname" type="text" value=""><br>
    Lietotajvards:<input name="username" type="text" value=""><br>
    Parole:<input name="password" type="text" value=""><br>
    <input type="submit" value="Send">
    </form>';
    ?>

     

    Formas datu fails insert.php

    <?php
    $name = $_POST['name'];
    $lastname = $_POST['lastname'];
    $username = $_POST['username'];
    $password = $_POST['password'];
    if(isset($_POST['level'])) { $level = 'admin'; }
    else { $level = 'user'; }
    
    $insert = mysql_query (INSERT INTO `db`.`users` (`username`, `password`, `name`, `lastname`, `level`) VALUES ('$usernamme', '$password', '$name', '$lastname', '$level'));
    
    if($insert)
    { echo 'Dati pievienoti'; }
    else { echo 'Dati nav pievienoti, jo: '.mysql_error(); }
    ?>
    

     

    Nu vienkāršajā variantā, tas apmēram tā varētu izskatīties, tik nevaig aizmirst veikt datu pārbaudi pirms tiek insertoti datu bāzē,

    kā arī paroles kriptēšnu un visas pārējās izvirtības, kas nepiecišamas pirms inserta ;)

    Bet gan jau lielie PHP guru ar ko ieteiks!

     

     

    pats tiku atrak gala neka postu sagaidiju :D

  4. kā var caur formu ierakstīt db?

    echo 'Pievienot jaunu lietotaju<br>
    <form name="" action="" method="post">
    Vards:<input name="Name" type="text" value=""><br>
    Uzvards:<input name="Secondname" type="text" value=""><br>
    Lietotajvards:<input name="username" type="text" value=""><br>
    Parole:<input name="password" type="text" value=""><br>
    <input type="submit" value="Send">
    </form>

     

    mysql_query (INSERT INTO `db`.`users` (`id`, `username`, `password`, `name`, `lastname`, `level`) VALUES ('$id', '$usernamme', '$password', '$name', '$lastname', '$level'));

    ceru ka sapratāt ko vajag..

    EDIT: laikam nepareizajā vietā topiku atvēru :D

×
×
  • Create New...