Jump to content
alexer13

Camp obligatoriu

Recommended Posts

Posted

am urmatorul cod php

<?php 
// Scrie data si ora in fisierul cu dedicatii.
$luna = array("","Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie");
$data = '<b>Data si ora:</b> '.date("d ",time()).$luna[date("n",time())].date(" Y, H:i", time()).'<br />';

// Get the data from the 'nume' field of the form.
$data = $data.'<b>Nume Prenume:</b> '.htmlentities($_POST['nume']).'<br />';

// Get the data from the 'telefon' field of the form.
$data = $data.'<b>Telefon:</b> '.htmlentities($_POST['telefon']).'<br />';

// Get the data from the 'oras' field of the form.
$data = $data.'<b>Oras:</b> '.htmlentities($_POST['oras']).'<br />';

// Get the data from the 'produs' field of the form.
$data = $data.'<b>Produs:</b> '.htmlentities($_POST['produs']).'<br />';

// Get the data from the 'sugestii' field of the form.
$data = $data.'<b>Comentarii/sugestii:</b>'.''.htmlentities($_POST['sugestii']).'<br />';




// Adresa IP
$ip = $_SERVER['REMOTE_ADDR'];
if (strstr($ip, ",")) {
$ipuri = explode(", ", $ip);
$ip = $ipuri[0];
} else { $ip = $_SERVER['REMOTE_ADDR']; }
$data = $data.'<b>Adresa IP: </b>'.''.$ip.'<hr />';


// $email is detecting if the 'nume' field is empty.
$name = htmlentities($_POST['nume']);



// $message is detecting if $spam words are in the 'mesaj' field.
$message = htmlentities($_POST['telefon']);

// Specifications of the "bad words", spam, in the 'mesaj' field.
$spam = "/(pula|pizda|coaie|muie|curva|fut|cacat)/i";
if (empty($name))
{
echo ('<br /><br /><center><body bgcolor=#FFFFFF " background="bgsite.gif"><img src=tabel.png></center>');
}
else
{
// Detects the $spam word and displays it in the warning.
if(preg_match($spam,$message,$matches))
{
echo ('<br /><br /><center><body bgcolor="#FFFFFF" background="bgsite.gif"><img src=vulgar.png></center>');
}
elseif(preg_match($spam,$name,$matches))
{
echo ('<br /><br /><center><body bgcolor="#FFFFFF" background="bgsite.gif"><img src=vulgar.png></center>');
}
else
{
// The file to write $data to (don't forget to CHMOD it to 777 or rwx-rwx-rwx).
$file = "dedicatii.txt";
if (!$file_handle = fopen($file, "a+"))
{
echo "Momentan nu pot fi trimise comenzi. Nu pot deschide fisierul.";
}
if (!fwrite($file_handle, $data))
{
echo "Momentan nu pot fi trimise comenzi. Nu pot scrie in fisier.";
}
fclose($file_handle);
echo ('<br /><br /><center><body bgcolor="" background="bgsite.gif"><img src=trimis.png></center>');
echo ('<meta http-equiv="Refresh" content="4;url=comanda.php" />');
}
}
?>

si as vrea sa fac mai multe campuri obligatorii.. in ce linie si cum mai exact pot modifica acest aspect

Posted

<?php
$errors = array();
$data = array(
'nume' => trim($_POST['nume']),
'telefon' => trim($_POST['telefon'])
);

foreach($data as $key => $value )
if($value == '')
$errors[$key] = 'Acest camp este necesar';

if(empty($errors)) {
// OK
} else {
// Arata erorile
}
?>

Posted (edited)

in ce zona il pot introduce ?

//

Warning: fwrite() expects parameter 2 to be string, array given in C:\xampp\htdocs\comanda\trimite.php on line 80

Momentan nu pot fi trimise comenzi. Nu pot scrie in fisier.

Edited by alexer13

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...