Jump to content

johnake

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

johnake's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. You could try array_multisort: <? $breadcrumbs[] = array( 'name' => 'Computers', 'title_order' => 3, ); $breadcrumbs[] = array( 'name' => 'Printers', 'title_order' => 4, ); $breadcrumbs[] = array( 'name' => 'Misc.', 'title_order' => 5, ); foreach ($breadcrumbs as $key => $row) { $name[$key] = $row['name']; $title_order[$key] = $row['title_order']; } array_multisort($title_order, SORT_ASC, $name, SORT_ASC, $breadcrumbs); var_dump($breadcrumbs); ?>
  2. The script uses Smarty Web Templates engine. The $_POSTS are empty... I made something like this, but I have no ideea where to put this to in the code. if ($_POST['nume']==''||$_POST['email']==''||$_POST['subiect']==''||$_POST['mesaj']==''{ print("Display some error here!"); }
  3. As an addition to what thorpe said you could use some security to prevent injection: $name = $_GET['name']; should be $name=mysql_real_escape_string($_GET['name']); and so on. If you have a form that accept input you should use htmlspecialchars in order to prevent XSS. Good luck.
  4. Hello, I don't know if this is the right place to post, but I have a problem with my script. So here it goes. I have a contact page wich requeires some fields to be completed. The problem is when i type in the browser ?action=validate it inserts in the db a blank email adress and sends the mail with blank fields. The code loooks like this: <?php require_once('libs/Smarty.class.php'); require_once('lib/config.php'); $smarty = new Smarty(); require_once('leftColumn.php'); require_once('rightColumn.php'); //We declare the sessions if(!isset($_SESSION['nume'])) $_SESSION['nume'] = ''; if(!isset($_SESSION['email'])) $_SESSION['email'] = ''; if(!isset($_SESSION['subiect'])) $_SESSION['subiect'] = ''; if(!isset($_SESSION['mesaj'])) $_SESSION['mesaj'] = ''; if(!isset($_GET['actiune'])) $_GET['actiune'] = ''; switch($_GET['action']){ case '': $smarty->assign('titlu_formular', 'Formular de contact'); $campuri = array('nume' => array('camp' => 'Nume', 'valoare' => $_SESSION['nume']), 'email' => array('camp' => 'E-mail', 'valoare' => $_SESSION['email']), 'subiect' => array('camp' => 'Subiect', 'valoare' => $_SESSION['subiect'])); $textarea = array('mesaj' => array('camp' => 'Mesaj', 'valoare' => $_SESSION['mesaj'])); $smarty->assign('textarea', $textarea); $smarty->assign('formular', $campuri); break; case 'validate': $_SESSION['nume'] = $_POST['nume']; $_SESSION['email'] = $_POST['email']; $_SESSION['subiect'] = $_POST['subiect']; $_SESSION['mesaj'] = $_POST['mesaj']; $smarty->assign('done', 'Mesajul a fost trimis cu succes!'); $sql_insert_mail = "INSERT INTO `adrese` (`email`) VALUES ('".addentities($_SESSION['email'])."')"; mysql_query($sql_insert_mail)or die('Nu am putut adauga adresa in baza de date!'); $catre = '[email protected]'; $data_trimitere = date('d-m-Y H:i:s'); $subiect = $_SESSION['subiect']; $mesaj = ' <html> <head> <title>Formular de contact</title> </head> <body> <p><tt>Data trimitere: '.$data_trimitere.'</tt></p> <table> <tr> <td><tt>Nume: '.$_SESSION['nume'].'</tt></td> </tr> <td><tt>E-mail: '.$_SESSION['email'].'</tt></td> </tr> <tr> <td><tt>Subiect: '.$_SESSION['subiect'].'</tt></td> </tr> <tr> <td><tt>Mesaj:<br><br>'.$_SESSION['mesaj'].'</tt></td> </tr> </table> </body> </html>'; $headere = "MIME-Version: 1.0\r\n"; $headere .= "Content-type: text/html; charset=iso-8859-1\r\n"; $headere .= "From: ".$_SESSION['email']."\r\n"; mail($catre, $subiect, $mesaj, $headere); $_SESSION['nume'] = ''; $_SESSION['email'] = ''; $_SESSION['subiect'] = ''; $_SESSION['mesaj'] = ''; break; } $smarty->display('contact.tpl'); ?> Quick mention: I made an if statement that checks if the session is blank but it seems to skip that declaration. . I don't need a rewrite of the script just an explanation where I did wrong. Thank you
×
×
  • 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.